Changeset 207168 in webkit


Ignore:
Timestamp:
Oct 11, 2016 3:01:45 PM (7 years ago)
Author:
andersca@apple.com
Message:

Clean up WebPageGroup somewhat
https://bugs.webkit.org/show_bug.cgi?id=163299

Reviewed by Tim Horton.

  • Shared/API/c/WKDeprecatedFunctions.cpp:

(WKPageGroupCopyIdentifier):
Move this here from WKPageGroup.

(WKPageGroupAddUserContentFilter):
(WKPageGroupRemoveUserContentFilter):
(WKPageGroupRemoveAllUserContentFilters):
Just call directly into the user content controller.

  • UIProcess/API/C/WKPageGroup.cpp:

(WKPageGroupAddUserStyleSheet):
(WKPageGroupRemoveAllUserStyleSheets):
(WKPageGroupAddUserScript):
(WKPageGroupRemoveAllUserScripts):
Just call directly into the user content controller.

  • UIProcess/API/C/WKPageGroup.h:
  • UIProcess/WebPageGroup.cpp:

(WebKit::WebPageGroup::addUserStyleSheet): Deleted.
(WebKit::WebPageGroup::addUserScript): Deleted.
(WebKit::WebPageGroup::removeAllUserStyleSheets): Deleted.
(WebKit::WebPageGroup::removeAllUserScripts): Deleted.
(WebKit::WebPageGroup::removeAllUserContent): Deleted.
(WebKit::WebPageGroup::addUserContentExtension): Deleted.
(WebKit::WebPageGroup::removeUserContentExtension): Deleted.
(WebKit::WebPageGroup::removeAllUserContentExtensions): Deleted.
Get rid of these, all their callers just call into the user content controller now.

  • UIProcess/WebPageGroup.h:

