⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176544 in webkit


Ignore:
Timestamp:
Nov 25, 2014, 11:50:45 AM (12 years ago)
Author:
andersca@apple.com
Message:

Remove user content handling from PageGroup
https://bugs.webkit.org/show_bug.cgi?id=139051

Reviewed by Antti Koivisto.

Source/WebCore:

Remove m_userContentController from PageGroup and the related functions and symbol exports.

  • WebCore.exp.in:
  • page/PageGroup.cpp:

(WebCore::PageGroup::PageGroup):
(WebCore::PageGroup::~PageGroup):
(WebCore::PageGroup::addPage):
(WebCore::PageGroup::removePage):
(WebCore::PageGroup::addUserScriptToWorld): Deleted.
(WebCore::PageGroup::addUserStyleSheetToWorld): Deleted.
(WebCore::PageGroup::removeUserScriptFromWorld): Deleted.
(WebCore::PageGroup::removeUserStyleSheetFromWorld): Deleted.
(WebCore::PageGroup::removeUserScriptsFromWorld): Deleted.
(WebCore::PageGroup::removeUserStyleSheetsFromWorld): Deleted.
(WebCore::PageGroup::removeAllUserContent): Deleted.

  • page/PageGroup.h:

Source/WebKit/mac:

Use the user content controller in the web view group.

  • WebView/WebView.mm:

(-[WebView _injectOutlookQuirksScript]):

Source/WebKit2:

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::addUserScript):
(WebKit::InjectedBundle::addUserStyleSheet):
(WebKit::InjectedBundle::removeUserScript):
(WebKit::InjectedBundle::removeUserStyleSheet):
(WebKit::InjectedBundle::removeUserScripts):
(WebKit::InjectedBundle::removeUserStyleSheets):
(WebKit::InjectedBundle::removeAllUserContent):
Talk to the user content controller from the passed in WebPageGroupProxy.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage):
Create the WebPageGroupProxy before creating the page so we can get its user content controller and
pass it to the page configuration if necessary.

  • WebProcess/WebPage/WebPageGroupProxy.cpp:

(WebKit::WebPageGroupProxy::userContentController):
New function that lazily creates a user content controller. We don't want to create this eagerly since
it's not used with the modern API.

(WebKit::WebPageGroupProxy::addUserStyleSheet):
(WebKit::WebPageGroupProxy::addUserScript):
(WebKit::WebPageGroupProxy::removeAllUserStyleSheets):
(WebKit::WebPageGroupProxy::removeAllUserScripts):
(WebKit::WebPageGroupProxy::removeAllUserContent):
Call through to the user content controller.

  • WebProcess/WebPage/WebPageGroupProxy.h:

