WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-133730-20140612170839.patch (text/plain), 43.34 KB, created by
Adrian Perez
on 2014-06-12 07:06:51 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Adrian Perez
Created:
2014-06-12 07:06:51 PDT
Size:
43.34 KB
patch
obsolete
>Subversion Revision: 169890 >diff --git a/Source/WebKit2/PlatformGTK.cmake b/Source/WebKit2/PlatformGTK.cmake >index 7649f14d97c96240547e611bc94d18312fd2119c..7ea281dfb47866f2db7d326b637167286f34d859 100644 >--- a/Source/WebKit2/PlatformGTK.cmake >+++ b/Source/WebKit2/PlatformGTK.cmake >@@ -207,6 +207,11 @@ list(APPEND WebKit2_SOURCES > UIProcess/API/gtk/WebKitURISchemeRequest.cpp > UIProcess/API/gtk/WebKitURISchemeRequest.h > UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h >+ UIProcess/API/gtk/WebKitUserContent.h >+ UIProcess/API/gtk/WebKitUserContent.cpp >+ UIProcess/API/gtk/WebKitUserContentPrivate.h >+ UIProcess/API/gtk/WebKitUserContentManager.h >+ UIProcess/API/gtk/WebKitUserContentManager.cpp > UIProcess/API/gtk/WebKitVersion.cpp > UIProcess/API/gtk/WebKitVersion.h.in > UIProcess/API/gtk/WebKitWebContext.cpp >@@ -349,6 +354,8 @@ set(WebKit2GTK_INSTALLED_HEADERS > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitURIRequest.h > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitURIResponse.h > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitURISchemeRequest.h >+ ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitUserContent.h >+ ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitUserContentManager.h > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebContext.h > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebInspector.h > ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebResource.h >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..48674c551d7cc9fb3dc765c4fd6af06ee2fe86ee >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.cpp >@@ -0,0 +1,312 @@ >+/* >+ * Copyright (C) 2014 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "WebKitUserContent.h" >+ >+#include "WebKitPrivate.h" >+#include "WebKitUserContentPrivate.h" >+ >+#include <WebCore/page/UserScript.h> >+#include <WebCore/page/UserStyleSheet.h> >+#include <wtf/text/CString.h> >+#include <wtf/text/StringBuilder.h> >+ >+using namespace WebCore; >+ >+ >+static inline UserContentInjectedFrames toUserContentInjectedFrames(WebKitUserContentInjectedFrames injectedFrames) >+{ >+ switch (injectedFrames) { >+ case WEBKIT_USER_CONTENT_INJECT_TOP_FRAME: >+ return InjectInTopFrameOnly; >+ case WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES: >+ return InjectInAllFrames; >+ default: >+ ASSERT_NOT_REACHED(); >+ return InjectInAllFrames; >+ } >+} >+ >+ >+static inline UserScriptInjectionTime toUserScriptInjectionTime(WebKitUserScriptInjectionTime injectionTime) >+{ >+ switch (injectionTime) { >+ case WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START: >+ return InjectAtDocumentStart; >+ case WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END: >+ return InjectAtDocumentEnd; >+ default: >+ ASSERT_NOT_REACHED(); >+ return InjectAtDocumentStart; >+ } >+} >+ >+ >+static inline UserStyleLevel toUserStyleLevel(WebKitUserStyleLevel styleLevel) >+{ >+ switch (styleLevel) { >+ case WEBKIT_USER_STYLE_LEVEL_USER: >+ return UserStyleUserLevel; >+ case WEBKIT_USER_STYLE_LEVEL_AUTHOR: >+ return UserStyleAuthorLevel; >+ default: >+ ASSERT_NOT_REACHED(); >+ return UserStyleAuthorLevel; >+ } >+} >+ >+ >+struct _WebKitUserContentPrivate { >+ _WebKitUserContentPrivate() >+ : injectedFrames(WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES) { } >+ >+ CString source; >+ Vector<String> whitelist; >+ Vector<String> blacklist; >+ WebKitUserContentInjectedFrames injectedFrames; >+}; >+ >+WEBKIT_DEFINE_TYPE(WebKitUserContent, webkit_user_content, G_TYPE_OBJECT) >+ >+ >+static void webkit_user_content_class_init(WebKitUserContentClass*) >+{ >+ // Empty >+} >+ >+/** >+ * webkit_user_content_set_source: >+ */ >+void webkit_user_content_set_source(WebKitUserContent* user_content, const gchar* source) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT(user_content)); >+ if (!g_strcmp0(user_content->priv->source.data(), source)) >+ return; >+ user_content->priv->source = source; >+} >+ >+/** >+ * webkit_user_content_get_source: >+ */ >+const gchar* webkit_user_content_get_source(WebKitUserContent* user_content) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_CONTENT(user_content), nullptr); >+ return user_content->priv->source.data(); >+} >+ >+/** >+ * webkit_user_content_set_injected_frames: >+ */ >+void webkit_user_content_set_injected_frames(WebKitUserContent* user_content, WebKitUserContentInjectedFrames injected_frames) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT(user_content)); >+ user_content->priv->injectedFrames = injected_frames; >+} >+ >+/** >+ * webkit_user_content_get_injected_frames: >+ */ >+WebKitUserContentInjectedFrames webkit_user_content_get_injected_frames(WebKitUserContent* user_content) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_CONTENT(user_content), WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES); >+ return user_content->priv->injectedFrames; >+} >+ >+/** >+ * webkit_user_content_set_whitelist: >+ */ >+void webkit_user_content_set_whitelist(WebKitUserContent* user_content, GList* whitelist) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT(user_content)); >+ >+ user_content->priv->whitelist.clear(); >+ for (GList *l = whitelist; l != nullptr; l = l->next) >+ user_content->priv->whitelist.append(String::fromUTF8(reinterpret_cast<const gchar*>(l->data))); >+} >+ >+/** >+ * webkit_user_content_get_whitelist: >+ */ >+GList* webkit_user_content_get_whitelist(WebKitUserContent* user_content) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_CONTENT(user_content), nullptr); >+ >+ GList* result = nullptr; >+ for (auto i = user_content->priv->whitelist.rend(); i != user_content->priv->whitelist.rbegin(); --i) >+ result = g_list_prepend(result, g_strdup(i->utf8().data())); >+ >+ return result; >+} >+ >+/** >+ * webkit_user_content_set_blacklist: >+ */ >+void webkit_user_content_set_blacklist(WebKitUserContent* user_content, GList* blacklist) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT(user_content)); >+ >+ user_content->priv->blacklist.clear(); >+ for (GList *l = blacklist; l != nullptr; l = l->next) >+ user_content->priv->blacklist.append(String::fromUTF8(reinterpret_cast<const gchar*>(l->data))); >+} >+ >+/** >+ * webkit_user_content_get_blacklist: >+ */ >+GList* webkit_user_content_get_blacklist(WebKitUserContent* user_content) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_CONTENT(user_content), nullptr); >+ >+ GList* result = nullptr; >+ for (auto i = user_content->priv->blacklist.rend(); i != user_content->priv->blacklist.rbegin(); --i) >+ result = g_list_prepend(result, g_strdup(i->utf8().data())); >+ >+ return result; >+} >+ >+ >+struct _WebKitUserScriptPrivate { >+ _WebKitUserScriptPrivate() >+ : injectionTime(WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START) { } >+ >+ WebKitUserScriptInjectionTime injectionTime; >+}; >+ >+WEBKIT_DEFINE_TYPE(WebKitUserScript, webkit_user_script, WEBKIT_TYPE_USER_CONTENT) >+ >+ >+static void webkit_user_script_class_init(WebKitUserScriptClass*) >+{ >+ // Empty >+} >+ >+/** >+ * webkit_user_script_new: >+ * @source: (transfer none): Source code of the user script. >+ * >+ * Returns: (transfer full): A new #WebKitUserScript. >+ */ >+WebKitUserContent* webkit_user_script_new(const gchar* source) >+{ >+ WebKitUserContent* userContent = WEBKIT_USER_CONTENT(g_object_new(WEBKIT_TYPE_USER_SCRIPT, nullptr)); >+ userContent->priv->source = source; >+ return userContent; >+} >+ >+/** >+ * webkit_user_script_set_injection_time: >+ */ >+void webkit_user_script_set_injection_time(WebKitUserScript* userScript, WebKitUserScriptInjectionTime injectionTime) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_SCRIPT(userScript)); >+ userScript->priv->injectionTime = injectionTime; >+} >+ >+/** >+ * webkit_user_script_get_injection_time: >+ */ >+WebKitUserScriptInjectionTime webkit_user_script_get_injection_time(WebKitUserScript* userScript) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_SCRIPT(userScript), WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END); >+ return userScript->priv->injectionTime; >+} >+ >+UserScript webkitWebKitUserScriptToUserScript(WebKitUserScript* script, guint64 scriptId) >+{ >+ g_assert(WEBKIT_IS_USER_SCRIPT(script)); >+ >+ StringBuilder urlStringBuilder; >+ urlStringBuilder.append("user-script:"); >+ urlStringBuilder.appendNumber(scriptId); >+ >+ return UserScript { >+ String::fromUTF8(script->parent.priv->source.data(), script->parent.priv->source.length()), >+ URL { URL { }, urlStringBuilder.toString() }, >+ script->parent.priv->whitelist, >+ script->parent.priv->blacklist, >+ toUserScriptInjectionTime(script->priv->injectionTime), >+ toUserContentInjectedFrames(script->parent.priv->injectedFrames) >+ }; >+} >+ >+ >+struct _WebKitUserStyleSheetPrivate { >+ _WebKitUserStyleSheetPrivate() >+ : level(WEBKIT_USER_STYLE_LEVEL_USER) { } >+ >+ WebKitUserStyleLevel level; >+}; >+ >+WEBKIT_DEFINE_TYPE(WebKitUserStyleSheet, webkit_user_style_sheet, WEBKIT_TYPE_USER_CONTENT) >+ >+ >+static void webkit_user_style_sheet_class_init(WebKitUserStyleSheetClass*) >+{ >+ // Empty >+} >+ >+/** >+ * webkit_user_style_sheet_new: >+ * @source: (transfer none): Source code of the user style sheet. >+ * >+ * Returns: (transfer full): A new #WebKitUserStyleSheet object. >+ */ >+WebKitUserContent* webkit_user_style_sheet_new(const gchar* source) >+{ >+ WebKitUserContent* userContent = WEBKIT_USER_CONTENT(g_object_new(WEBKIT_TYPE_USER_STYLE_SHEET, nullptr)); >+ userContent->priv->source = g_strdup(source); >+ return userContent; >+} >+ >+/** >+ * webkit_user_style_sheet_set_level: >+ */ >+void webkit_user_style_sheet_set_level(WebKitUserStyleSheet* userStyleSheet, WebKitUserStyleLevel level) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_STYLE_SHEET(userStyleSheet)); >+ userStyleSheet->priv->level = level; >+} >+ >+/** >+ * webkit_user_style_sheet_get_level: >+ */ >+WebKitUserStyleLevel webkit_user_style_sheet_get_level(WebKitUserStyleSheet* userStyleSheet) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_STYLE_SHEET(userStyleSheet), WEBKIT_USER_STYLE_LEVEL_USER); >+ return userStyleSheet->priv->level; >+} >+ >+UserStyleSheet webkitWebKitUserStyleSheetToUserStyleSheet(WebKitUserStyleSheet* styleSheet, guint64 styleSheetId) >+{ >+ g_assert(WEBKIT_IS_USER_STYLE_SHEET(styleSheet)); >+ >+ StringBuilder urlStringBuilder; >+ urlStringBuilder.append("user-style-sheet:"); >+ urlStringBuilder.appendNumber(styleSheetId); >+ >+ return UserStyleSheet { >+ String::fromUTF8(styleSheet->parent.priv->source.data(), styleSheet->parent.priv->source.length()), >+ URL { URL { }, urlStringBuilder.toString() }, >+ styleSheet->parent.priv->whitelist, >+ styleSheet->parent.priv->blacklist, >+ toUserContentInjectedFrames(styleSheet->parent.priv->injectedFrames), >+ toUserStyleLevel(styleSheet->priv->level) >+ }; >+} >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.h b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..03a06ed5cc41186f767f5a22e76458d41093ff97 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContent.h >@@ -0,0 +1,209 @@ >+/* >+ * Copyright (C) 2014 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) >+#error "Only <webkit2/webkit2.h> can be included directly." >+#endif >+ >+#ifndef WebKitUserContent_h >+#define WebKitUserContent_h >+ >+#include <glib-object.h> >+#include <webkit2/WebKitDefines.h> >+ >+G_BEGIN_DECLS >+ >+/** >+ * WebKitUserContentInjectedFrames: Specifies in which frames user >+ * scripts and user style sheets are to be inserted in. >+ * >+ * @WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES: Insert the user content >+ * (a script or style sheet) in all the frames loaded by the web >+ * view, including nested frames. This is the default. >+ * @WEBKIT_USER_CONTENT_INJECT_TOP_FRAME: Insert the user content >+ * (a script or style sheet) *only* in the top-level frame loaded >+ * by the web view, and *not* in the nested frames. >+ */ >+typedef enum { >+ WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, >+ WEBKIT_USER_CONTENT_INJECT_TOP_FRAME, >+} WebKitUserContentInjectedFrames; >+ >+#define WEBKIT_TYPE_USER_CONTENT (webkit_user_content_get_type()) >+#define WEBKIT_USER_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_USER_CONTENT, WebKitUserContent)) >+#define WEBKIT_IS_USER_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_USER_CONTENT)) >+#define WEBKIT_USER_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_USER_CONTENT, WebKitUserContentClass)) >+#define WEBKIT_IS_USER_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_USER_CONTENT)) >+#define WEBKIT_USER_CONTENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_USER_CONTENT, WebKitUserContentClass)) >+ >+typedef struct _WebKitUserContent WebKitUserContent; >+typedef struct _WebKitUserContentClass WebKitUserContentClass; >+typedef struct _WebKitUserContentPrivate WebKitUserContentPrivate; >+ >+ >+struct _WebKitUserContent { >+ GObject parent; >+ >+ /*< private >*/ >+ WebKitUserContentPrivate *priv; >+}; >+ >+struct _WebKitUserContentClass { >+ GObjectClass parent_class; >+}; >+ >+ >+WEBKIT_API GType >+webkit_user_content_get_type (void); >+ >+WEBKIT_API void >+webkit_user_content_set_source (WebKitUserContent *user_content, >+ const gchar *source); >+ >+WEBKIT_API const gchar * >+webkit_user_content_get_source (WebKitUserContent *user_content); >+ >+WEBKIT_API void >+webkit_user_content_set_injected_frames (WebKitUserContent *user_content, >+ WebKitUserContentInjectedFrames injected_frames); >+ >+WEBKIT_API WebKitUserContentInjectedFrames >+webkit_user_content_get_injected_frames (WebKitUserContent *user_content); >+ >+WEBKIT_API void >+webkit_user_content_set_whitelist (WebKitUserContent *user_content, >+ GList *whitelist); >+ >+WEBKIT_API GList * >+webkit_user_content_get_whitelist (WebKitUserContent *user_content); >+ >+WEBKIT_API void >+webkit_user_content_set_blacklist (WebKitUserContent *user_content, >+ GList *blacklist); >+ >+WEBKIT_API GList * >+webkit_user_content_get_blacklist (WebKitUserContent *user_content); >+ >+ >+/** >+ * WebKitUserScriptInjectionTime: Specifies at which place user scripts >+ * are inserted. >+ * >+ * @WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START: Insert the code of the user >+ * script at the beginning of the loaded documents. This is the default. >+ * @WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END: Insert the code of the user >+ * script at the end of the loaded documents. >+ */ >+typedef enum { >+ WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START, >+ WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, >+} WebKitUserScriptInjectionTime; >+ >+#define WEBKIT_TYPE_USER_SCRIPT (webkit_user_content_get_type()) >+#define WEBKIT_USER_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_USER_SCRIPT, WebKitUserScript)) >+#define WEBKIT_IS_USER_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_USER_SCRIPT)) >+#define WEBKIT_USER_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_USER_SCRIPT, WebKitUserScriptClass)) >+#define WEBKIT_IS_USER_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_USER_SCRIPT)) >+#define WEBKIT_USER_SCRIPT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_USER_SCRIPT, WebKitUserScriptClass)) >+ >+typedef struct _WebKitUserScript WebKitUserScript; >+typedef struct _WebKitUserScriptClass WebKitUserScriptClass; >+typedef struct _WebKitUserScriptPrivate WebKitUserScriptPrivate; >+ >+ >+struct _WebKitUserScript { >+ WebKitUserContent parent; >+ >+ /*< private >*/ >+ WebKitUserScriptPrivate *priv; >+}; >+ >+struct _WebKitUserScriptClass { >+ WebKitUserContentClass parent_class; >+}; >+ >+ >+WEBKIT_API GType >+webkit_user_script_get_type (void); >+ >+WEBKIT_API WebKitUserContent * >+webkit_user_script_new (const gchar *source); >+ >+WEBKIT_API void >+webkit_user_script_set_injection_time (WebKitUserScript *user_script, >+ WebKitUserScriptInjectionTime injection_time); >+ >+WEBKIT_API WebKitUserScriptInjectionTime >+webkit_user_script_get_injection_time (WebKitUserScript *user_script); >+ >+ >+/** >+ * WebKitUserStyleLevel: Specifies how to treat an user style sheet. >+ * >+ * @WEBKIT_USER_STYLE_LEVEL_USER: The style sheet is an user style sheet, >+ * its contents always override other style sheets. This is the default. >+ * @WEBKIT_USER_STYLE_LEVEL_AUTHOR: The style sheet will be treated as if >+ * it was provided by the loaded documents. That means other user style >+ * sheets may still override it. >+ */ >+typedef enum { >+ WEBKIT_USER_STYLE_LEVEL_USER, >+ WEBKIT_USER_STYLE_LEVEL_AUTHOR, >+} WebKitUserStyleLevel; >+ >+#define WEBKIT_TYPE_USER_STYLE_SHEET (webkit_user_content_get_type()) >+#define WEBKIT_USER_STYLE_SHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_USER_STYLE_SHEET, WebKitUserStyleSheet)) >+#define WEBKIT_IS_USER_STYLE_SHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_USER_STYLE_SHEET)) >+#define WEBKIT_USER_STYLE_SHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_USER_STYLE_SHEET, WebKitUserStyleSheetClass)) >+#define WEBKIT_IS_USER_STYLE_SHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_USER_STYLE_SHEET)) >+#define WEBKIT_USER_STYLE_SHEET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_USER_STYLE_SHEET, WebKitUserStyleSheetClass)) >+ >+typedef struct _WebKitUserStyleSheet WebKitUserStyleSheet; >+typedef struct _WebKitUserStyleSheetClass WebKitUserStyleSheetClass; >+typedef struct _WebKitUserStyleSheetPrivate WebKitUserStyleSheetPrivate; >+ >+ >+struct _WebKitUserStyleSheet { >+ WebKitUserContent parent; >+ >+ /*< private >*/ >+ WebKitUserStyleSheetPrivate *priv; >+}; >+ >+struct _WebKitUserStyleSheetClass { >+ WebKitUserContentClass parent_class; >+}; >+ >+ >+WEBKIT_API GType >+webkit_user_style_sheet_get_type (void); >+ >+WEBKIT_API WebKitUserContent * >+webkit_user_style_sheet_new (const gchar *source); >+ >+WEBKIT_API void >+webkit_user_style_sheet_set_level (WebKitUserStyleSheet *user_style_sheet, >+ WebKitUserStyleLevel level); >+ >+WEBKIT_API WebKitUserStyleLevel >+webkit_user_style_sheet_get_level (WebKitUserStyleSheet *user_style_sheet); >+ >+G_END_DECLS >+ >+#endif >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..4715fe5cca005fd6c038abc95246945a3c9aacc2 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.cpp >@@ -0,0 +1,229 @@ >+/* >+ * Copyright (C) 2014 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "WebKitUserContentManager.h" >+ >+#include "UserScript.h" >+#include "UserStyleSheet.h" >+#include "WebKitJavascriptResult.h" >+#include "WebKitPrivate.h" >+#include "WebKitUserContentPrivate.h" >+#include "WebScriptMessageHandler.h" >+#include "WebUserContentControllerProxy.h" >+#include <wtf/gobject/GRefPtr.h> >+ >+using namespace WebCore; >+using namespace WebKit; >+ >+ >+class ScriptMessageClientGtk : public WebScriptMessageHandler::Client { >+public: >+ ScriptMessageClientGtk(const GRefPtr<WebKitUserContentManager>& manager, >+ const String& handlerName): m_handlerName(handlerName), m_manager(manager) { } >+ >+ virtual void didPostMessage(WebPageProxy&, WebFrameProxy&, WebCore::SerializedScriptValue&) >+ { >+ // TODO: Implement >+ } >+ >+ virtual ~ScriptMessageClientGtk() { } >+ >+private: >+ String m_handlerName; >+ GRefPtr<WebKitUserContentManager> m_manager; >+}; >+ >+ >+struct _WebKitUserContentManagerPrivate { >+ _WebKitUserContentManagerPrivate() >+ : userContentController(WebUserContentControllerProxy::create()) { } >+ >+ RefPtr<WebUserContentControllerProxy> userContentController; >+ guint64 numUserStyleSheets; >+ guint64 numUserScripts; >+}; >+ >+/** >+ * SECTION:WebKitUserContentManager >+ * @short_description: TODO >+ * @title: WebKitUserContentManager >+ * >+ * Since: 2.6 >+ */ >+ >+WEBKIT_DEFINE_TYPE(WebKitUserContentManager, webkit_user_content_manager, G_TYPE_OBJECT) >+ >+ >+enum { >+ SCRIPT_MESSAGE_RECEIVED, >+ >+ LAST_SIGNAL >+}; >+ >+static guint signals[LAST_SIGNAL] = { 0, }; >+ >+ >+static void webkit_user_content_manager_class_init(WebKitUserContentManagerClass *klass) >+{ >+ GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); >+ >+ /** >+ * WebKitUserContentManager::script-message-received: >+ * @manager: the #WebKitUserContentManager >+ * @js_result: the #WebKitJavascriptResult holding the value received >+ * from the JavaScript world. >+ * >+ * This signal is emitted when JavaScript in a web view calls >+ * <code>window.webkit.<name>.postMessage()</code>, after registering >+ * <code><name></code> using >+ * webkit_user_content_manager_register_script_message_name() >+ */ >+ signals[SCRIPT_MESSAGE_RECEIVED] = >+ g_signal_new( >+ "script-message-received", >+ G_TYPE_FROM_CLASS(gObjectClass), >+ static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED), >+ 0, nullptr, nullptr, >+ g_cclosure_marshal_VOID__BOXED, >+ G_TYPE_NONE, 1, >+ WEBKIT_TYPE_JAVASCRIPT_RESULT); >+} >+ >+ >+static gpointer createDefaultUserContextManager(gpointer) >+{ >+ static GRefPtr<WebKitUserContentManager> manager = adoptGRef(WEBKIT_USER_CONTENT_MANAGER(g_object_new(WEBKIT_TYPE_USER_CONTENT_MANAGER, nullptr))); >+ return manager.get(); >+} >+ >+/** >+ * webkit_user_content_manager_get_default: >+ * >+ * Obtains the default user content manager. >+ * >+ * Returns: (transfer none): a #WebKitUserContentManager >+ */ >+WebKitUserContentManager* webkit_user_content_manager_get_default(void) >+{ >+ static GOnce onceInit = G_ONCE_INIT; >+ return WEBKIT_USER_CONTENT_MANAGER(g_once(&onceInit, createDefaultUserContextManager, nullptr)); >+} >+ >+/** >+ * webkit_user_content_manager_add_script: >+ * @manager: A #WebKitUserContentManager. >+ */ >+void >+webkit_user_content_manager_add_script(WebKitUserContentManager* manager, WebKitUserScript* script) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager)); >+ g_return_if_fail(WEBKIT_IS_USER_SCRIPT(script)); >+ manager->priv->userContentController->addUserScript( >+ webkitWebKitUserScriptToUserScript(script, manager->priv->numUserScripts++)); >+} >+ >+/** >+ * webkit_user_content_manager_remove_all_scripts: >+ * @manager: A #WebKitUserContentManager. >+ */ >+void >+webkit_user_content_manager_remove_all_scripts(WebKitUserContentManager* manager) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager)); >+ manager->priv->userContentController->removeAllUserScripts(); >+ manager->priv->numUserScripts = 0; >+} >+ >+/** >+ * webkit_user_content_manager_add_style_sheet: >+ * @manager: A #WebKitUserContentManager. >+ */ >+void >+webkit_user_content_manager_add_style_sheet(WebKitUserContentManager* manager, WebKitUserStyleSheet* stylesheet) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager)); >+ g_return_if_fail(WEBKIT_IS_USER_STYLE_SHEET(stylesheet)); >+ manager->priv->userContentController->addUserStyleSheet( >+ webkitWebKitUserStyleSheetToUserStyleSheet(stylesheet, manager->priv->numUserStyleSheets++)); >+} >+ >+/** >+ * webkit_user_content_manager_remove_all_style_sheets: >+ * @manager: A #WebKitUserContentManager. >+ */ >+void >+webkit_user_content_manager_remove_all_style_sheets(WebKitUserContentManager* manager) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager)); >+ manager->priv->userContentController->removeAllUserStyleSheets(); >+ manager->priv->numUserStyleSheets = 0; >+} >+ >+ >+/** >+ * webkit_user_content_manager_register_script_message_handler_name: >+ * @manager: A #WebKitUserContentManager. >+ * @name: (transfer none): Name of the script message channel. >+ * >+ * Registers a new user script message handler name. After it is >+ * registered, scripts can use `window.webkit.<name>.postMessage(value)` >+ * to send messages. Those messages are received by connecting handlers >+ * to the WebKitUserContentManager::script-message-received signal. The >+ * handler name is used as the detail of the signal. To avoid race >+ * conditions between registering the handler name, and starting to >+ * receive the signals, it is recommended to connect to the signal >+ * *before* registering the handler name: >+ * >+ * <informalexample><programlisting> >+ * WebKitWebView *view = webkit_web_view_new (); >+ * WebKitUserContentManager *manager = webkit_web_view_get_user_content_manager (); >+ * g_signal_connect (manager, "script-message-received::foobar", >+ * G_CALLBACK (handle_script_message), NULL); >+ * webkit_user_content_manager_register_script_message_handler (manager, "foobar"); >+ * </programlisting></informalexample> >+ * >+ * Returns: Whether the message channel was registered successfully. >+ */ >+gboolean webkit_user_content_manager_register_script_message_handler_name(WebKitUserContentManager* manager, const gchar* name) >+{ >+ g_return_val_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager), FALSE); >+ >+ const auto handler_name = String::fromUTF8(name); >+ auto handler = WebScriptMessageHandler::create(std::make_unique<ScriptMessageClientGtk>(manager, handler_name), handler_name); >+ return manager->priv->userContentController->addUserScriptMessageHandler(handler.get()); >+} >+ >+/** >+ * webkit_user_content_manager_unregister_script_message_handler_name: >+ * @manager: A #WebKitUserContentManager. >+ * @name: (transfer none): Name of the script message channel. >+ * >+ * Unregisters a previously registered message handler name. >+ * >+ * Note that this does *not* disconnect handlers for the >+ * WebKitUserContentManager::script-message-received signal. >+ * >+ * See: webkit_user_content_manager_register_script_message_handler_name >+ */ >+void webkit_user_content_manager_unregister_script_message_handler_name(WebKitUserContentManager* manager, const gchar* name) >+{ >+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager)); >+ manager->priv->userContentController->removeUserMessageHandlerForName(String::fromUTF8(name)); >+} >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.h b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.h >new file mode 100644 >index 0000000000000000000000000000000000000000..171bc3c6f2391cd6032861cbc75a0ccac465af86 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentManager.h >@@ -0,0 +1,94 @@ >+/* >+ * Copyright (C) 2014 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) >+#error "Only <webkit2/webkit2.h> can be included directly." >+#endif >+ >+#ifndef WebKitUserContentManager_h >+#define WebKitUserContentManager_h >+ >+#include <glib-object.h> >+#include <webkit2/WebKitDefines.h> >+#include <webkit2/WebKitUserContent.h> >+ >+G_BEGIN_DECLS >+ >+#define WEBKIT_TYPE_USER_CONTENT_MANAGER (webkit_user_content_manager_get_type()) >+#define WEBKIT_USER_CONTENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_USER_CONTENT_MANAGER, WebKitUserContentManager)) >+#define WEBKIT_IS_USER_CONTENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_USER_CONTENT_MANAGER)) >+#define WEBKIT_USER_CONTENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_USER_CONTENT_MANAGER, WebKitUserContentManagerClass)) >+#define WEBKIT_IS_USER_CONTENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_USER_CONTENT_MANAGER)) >+#define WEBKIT_USER_CONTENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_USER_CONTENT_MANAGER, WebKitUserContentManagerClass)) >+ >+typedef struct _WebKitUserContentManager WebKitUserContentManager; >+typedef struct _WebKitUserContentManagerClass WebKitUserContentManagerClass; >+typedef struct _WebKitUserContentManagerPrivate WebKitUserContentManagerPrivate; >+ >+ >+struct _WebKitUserContentManager { >+ GObject parent; >+ >+ /*< private >*/ >+ WebKitUserContentManagerPrivate *priv; >+}; >+ >+struct _WebKitUserContentManagerClass { >+ GObjectClass parent_class; >+ >+ void (*_webkit_reserved0) (void); >+ void (*_webkit_reserved1) (void); >+ void (*_webkit_reserved2) (void); >+ void (*_webkit_reserved3) (void); >+ void (*_webkit_reserved4) (void); >+ void (*_webkit_reserved5) (void); >+ void (*_webkit_reserved6) (void); >+ void (*_webkit_reserved7) (void); >+}; >+ >+ >+WEBKIT_API GType >+webkit_user_content_manager_get_type (void); >+ >+WEBKIT_API WebKitUserContentManager * >+webkit_user_content_manager_get_default (void); >+ >+WEBKIT_API void >+webkit_user_content_manager_add_script (WebKitUserContentManager *manager, >+ WebKitUserScript *script); >+WEBKIT_API void >+webkit_user_content_manager_remove_all_scripts (WebKitUserContentManager *manager); >+ >+WEBKIT_API void >+webkit_user_content_manager_add_style_sheet (WebKitUserContentManager *manager, >+ WebKitUserStyleSheet *stylesheet); >+WEBKIT_API void >+webkit_user_content_manager_remove_all_style_sheets (WebKitUserContentManager *manager); >+ >+WEBKIT_API gboolean >+webkit_user_content_manager_register_script_message_handler_name (WebKitUserContentManager *manager, >+ const gchar *name); >+ >+WEBKIT_API void >+webkit_user_content_manager_unregister_script_message_handler_name (WebKitUserContentManager *manager, >+ const gchar *name); >+ >+G_END_DECLS >+ >+#endif >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentPrivate.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3d6912e65746c239ead09335099b4d5515db3668 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUserContentPrivate.h >@@ -0,0 +1,33 @@ >+/* >+ * Copyright (C) 2014 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#ifndef WebKitUserContentPrivate_h >+#define WebKitUserContentPrivate_h >+ >+#include "WebKitUserContent.h" >+ >+namespace WebCore { >+class UserScript; >+class UserStyleSheet; >+}; >+ >+WebCore::UserScript webkitWebKitUserScriptToUserScript(WebKitUserScript*, guint64); >+WebCore::UserStyleSheet webkitWebKitUserStyleSheetToUserStyleSheet(WebKitUserStyleSheet*, guint64); >+ >+#endif // WebKitUserContentPrivate_h >diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >index 47b864e4091581d71c63643cbe07102c0adbe2a4..652a17a48736c5bfa2d7ee58b57d3b3d9d419d31 100644 >--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >@@ -73,6 +73,89 @@ webkit_web_context_get_type > </SECTION> > > <SECTION> >+<FILE>WebKitUserContent</FILE> >+<TITLE>WebKitUserContent</TITLE> >+WebKitUserContent >+WebKitUserScript >+WebKitUserStyleSheet >+WebKitUserContentInjectedFrames >+WebKitUserScriptInjectionTime >+WebKitUserStyleLevel >+webkit_user_content_get_injected_frames >+webkit_user_content_set_injected_frames >+webkit_user_content_get_source >+webkit_user_content_set_source >+webkit_user_content_get_blacklist >+webkit_user_content_set_blacklist >+webkit_user_content_get_whitelist >+webkit_user_content_set_whitelist >+webkit_user_script_new >+webkit_user_script_get_injection_time >+webkit_user_script_set_injection_time >+webkit_user_style_sheet_new >+webkit_user_style_sheet_get_level >+webkit_user_style_sheet_set_level >+ >+<SUBSECTION Standard> >+WebKitUserContentClass >+WEBKIT_USER_CONTENT >+WEBKIT_IS_USER_CONTENT >+WEBKIT_TYPE_USER_CONTENT >+WEBKIT_USER_CONTENT_CLASS >+WEBKIT_IS_USER_CONTENT_CLASS >+WEBKIT_USER_CONTENT_GET_CLASS >+WebKitUserScriptClass >+WEBKIT_USER_SCRIPT >+WEBKIT_IS_USER_SCRIPT >+WEBKIT_TYPE_USER_SCRIPT >+WEBKIT_USER_SCRIPT_CLASS >+WEBKIT_IS_USER_SCRIPT_CLASS >+WEBKIT_USER_SCRIPT_GET_CLASS >+WebKitUserStyleSheetClass >+WEBKIT_USER_STYLE_SHEET >+WEBKIT_IS_USER_STYLE_SHEET >+WEBKIT_TYPE_USER_STYLE_SHEET >+WEBKIT_USER_STYLE_SHEET_CLASS >+WEBKIT_IS_USER_STYLE_SHEET_CLASS >+WEBKIT_USER_STYLE_SHEET_GET_CLASS >+ >+<SUBSECTION Private> >+WebKitUserContentPrivate >+WebKitUserScriptPrivate >+WebKitUserStyleSheetPrivate >+webkit_user_content_get_type >+webkit_user_script_get_type >+webkit_user_style_sheet_get_type >+</SECTION> >+ >+<SECTION> >+<FILE>WebKitUserContentManager</FILE> >+<TITLE>WebKitUserContentManager</TITLE> >+WebKitUserContentManager >+webkit_user_content_manager_get_default >+webkit_user_content_manager_add_script >+webkit_user_content_manager_remove_all_scripts >+webkit_user_content_manager_add_style_sheet >+webkit_user_content_manager_remove_all_style_sheets >+webkit_user_content_manager_register_script_message_handler_name >+webkit_user_content_manager_unregister_script_message_handler_name >+ >+<SUBSECTION Standard> >+WEBKIT_IS_USER_CONTENT_MANAGER >+WEBKIT_IS_USER_CONTENT_MANAGER_CLASS >+WEBKIT_TYPE_USER_CONTENT_MANAGER >+WEBKIT_USER_CONTENT_MANAGER >+WEBKIT_USER_CONTENT_MANAGER_CLASS >+WEBKIT_USER_CONTENT_MANAGER_GET_CLASS >+WebKitUserContentManagerClass >+ >+<SUBSECTION Private> >+WebKitUserContentManagerPrivate >+webkit_user_content_manager_get_type >+ >+</SECTION> >+ >+<SECTION> > <FILE>WebKitWebView</FILE> > <TITLE>WebKitWebView</TITLE> > WebKitWebView >diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h >index c18538a63111040e46bb282f0680bd3bc2f564e8..23d0bb87a08cd4b6991a360ccf42c3722ae37e04 100644 >--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h >+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h >@@ -60,6 +60,8 @@ > #include <webkit2/WebKitURIRequest.h> > #include <webkit2/WebKitURIResponse.h> > #include <webkit2/WebKitURISchemeRequest.h> >+#include <webkit2/WebKitUserContent.h> >+#include <webkit2/WebKitUserContentManager.h> > #include <webkit2/WebKitVersion.h> > #include <webkit2/WebKitWebContext.h> > #include <webkit2/WebKitWebInspector.h> >diff --git a/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp b/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp >index f0dd6c792403c89ac881988b3b29d3c5630be5c5..7105fa471393f13451c6a97aa0bc4f8fdd55591d 100644 >--- a/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp >+++ b/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp >@@ -97,6 +97,22 @@ void WebUserContentControllerProxy::removeAllUserScripts() > processAndCount.key->connection()->send(Messages::WebUserContentController::RemoveAllUserScripts(), m_identifier); > } > >+void WebUserContentControllerProxy::addUserStyleSheet(WebCore::UserStyleSheet userStyleSheet) >+{ >+ m_userStyleSheets.append(std::move(userStyleSheet)); >+ >+ for (auto& processAndCount : m_processes) >+ processAndCount.key->connection()->send(Messages::WebUserContentController::AddUserStyleSheets({ m_userStyleSheets.last() }), m_identifier); >+} >+ >+void WebUserContentControllerProxy::removeAllUserStyleSheets() >+{ >+ m_userStyleSheets.clear(); >+ >+ for (auto& processAndCount : m_processes) >+ processAndCount.key->connection()->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(), m_identifier); >+} >+ > bool WebUserContentControllerProxy::addUserScriptMessageHandler(WebScriptMessageHandler* handler) > { > for (auto& existingHandler : m_scriptMessageHandlers.values()) { >diff --git a/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h b/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h >index cff6f29d4864e0a76849ffaf2ea0449d74db0849..7dc0595aa2b7c2de82bfc08334a173c6b941daae 100644 >--- a/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h >+++ b/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h >@@ -39,6 +39,7 @@ class DataReference; > > namespace WebCore { > class UserScript; >+class UserStyleSheet; > } > > namespace WebKit { >@@ -59,6 +60,9 @@ public: > void addUserScript(WebCore::UserScript); > void removeAllUserScripts(); > >+ void addUserStyleSheet(WebCore::UserStyleSheet); >+ void removeAllUserStyleSheets(); >+ > // Returns false if there was a name conflict. > bool addUserScriptMessageHandler(WebScriptMessageHandler*); > void removeUserMessageHandlerForName(const String&); >@@ -75,6 +79,7 @@ private: > HashCountedSet<WebProcessProxy*> m_processes; > > Vector<WebCore::UserScript> m_userScripts; >+ Vector<WebCore::UserStyleSheet> m_userStyleSheets; > HashMap<uint64_t, RefPtr<WebScriptMessageHandler>> m_scriptMessageHandlers; > }; > >diff --git a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp >index d9dc15c58455b908927546f066d8295d1353f692..24f214815a43cdb110ef50a470925b5d445bc9fc 100644 >--- a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp >+++ b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp >@@ -35,6 +35,7 @@ > #include <WebCore/DOMWrapperWorld.h> > #include <WebCore/ScriptController.h> > #include <WebCore/SerializedScriptValue.h> >+#include <WebCore/UserStyleSheet.h> > #include <wtf/NeverDestroyed.h> > > #if ENABLE(USER_MESSAGE_HANDLERS) >@@ -92,6 +93,19 @@ void WebUserContentController::removeAllUserScripts() > m_userContentController->removeUserScripts(mainThreadNormalWorld()); > } > >+void WebUserContentController::addUserStyleSheets(const Vector<WebCore::UserStyleSheet>& userStyleSheets) >+{ >+ for (const auto& userStyleSheet : userStyleSheets) { >+ m_userContentController->addUserStyleSheet(mainThreadNormalWorld(), >+ std::make_unique<WebCore::UserStyleSheet>(userStyleSheet), InjectInExistingDocuments); >+ } >+} >+ >+void WebUserContentController::removeAllUserStyleSheets() >+{ >+ m_userContentController->removeUserStyleSheets(mainThreadNormalWorld()); >+} >+ > #if ENABLE(USER_MESSAGE_HANDLERS) > class WebUserMessageHandlerDescriptorProxy : public RefCounted<WebUserMessageHandlerDescriptorProxy>, public WebCore::UserMessageHandlerDescriptor::Client { > public: >diff --git a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h >index 4c8469964cffd0f69a9c67eafadfd05efa556997..639c20e000aed798c2b73cd1f04cfb6c2b5d64f6 100644 >--- a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h >+++ b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h >@@ -54,6 +54,9 @@ private: > void addUserScripts(const Vector<WebCore::UserScript>& userScripts); > void removeAllUserScripts(); > >+ void addUserStyleSheets(const Vector<WebCore::UserStyleSheet>& userStyleSheets); >+ void removeAllUserStyleSheets(); >+ > void addUserScriptMessageHandlers(const Vector<WebScriptMessageHandlerHandle>& scriptMessageHandlers); > void removeUserScriptMessageHandler(uint64_t); > >diff --git a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in >index d0cfc1f766781fc0d737516cb2ab52bc95653974..a93fa47c068487f5cad6e5ae2f5ee16efbb5014b 100644 >--- a/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in >+++ b/Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in >@@ -27,6 +27,9 @@ messages -> WebUserContentController { > AddUserScripts(Vector<WebCore::UserScript> userScripts); > RemoveAllUserScripts() > >+ AddUserStyleSheets(Vector<WebCore::UserStyleSheet> userStyleShhets); >+ RemoveAllUserStyleSheets() >+ > AddUserScriptMessageHandlers(Vector<WebKit::WebScriptMessageHandlerHandle> scriptMessageHandlers); > RemoveUserScriptMessageHandler(uint64_t identifier) > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 133730
:
232952
|
233651
|
234981
|
234982
|
234986
|
240219
|
240479
|
240561
|
240666