(WebKit::WebPageGroup::identifier): Deleted.
(WebKit::WebPageGroup::sendToAllProcessesInGroup): Deleted.
Remove unused code.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r207159 r207168  
     12016-10-11  Anders Carlsson  <andersca@apple.com>
     2
     3        Clean up WebPageGroup somewhat
     4        https://bugs.webkit.org/show_bug.cgi?id=163299
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/API/c/WKDeprecatedFunctions.cpp:
     9        (WKPageGroupCopyIdentifier):
     10        Move this here from WKPageGroup.
     11
     12        (WKPageGroupAddUserContentFilter):
     13        (WKPageGroupRemoveUserContentFilter):
     14        (WKPageGroupRemoveAllUserContentFilters):
     15        Just call directly into the user content controller.
     16
     17        * UIProcess/API/C/WKPageGroup.cpp:
     18        (WKPageGroupAddUserStyleSheet):
     19        (WKPageGroupRemoveAllUserStyleSheets):
     20        (WKPageGroupAddUserScript):
     21        (WKPageGroupRemoveAllUserScripts):
     22        Just call directly into the user content controller.
     23
     24        * UIProcess/API/C/WKPageGroup.h:
     25        * UIProcess/WebPageGroup.cpp:
     26        (WebKit::WebPageGroup::addUserStyleSheet): Deleted.
     27        (WebKit::WebPageGroup::addUserScript): Deleted.
     28        (WebKit::WebPageGroup::removeAllUserStyleSheets): Deleted.
     29        (WebKit::WebPageGroup::removeAllUserScripts): Deleted.
     30        (WebKit::WebPageGroup::removeAllUserContent): Deleted.
     31        (WebKit::WebPageGroup::addUserContentExtension): Deleted.
     32        (WebKit::WebPageGroup::removeUserContentExtension): Deleted.
     33        (WebKit::WebPageGroup::removeAllUserContentExtensions): Deleted.
     34        Get rid of these, all their callers just call into the user content controller now.
     35
     36        * UIProcess/WebPageGroup.h:
     37        (WebKit::WebPageGroup::identifier): Deleted.
     38        (WebKit::WebPageGroup::sendToAllProcessesInGroup): Deleted.
     39        Remove unused code.
     40
    1412016-10-11  Daniel Bates  <dabates@apple.com>
    242
  • trunk/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp

    r207149 r207168  
    3434#include "WKPreferencesRefPrivate.h"
    3535#include "WebPageGroup.h"
     36#include "WebUserContentControllerProxy.h"
    3637
    3738#if PLATFORM(MAC)
     
    4243
    4344extern "C" {
     45WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
    4446WK_EXPORT void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroup, WKUserContentFilterRef userContentFilter);
    4547WK_EXPORT void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroup, WKStringRef userContentFilterName);
     
    5759}
    5860
     61WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef)
     62{
     63    return nullptr;
     64}
     65
    5966void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroupRef, WKUserContentFilterRef userContentFilterRef)
    6067{
    6168#if ENABLE(CONTENT_EXTENSIONS)
    62     toImpl(pageGroupRef)->addUserContentExtension(*toImpl(userContentFilterRef));
     69    toImpl(pageGroupRef)->userContentController().addUserContentExtension(*toImpl(userContentFilterRef));
    6370#else
    6471    UNUSED_PARAM(pageGroupRef);
     
    7077{
    7178#if ENABLE(CONTENT_EXTENSIONS)
    72     toImpl(pageGroupRef)->removeUserContentExtension(toWTFString(userContentFilterNameRef));
     79    toImpl(pageGroupRef)->userContentController().removeUserContentExtension(toWTFString(userContentFilterNameRef));
    7380#else
    7481    UNUSED_PARAM(pageGroupRef);
     
    7784}
    7885
    79 
    8086void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroupRef)
    8187{
    8288#if ENABLE(CONTENT_EXTENSIONS)
    83     toImpl(pageGroupRef)->removeAllUserContentExtensions();
     89    toImpl(pageGroupRef)->userContentController().removeAllUserContentExtensions();
    8490#else
    8591    UNUSED_PARAM(pageGroupRef);
  • trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp

    r207149 r207168  
    2828
    2929#include "APIUserContentExtension.h"
     30#include "APIUserContentWorld.h"
     31#include "APIUserScript.h"
     32#include "APIUserStyleSheet.h"
    3033#include "WKAPICast.h"
    3134#include "WebPageGroup.h"
     
    4649}
    4750
    48 WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroupRef)
    49 {
    50     return toCopiedAPI(toImpl(pageGroupRef)->identifier());
    51 }
    52 
    5351void WKPageGroupSetPreferences(WKPageGroupRef pageGroupRef, WKPreferencesRef preferencesRef)
    5452{
     
    6664}
    6765
    68 void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames)
     66void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURLRef, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames)
    6967{
    70     toImpl(pageGroupRef)->addUserStyleSheet(toWTFString(sourceRef), toWTFString(baseURL), toImpl(whitelistedURLPatterns), toImpl(blacklistedURLPatterns), toUserContentInjectedFrames(injectedFrames), WebCore::UserStyleUserLevel);
     68    auto source = toWTFString(sourceRef);
     69
     70    if (source.isEmpty())
     71        return;
     72
     73    auto baseURLString = toWTFString(baseURLRef);
     74    auto whitelist = toImpl(whitelistedURLPatterns);
     75    auto blacklist = toImpl(blacklistedURLPatterns);
     76
     77    Ref<API::UserStyleSheet> userStyleSheet = API::UserStyleSheet::create(WebCore::UserStyleSheet { source, (baseURLString.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURLString)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), toUserContentInjectedFrames(injectedFrames), WebCore::UserStyleUserLevel }, API::UserContentWorld::normalWorld());
     78
     79    toImpl(pageGroupRef)->userContentController().addUserStyleSheet(userStyleSheet.get());
    7180}
    7281
    73 void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroupRef)
     82void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroup)
    7483{
    75     toImpl(pageGroupRef)->removeAllUserStyleSheets();
     84    toImpl(pageGroup)->userContentController().removeAllUserStyleSheets();
    7685}
    7786
    78 void WKPageGroupAddUserScript(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames, _WKUserScriptInjectionTime injectionTime)
     87void WKPageGroupAddUserScript(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURLRef, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames, _WKUserScriptInjectionTime injectionTime)
    7988{
    80     toImpl(pageGroupRef)->addUserScript(toWTFString(sourceRef), toWTFString(baseURL), toImpl(whitelistedURLPatterns), toImpl(blacklistedURLPatterns), toUserContentInjectedFrames(injectedFrames), toUserScriptInjectionTime(injectionTime));
     89    auto source = toWTFString(sourceRef);
     90
     91    if (source.isEmpty())
     92        return;
     93
     94    auto baseURLString = toWTFString(baseURLRef);
     95    auto whitelist = toImpl(whitelistedURLPatterns);
     96    auto blacklist = toImpl(blacklistedURLPatterns);
     97
     98    Ref<API::UserScript> userScript = API::UserScript::create(WebCore::UserScript { source, (baseURLString.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURLString)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), toUserScriptInjectionTime(injectionTime), toUserContentInjectedFrames(injectedFrames) }, API::UserContentWorld::normalWorld());
     99    toImpl(pageGroupRef)->userContentController().addUserScript(userScript.get());
    81100}
    82101
    83102void WKPageGroupRemoveAllUserScripts(WKPageGroupRef pageGroupRef)
    84103{
    85     toImpl(pageGroupRef)->removeAllUserScripts();
     104    toImpl(pageGroupRef)->userContentController().removeAllUserScripts();
    86105}
  • trunk/Source/WebKit2/UIProcess/API/C/WKPageGroup.h

    r207149 r207168  
    3939WK_EXPORT WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier);
    4040
    41 WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
    42 
    4341WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences);
    4442WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup);
  • trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp

    r197304 r207168  
    143143}
    144144
    145 void WebPageGroup::addUserStyleSheet(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserStyleLevel level)
    146 {
    147     if (source.isEmpty())
    148         return;
    149 
    150     Ref<API::UserStyleSheet> userStyleSheet = API::UserStyleSheet::create(WebCore::UserStyleSheet { source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames, level }, API::UserContentWorld::normalWorld());
    151     m_userContentController->addUserStyleSheet(userStyleSheet.get());
    152 }
    153 
    154 void WebPageGroup::addUserScript(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserScriptInjectionTime injectionTime)
    155 {
    156     if (source.isEmpty())
    157         return;
    158 
    159     Ref<API::UserScript> userScript = API::UserScript::create(WebCore::UserScript { source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames }, API::UserContentWorld::normalWorld());
    160     m_userContentController->addUserScript(userScript.get());
    161 }
    162 
    163 void WebPageGroup::removeAllUserStyleSheets()
    164 {
    165     m_userContentController->removeAllUserStyleSheets();
    166 }
    167 
    168 void WebPageGroup::removeAllUserScripts()
    169 {
    170     m_userContentController->removeAllUserScripts();
    171 }
    172 
    173 void WebPageGroup::removeAllUserContent()
    174 {
    175     m_userContentController->removeAllUserStyleSheets();
    176     m_userContentController->removeAllUserScripts();
    177 }
    178 
    179 #if ENABLE(CONTENT_EXTENSIONS)
    180 void WebPageGroup::addUserContentExtension(API::UserContentExtension& userContentExtension)
    181 {
    182     m_userContentController->addUserContentExtension(userContentExtension);
    183 }
    184 
    185 void WebPageGroup::removeUserContentExtension(const String& contentExtensionName)
    186 {
    187     m_userContentController->removeUserContentExtension(contentExtensionName);
    188 }
    189 
    190 void WebPageGroup::removeAllUserContentExtensions()
    191 {
    192     m_userContentController->removeAllUserContentExtensions();
    193 }
    194 #endif
    195 
    196145} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebPageGroup.h

    r197304 r207168  
    5454    void removePage(WebPageProxy*);
    5555
    56     const String& identifier() const { return m_data.identifier; }
    5756    uint64_t pageGroupID() const { return m_data.pageGroupID; }
    5857
     
    6564    WebUserContentControllerProxy& userContentController();
    6665
    67     void addUserStyleSheet(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames, WebCore::UserStyleLevel);
    68     void addUserScript(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames, WebCore::UserScriptInjectionTime);
    69     void removeAllUserStyleSheets();
    70     void removeAllUserScripts();
    71     void removeAllUserContent();
    72 
    73 #if ENABLE(CONTENT_EXTENSIONS)
    74     void addUserContentExtension(API::UserContentExtension&);
    75     void removeUserContentExtension(const String&);
    76     void removeAllUserContentExtensions();
    77 #endif
    78 
    7966private:
    80     template<typename T> void sendToAllProcessesInGroup(const T&, uint64_t destinationID);
    81 
    8267    WebPageGroupData m_data;
    8368    RefPtr<WebPreferences> m_preferences;
     
    8671};
    8772
    88 template<typename T>
    89 void WebPageGroup::sendToAllProcessesInGroup(const T& message, uint64_t destinationID)
    90 {
    91     HashSet<WebProcessProxy*> processesSeen;
    92 
    93     for (WebPageProxy* webPageProxy : m_pages) {
    94         WebProcessProxy& webProcessProxy = webPageProxy->process();
    95         if (!processesSeen.add(&webProcessProxy).isNewEntry)
    96             continue;
    97 
    98         if (webProcessProxy.canSendMessage())
    99             webProcessProxy.send(T(message), destinationID);
    100     }
    101 }
    102 
    10373} // namespace WebKit
    10474
Note: See TracChangeset for help on using the changeset viewer.