Add an m_userContentController member.

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176542 r176544  
     12014-11-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove user content handling from PageGroup
     4        https://bugs.webkit.org/show_bug.cgi?id=139051
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Remove m_userContentController from PageGroup and the related functions and symbol exports.
     9
     10        * WebCore.exp.in:
     11        * page/PageGroup.cpp:
     12        (WebCore::PageGroup::PageGroup):
     13        (WebCore::PageGroup::~PageGroup):
     14        (WebCore::PageGroup::addPage):
     15        (WebCore::PageGroup::removePage):
     16        (WebCore::PageGroup::addUserScriptToWorld): Deleted.
     17        (WebCore::PageGroup::addUserStyleSheetToWorld): Deleted.
     18        (WebCore::PageGroup::removeUserScriptFromWorld): Deleted.
     19        (WebCore::PageGroup::removeUserStyleSheetFromWorld): Deleted.
     20        (WebCore::PageGroup::removeUserScriptsFromWorld): Deleted.
     21        (WebCore::PageGroup::removeUserStyleSheetsFromWorld): Deleted.
     22        (WebCore::PageGroup::removeAllUserContent): Deleted.
     23        * page/PageGroup.h:
     24
    1252014-11-25  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebCore/WebCore.exp.in

    r176542 r176544  
    15551555__ZN7WebCore9PageGroup17closeLocalStorageEv
    15561556__ZN7WebCore9PageGroup18addVisitedLinkHashEy
    1557 __ZN7WebCore9PageGroup20addUserScriptToWorldERNS_15DOMWrapperWorldERKN3WTF6StringERKNS_3URLERKNS3_6VectorIS4_Lj0ENS3_15CrashOnOverflowEEESE_NS_23UserScriptInjectionTimeENS_25UserContentInjectedFramesE
    1558 __ZN7WebCore9PageGroup20removeAllUserContentEv
    15591557__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
    1560 __ZN7WebCore9PageGroup24addUserStyleSheetToWorldERNS_15DOMWrapperWorldERKN3WTF6StringERKNS_3URLERKNS3_6VectorIS4_Lj0ENS3_15CrashOnOverflowEEESE_NS_25UserContentInjectedFramesENS_14UserStyleLevelENS_22UserStyleInjectionTimeE
    1561 __ZN7WebCore9PageGroup25removeUserScriptFromWorldERNS_15DOMWrapperWorldERKNS_3URLE
    1562 __ZN7WebCore9PageGroup26removeUserScriptsFromWorldERNS_15DOMWrapperWorldE
    15631558__ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
    1564 __ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldERNS_15DOMWrapperWorldERKNS_3URLE
    15651559__ZN7WebCore9PageGroup30closeIdleLocalStorageDatabasesEv
    1566 __ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldERNS_15DOMWrapperWorldE
    15671560__ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE
    15681561__ZN7WebCore9Scrollbar11mouseExitedEv
  • trunk/Source/WebCore/page/PageGroup.cpp

    r170774 r176544  
    4040#include "Settings.h"
    4141#include "StorageNamespace.h"
    42 #include "UserContentController.h"
    4342#include "VisitedLinkStore.h"
    4443#include <wtf/StdLibExtras.h>
     
    6867    , m_visitedLinksPopulated(false)
    6968    , m_identifier(getUniqueIdentifier())
    70     , m_userContentController(UserContentController::create())
    7169    , m_groupSettings(std::make_unique<GroupSettings>())
    7270{
     
    7674    : m_visitedLinksPopulated(false)
    7775    , m_identifier(getUniqueIdentifier())
    78     , m_userContentController(UserContentController::create())
    7976    , m_groupSettings(std::make_unique<GroupSettings>())
    8077{
     
    8481PageGroup::~PageGroup()
    8582{
    86     removeAllUserContent();
    8783}
    8884
     
    167163    ASSERT(!m_pages.contains(&page));
    168164    m_pages.add(&page);
    169 
    170     if (!page.userContentController())
    171         page.setUserContentController(m_userContentController.get());
    172165}
    173166
     
    176169    ASSERT(m_pages.contains(&page));
    177170    m_pages.remove(&page);
    178 
    179     if (page.userContentController() == m_userContentController)
    180         page.setUserContentController(nullptr);
    181171}
    182172
     
    285275
    286276    return result.iterator->value.get();
    287 }
    288 
    289 void PageGroup::addUserScriptToWorld(DOMWrapperWorld& world, const String& source, const URL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
    290 {
    291     auto userScript = std::make_unique<UserScript>(source, url, whitelist, blacklist, injectionTime, injectedFrames);
    292     m_userContentController->addUserScript(world, WTF::move(userScript));
    293 }
    294 
    295 void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld& world, const String& source, const URL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserContentInjectedFrames injectedFrames, UserStyleLevel level, UserStyleInjectionTime injectionTime)
    296 {
    297     auto userStyleSheet = std::make_unique<UserStyleSheet>(source, url, whitelist, blacklist, injectedFrames, level);
    298     m_userContentController->addUserStyleSheet(world, WTF::move(userStyleSheet), injectionTime);
    299 
    300 }
    301 
    302 void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld& world, const URL& url)
    303 {
    304     m_userContentController->removeUserScript(world, url);
    305 }
    306 
    307 void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld& world, const URL& url)
    308 {
    309     m_userContentController->removeUserStyleSheet(world, url);
    310 }
    311 
    312 void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld& world)
    313 {
    314     m_userContentController->removeUserScripts(world);
    315 }
    316 
    317 void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld& world)
    318 {
    319     m_userContentController->removeUserStyleSheets(world);
    320 }
    321 
    322 void PageGroup::removeAllUserContent()
    323 {
    324     m_userContentController->removeAllUserContent();
    325277}
    326278
  • trunk/Source/WebCore/page/PageGroup.h

    r173176 r176544  
    4444    class StorageNamespace;
    4545    class VisitedLinkStore;
    46     class UserContentController;
    4746
    4847#if ENABLE(VIDEO_TRACK)
     
    9493        StorageNamespace* transientLocalStorage(SecurityOrigin* topOrigin);
    9594
    96         WEBCORE_EXPORT void addUserScriptToWorld(DOMWrapperWorld&, const String& source, const URL&, const Vector<String>& whitelist, const Vector<String>& blacklist, UserScriptInjectionTime, UserContentInjectedFrames);
    97         WEBCORE_EXPORT void addUserStyleSheetToWorld(DOMWrapperWorld&, const String& source, const URL&, const Vector<String>& whitelist, const Vector<String>& blacklist, UserContentInjectedFrames, UserStyleLevel = UserStyleUserLevel, UserStyleInjectionTime = InjectInExistingDocuments);
    98         WEBCORE_EXPORT void removeUserStyleSheetFromWorld(DOMWrapperWorld&, const URL&);
    99         WEBCORE_EXPORT void removeUserScriptFromWorld(DOMWrapperWorld&, const URL&);
    100         WEBCORE_EXPORT void removeUserScriptsFromWorld(DOMWrapperWorld&);
    101         WEBCORE_EXPORT void removeUserStyleSheetsFromWorld(DOMWrapperWorld&);
    102         WEBCORE_EXPORT void removeAllUserContent();
    103 
    10495        GroupSettings& groupSettings() const { return *m_groupSettings; }
    10596
     
    124115        HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageNamespace>> m_transientLocalStorageMap;
    125116
    126         RefPtr<UserContentController> m_userContentController;
    127 
    128117        const std::unique_ptr<GroupSettings> m_groupSettings;
    129118
  • trunk/Source/WebKit/mac/ChangeLog

    r176542 r176544  
     12014-11-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove user content handling from PageGroup
     4        https://bugs.webkit.org/show_bug.cgi?id=139051
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Use the user content controller in the web view group.
     9
     10        * WebView/WebView.mm:
     11        (-[WebView _injectOutlookQuirksScript]):
     12
    1132014-11-25  Anders Carlsson  <andersca@apple.com>
    214
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r176542 r176544  
    781781{
    782782    static NSString *outlookQuirksScriptContents = leakOutlookQuirksUserScriptContents();
    783     core(self)->group().addUserScriptToWorld(*core([WebScriptWorld world]),
    784         outlookQuirksScriptContents, URL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInAllFrames);
     783    _private->group->userContentController().addUserScript(*core([WebScriptWorld world]), std::make_unique<UserScript>(outlookQuirksScriptContents, URL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInAllFrames));
     784
    785785}
    786786#endif
  • trunk/Source/WebKit2/ChangeLog

    r176540 r176544  
     12014-11-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove user content handling from PageGroup
     4        https://bugs.webkit.org/show_bug.cgi?id=139051
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     9        (WebKit::InjectedBundle::addUserScript):
     10        (WebKit::InjectedBundle::addUserStyleSheet):
     11        (WebKit::InjectedBundle::removeUserScript):
     12        (WebKit::InjectedBundle::removeUserStyleSheet):
     13        (WebKit::InjectedBundle::removeUserScripts):
     14        (WebKit::InjectedBundle::removeUserStyleSheets):
     15        (WebKit::InjectedBundle::removeAllUserContent):
     16        Talk to the user content controller from the passed in WebPageGroupProxy.
     17
     18        * WebProcess/WebPage/WebPage.cpp:
     19        (WebKit::WebPage::WebPage):
     20        Create the WebPageGroupProxy before creating the page so we can get its user content controller and
     21        pass it to the page configuration if necessary.
     22       
     23        * WebProcess/WebPage/WebPageGroupProxy.cpp:
     24        (WebKit::WebPageGroupProxy::userContentController):
     25        New function that lazily creates a user content controller. We don't want to create this eagerly since
     26        it's not used with the modern API.
     27
     28        (WebKit::WebPageGroupProxy::addUserStyleSheet):
     29        (WebKit::WebPageGroupProxy::addUserScript):
     30        (WebKit::WebPageGroupProxy::removeAllUserStyleSheets):
     31        (WebKit::WebPageGroupProxy::removeAllUserScripts):
     32        (WebKit::WebPageGroupProxy::removeAllUserContent):
     33        Call through to the user content controller.
     34
     35        * WebProcess/WebPage/WebPageGroupProxy.h:
     36        Add an m_userContentController member.
     37
    1382014-11-25  Ting-Wei Lan  <lantw44@gmail.com>
    239
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r173804 r176544  
    7171#include <WebCore/SessionID.h>
    7272#include <WebCore/Settings.h>
     73#include <WebCore/UserContentController.h>
    7374#include <WebCore/UserGestureIndicator.h>
    7475
     
    476477{
    477478    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    478     PageGroup::pageGroup(pageGroup->identifier())->addUserScriptToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames);
     479    auto userScript = std::make_unique<UserScript>(source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames);
     480
     481    pageGroup->userContentController().addUserScript(scriptWorld->coreWorld(), WTF::move(userScript));
    479482}
    480483
     
    482485{
    483486    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    484     PageGroup::pageGroup(pageGroup->identifier())->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames);
     487    auto userStyleSheet = std::make_unique<UserStyleSheet>(source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames, UserStyleUserLevel);
     488
     489    pageGroup->userContentController().addUserStyleSheet(scriptWorld->coreWorld(), WTF::move(userStyleSheet), InjectInExistingDocuments);
    485490}
    486491
     
    488493{
    489494    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    490     PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptFromWorld(scriptWorld->coreWorld(), URL(URL(), url));
     495    pageGroup->userContentController().removeUserScript(scriptWorld->coreWorld(), URL(URL(), url));
    491496}
    492497
     
    494499{
    495500    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    496     PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetFromWorld(scriptWorld->coreWorld(), URL(URL(), url));
     501    pageGroup->userContentController().removeUserStyleSheet(scriptWorld->coreWorld(), URL(URL(), url));
    497502}
    498503
    499504void InjectedBundle::removeUserScripts(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld)
    500505{
    501     PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptsFromWorld(scriptWorld->coreWorld());
     506    pageGroup->userContentController().removeUserScripts(scriptWorld->coreWorld());
    502507}
    503508
    504509void InjectedBundle::removeUserStyleSheets(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld)
    505510{
    506     PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetsFromWorld(scriptWorld->coreWorld());
     511    pageGroup->userContentController().removeUserStyleSheets(scriptWorld->coreWorld());
    507512}
    508513
    509514void InjectedBundle::removeAllUserContent(WebPageGroupProxy* pageGroup)
    510515{
    511     PageGroup::pageGroup(pageGroup->identifier())->removeAllUserContent();
     516    pageGroup->userContentController().removeAllUserContent();
    512517}
    513518
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r176499 r176544  
    338338    Settings::setDefaultMinDOMTimerInterval(0.004);
    339339
     340    m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData);
     341
    340342#if PLATFORM(IOS)
    341343    Settings::setShouldManageAudioSessionCategory(true);
     
    364366    pageConfiguration.diagnosticLoggingClient = new WebDiagnosticLoggingClient(*this);
    365367
    366     pageConfiguration.userContentController = m_userContentController ? &m_userContentController->userContentController() : nullptr;
     368    pageConfiguration.userContentController = m_userContentController ? &m_userContentController->userContentController() : &m_pageGroup->userContentController();
    367369    pageConfiguration.visitedLinkStore = VisitedLinkTableController::getOrCreate(parameters.visitedLinkTableID);
    368370
     
    407409    m_mayStartMediaWhenInWindow = parameters.mayStartMediaWhenInWindow;
    408410
    409     m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData);
    410411    m_page->setGroupName(m_pageGroup->identifier());
    411412    m_page->setDeviceScaleFactor(parameters.deviceScaleFactor);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp

    r150344 r176544  
    3131#include <WebCore/DOMWrapperWorld.h>
    3232#include <WebCore/PageGroup.h>
     33#include <WebCore/UserContentController.h>
    3334
    3435namespace WebKit {
     
    4445}
    4546
    46 WebPageGroupProxy::~WebPageGroupProxy()
    47 {
    48 }
    49 
    5047WebPageGroupProxy::WebPageGroupProxy(const WebPageGroupData& data)
    5148    : m_data(data)
     
    5855}
    5956
     57WebPageGroupProxy::~WebPageGroupProxy()
     58{
     59}
     60
     61WebCore::UserContentController& WebPageGroupProxy::userContentController()
     62{
     63    if (!m_userContentController)
     64        m_userContentController = WebCore::UserContentController::create();
     65
     66    return *m_userContentController;
     67}
     68
    6069void WebPageGroupProxy::addUserStyleSheet(const WebCore::UserStyleSheet& userStyleSheet)
    6170{
    62     m_pageGroup->addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), userStyleSheet.source(), userStyleSheet.url(), userStyleSheet.whitelist(), userStyleSheet.blacklist(), userStyleSheet.injectedFrames(), userStyleSheet.level());
     71    userContentController().addUserStyleSheet(WebCore::mainThreadNormalWorld(), std::make_unique<WebCore::UserStyleSheet>(userStyleSheet), WebCore::InjectInExistingDocuments);
    6372}
    6473
    6574void WebPageGroupProxy::addUserScript(const WebCore::UserScript& userScript)
    6675{
    67     m_pageGroup->addUserScriptToWorld(WebCore::mainThreadNormalWorld(), userScript.source(), userScript.url(), userScript.whitelist(), userScript.blacklist(), userScript.injectionTime(), userScript.injectedFrames());
     76    userContentController().addUserScript(WebCore::mainThreadNormalWorld(), std::make_unique<WebCore::UserScript>(userScript));
    6877}
    6978
    7079void WebPageGroupProxy::removeAllUserStyleSheets()
    7180{
    72     m_pageGroup->removeUserStyleSheetsFromWorld(WebCore::mainThreadNormalWorld());
     81    userContentController().removeUserStyleSheets(WebCore::mainThreadNormalWorld());
    7382}
    7483
    7584void WebPageGroupProxy::removeAllUserScripts()
    7685{
    77     m_pageGroup->removeUserScriptsFromWorld(WebCore::mainThreadNormalWorld());
     86    userContentController().removeUserScripts(WebCore::mainThreadNormalWorld());
    7887}
    7988
    8089void WebPageGroupProxy::removeAllUserContent()
    8190{
    82     m_pageGroup->removeAllUserContent();
     91    userContentController().removeAllUserContent();
    8392}
    8493
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h

    r161148 r176544  
    3838namespace WebCore {
    3939class PageGroup;
     40class UserContentController;
    4041}
    4142
     
    5354    WebCore::PageGroup* corePageGroup() const { return m_pageGroup; }
    5455
     56    WebCore::UserContentController& userContentController();
     57
    5558    void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&);
    56 
    57 private:
    58     WebPageGroupProxy(const WebPageGroupData&);
    5959
    6060    void addUserStyleSheet(const WebCore::UserStyleSheet&);
     
    6464    void removeAllUserContent();
    6565
     66private:
     67    WebPageGroupProxy(const WebPageGroupData&);
     68
    6669    WebPageGroupData m_data;
    6770    WebCore::PageGroup* m_pageGroup;
     71
     72    RefPtr<WebCore::UserContentController> m_userContentController;
    6873};
    6974
Note: See TracChangeset for help on using the changeset viewer.