Changeset 131275 in webkit


Ignore:
Timestamp:
Oct 14, 2012, 2:55:53 PM (13 years ago)
Author:
weinig@apple.com
Message:

Make UserScript and UserStyleSheet value objects that are copyable
https://bugs.webkit.org/show_bug.cgi?id=99275

Reviewed by Tim Horton.

Source/WebCore:

Simplify UserScript and UserStyleSheet and make them more easily usable
without sticking them in an OwnPtr.

  • WebCore.exp.in:

Update exports.

  • page/PageGroup.cpp:

(WebCore::PageGroup::addUserScriptToWorld):
(WebCore::PageGroup::addUserStyleSheetToWorld):

  • page/PageGroup.h:

(PageGroup):

  • page/UserContentURLPattern.cpp:

(WebCore::UserContentURLPattern::matchesPatterns):

  • page/UserContentURLPattern.h:

(UserContentURLPattern):
Update to not assume whitelist and blacklist are in Vector<String>*.

  • page/UserScript.h:

(UserScript):
(WebCore::UserScript::UserScript):
(WebCore::UserScript::whitelist):
(WebCore::UserScript::blacklist):

  • page/UserStyleSheet.h:

(UserStyleSheet):
(WebCore::UserStyleSheet::UserStyleSheet):
(WebCore::UserStyleSheet::whitelist):
(WebCore::UserStyleSheet::blacklist):
Switch OwnPtr<Vector<String> > to Vector<String> and remove Noncopyable restriction.

Source/WebKit/chromium:

  • src/WebViewImpl.cpp:

(WebKit::WebView::addUserScript):
(WebKit::WebView::addUserStyleSheet):
Update for new PageGroup function signatures.

Source/WebKit/efl:

  • WebCoreSupport/DumpRenderTreeSupportEfl.cpp:

(DumpRenderTreeSupportEfl::addUserScript):
(DumpRenderTreeSupportEfl::addUserStyleSheet):
Update for new PageGroup function signatures.

Source/WebKit/mac:

  • WebView/WebView.mm:

(-[WebView _injectMailQuirksScript]):
(-[WebView _injectOutlookQuirksScript]):
Update for new PageGroup function signatures.

Source/WebKit2:

  • Shared/UserContentContainer.cpp:

(WebKit::toStringVector):
(WebKit::UserContentContainer::Item::Item):
(WebKit::UserContentContainer::Item::encode):
(WebKit::UserContentContainer::Item::decode):

  • Shared/UserContentContainer.h:

(WebKit::UserContentContainer::Item::whitelist):
(WebKit::UserContentContainer::Item::blacklist):
Switch UserContentContainer::Item to store Vector<String> instead of ImmutableArray, easing
transition to new PageGroup function signatures.

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::toStringVector):

  • WebProcess/WebPage/qt/WebPageQt.cpp:

(WebKit::WebPage::setUserScripts):
Update for new PageGroup function signatures.

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131274 r131275  
     12012-10-14  Sam Weinig  <sam@webkit.org>
     2
     3        Make UserScript and UserStyleSheet value objects that are copyable
     4        https://bugs.webkit.org/show_bug.cgi?id=99275
     5
     6        Reviewed by Tim Horton.
     7
     8        Simplify UserScript and UserStyleSheet and make them more easily usable
     9        without sticking them in an OwnPtr.
     10
     11        * WebCore.exp.in:
     12        Update exports.
     13
     14        * page/PageGroup.cpp:
     15        (WebCore::PageGroup::addUserScriptToWorld):
     16        (WebCore::PageGroup::addUserStyleSheetToWorld):
     17        * page/PageGroup.h:
     18        (PageGroup):
     19        * page/UserContentURLPattern.cpp:
     20        (WebCore::UserContentURLPattern::matchesPatterns):
     21        * page/UserContentURLPattern.h:
     22        (UserContentURLPattern):
     23        Update to not assume whitelist and blacklist are in Vector<String>*.
     24
     25        * page/UserScript.h:
     26        (UserScript):
     27        (WebCore::UserScript::UserScript):
     28        (WebCore::UserScript::whitelist):
     29        (WebCore::UserScript::blacklist):
     30        * page/UserStyleSheet.h:
     31        (UserStyleSheet):
     32        (WebCore::UserStyleSheet::UserStyleSheet):
     33        (WebCore::UserStyleSheet::whitelist):
     34        (WebCore::UserStyleSheet::blacklist):
     35        Switch OwnPtr<Vector<String> > to Vector<String> and remove Noncopyable restriction.
     36
    1372012-10-14  Tim Horton  <timothy_horton@apple.com>
    238
  • trunk/Source/WebCore/WebCore.exp.in

    r131274 r131275  
    10531053__ZN7WebCore9PageGroup18addVisitedLinkHashEy
    10541054__ZN7WebCore9PageGroup18numberOfPageGroupsEv
    1055 __ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKN3WTF6StringERKNS_4KURLENS3_10PassOwnPtrINS3_6VectorIS4_Lm0EEEEESD_NS_23UserScriptInjectionTimeENS_25UserContentInjectedFramesE
     1055__ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKN3WTF6StringERKNS_4KURLERKNS3_6VectorIS4_Lm0EEESD_NS_23UserScriptInjectionTimeENS_25UserContentInjectedFramesE
    10561056__ZN7WebCore9PageGroup20removeAllUserContentEv
    10571057__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
    1058 __ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKN3WTF6StringERKNS_4KURLENS3_10PassOwnPtrINS3_6VectorIS4_Lm0EEEEESD_NS_25UserContentInjectedFramesENS_14UserStyleLevelENS_22UserStyleInjectionTimeE
     1058__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKN3WTF6StringERKNS_4KURLERKNS3_6VectorIS4_Lm0EEESD_NS_25UserContentInjectedFramesENS_14UserStyleLevelENS_22UserStyleInjectionTimeE
    10591059__ZN7WebCore9PageGroup25removeUserScriptFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
    10601060__ZN7WebCore9PageGroup26removeUserScriptsFromWorldEPNS_15DOMWrapperWorldE
  • trunk/Source/WebCore/page/PageGroup.cpp

    r130612 r131275  
    263263
    264264void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,
    265                                      PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
     265                                     const Vector<String>& whitelist, const Vector<String>& blacklist,
    266266                                     UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
    267267{
     
    278278
    279279void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,
    280                                          PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
     280                                         const Vector<String>& whitelist, const Vector<String>& blacklist,
    281281                                         UserContentInjectedFrames injectedFrames,
    282282                                         UserStyleLevel level,
  • trunk/Source/WebCore/page/PageGroup.h

    r123451 r131275  
    8484
    8585        void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
    86                                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
     86                                  const Vector<String>& whitelist, const Vector<String>& blacklist,
    8787                                  UserScriptInjectionTime, UserContentInjectedFrames);
    8888        void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
    89                                       PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
     89                                      const Vector<String>& whitelist, const Vector<String>& blacklist,
    9090                                      UserContentInjectedFrames,
    9191                                      UserStyleLevel level = UserStyleUserLevel,
  • trunk/Source/WebCore/page/UserContentURLPattern.cpp

    r127062 r131275  
    2626#include "config.h"
    2727#include "UserContentURLPattern.h"
     28
    2829#include "KURL.h"
    2930#include <wtf/StdLibExtras.h>
     
    3132namespace WebCore {
    3233
    33 bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>* whitelist, const Vector<String>* blacklist)
     34bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>& whitelist, const Vector<String>& blacklist)
    3435{
    3536    // In order for a URL to be a match it has to be present in the whitelist and not present in the blacklist.
    3637    // If there is no whitelist at all, then all URLs are assumed to be in the whitelist.
    37     bool matchesWhitelist = !whitelist || whitelist->isEmpty();
     38    bool matchesWhitelist = whitelist.isEmpty();
    3839    if (!matchesWhitelist) {
    39         for (unsigned i = 0; i < whitelist->size(); ++i) {
    40             UserContentURLPattern contentPattern(whitelist->at(i));
     40        size_t whitelistSize = whitelist.size();
     41        for (size_t i = 0; i < whitelistSize; ++i) {
     42            UserContentURLPattern contentPattern(whitelist[i]);
    4143            if (contentPattern.matches(url)) {
    4244                matchesWhitelist = true;
     
    4749
    4850    bool matchesBlacklist = false;
    49     if (blacklist) {
    50         for (unsigned i = 0; i < blacklist->size(); ++i) {
    51             UserContentURLPattern contentPattern(blacklist->at(i));
     51    if (!blacklist.isEmpty()) {
     52        size_t blacklistSize = blacklist.size();
     53        for (size_t i = 0; i < blacklistSize; ++i) {
     54            UserContentURLPattern contentPattern(blacklist[i]);
    5255            if (contentPattern.matches(url)) {
    5356                matchesBlacklist = true;
  • trunk/Source/WebCore/page/UserContentURLPattern.h

    r127757 r131275  
    5454    bool matchSubdomains() const { return m_matchSubdomains; }
    5555   
    56     static bool matchesPatterns(const KURL&, const Vector<String>* whitelist, const Vector<String>* blacklist);
     56    static bool matchesPatterns(const KURL&, const Vector<String>& whitelist, const Vector<String>& blacklist);
    5757
    5858private:
  • trunk/Source/WebCore/page/UserScript.h

    r95901 r131275  
    3030#include "UserContentTypes.h"
    3131#include "UserScriptTypes.h"
    32 #include <wtf/OwnPtr.h>
    33 #include <wtf/PassOwnPtr.h>
    3432#include <wtf/Vector.h>
    3533
     
    3735
    3836class UserScript {
    39     WTF_MAKE_NONCOPYABLE(UserScript); WTF_MAKE_FAST_ALLOCATED;
     37    WTF_MAKE_FAST_ALLOCATED;
    4038public:
    41     UserScript(const String& source, const KURL& url,
    42                PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
    43                UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
     39    UserScript(const String& source, const KURL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
    4440        : m_source(source)
    4541        , m_url(url)
     
    5349    const String& source() const { return m_source; }
    5450    const KURL& url() const { return m_url; }
    55     const Vector<String>* whitelist() const { return m_whitelist.get(); }
    56     const Vector<String>* blacklist() const { return m_blacklist.get(); }
     51    const Vector<String>& whitelist() const { return m_whitelist; }
     52    const Vector<String>& blacklist() const { return m_blacklist; }
    5753    UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
    5854    UserContentInjectedFrames injectedFrames() const { return m_injectedFrames; }
     
    6157    String m_source;
    6258    KURL m_url;
    63     OwnPtr<Vector<String> > m_whitelist;
    64     OwnPtr<Vector<String> > m_blacklist;
     59    Vector<String> m_whitelist;
     60    Vector<String> m_blacklist;
    6561    UserScriptInjectionTime m_injectionTime;
    6662    UserContentInjectedFrames m_injectedFrames;
  • trunk/Source/WebCore/page/UserStyleSheet.h

    r95901 r131275  
    3030#include "UserContentTypes.h"
    3131#include "UserStyleSheetTypes.h"
    32 #include <wtf/OwnPtr.h>
    33 #include <wtf/PassOwnPtr.h>
    3432#include <wtf/Vector.h>
    3533
     
    3735
    3836class UserStyleSheet {
    39     WTF_MAKE_NONCOPYABLE(UserStyleSheet); WTF_MAKE_FAST_ALLOCATED;
     37    WTF_MAKE_FAST_ALLOCATED;
    4038public:
    41     UserStyleSheet(const String& source, const KURL& url,
    42                    PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
    43                    UserContentInjectedFrames injectedFrames, UserStyleLevel level)
     39    UserStyleSheet(const String& source, const KURL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserContentInjectedFrames injectedFrames, UserStyleLevel level)
    4440        : m_source(source)
    4541        , m_url(url)
     
    5349    const String& source() const { return m_source; }
    5450    const KURL& url() const { return m_url; }
    55     const Vector<String>* whitelist() const { return m_whitelist.get(); }
    56     const Vector<String>* blacklist() const { return m_blacklist.get(); }
     51    const Vector<String>& whitelist() const { return m_whitelist; }
     52    const Vector<String>& blacklist() const { return m_blacklist; }
    5753    UserContentInjectedFrames injectedFrames() const { return m_injectedFrames; }
    5854    UserStyleLevel level() const { return m_level; }
     
    6157    String m_source;
    6258    KURL m_url;
    63     OwnPtr<Vector<String> > m_whitelist;
    64     OwnPtr<Vector<String> > m_blacklist;
     59    Vector<String> m_whitelist;
     60    Vector<String> m_blacklist;
    6561    UserContentInjectedFrames m_injectedFrames;
    6662    UserStyleLevel m_level;
  • trunk/Source/WebKit/chromium/ChangeLog

    r131223 r131275  
     12012-10-14  Sam Weinig  <sam@webkit.org>
     2
     3        Make UserScript and UserStyleSheet value objects that are copyable
     4        https://bugs.webkit.org/show_bug.cgi?id=99275
     5
     6        Reviewed by Tim Horton.
     7
     8        * src/WebViewImpl.cpp:
     9        (WebKit::WebView::addUserScript):
     10        (WebKit::WebView::addUserStyleSheet):
     11        Update for new PageGroup function signatures.
     12
    1132012-10-12  Adam Barth  <abarth@webkit.org>
    214
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r131131 r131275  
    35133513                            WebView::UserContentInjectIn injectIn)
    35143514{
    3515     OwnPtr<Vector<String> > patterns = adoptPtr(new Vector<String>);
     3515    Vector<String> patterns;
    35163516    for (size_t i = 0; i < patternsIn.size(); ++i)
    3517         patterns->append(patternsIn[i]);
     3517        patterns.append(patternsIn[i]);
    35183518
    35193519    PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
    35203520    RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::createUninitializedWorld());
    3521     pageGroup->addUserScriptToWorld(world.get(), sourceCode, WebURL(), patterns.release(), nullptr,
     3521    pageGroup->addUserScriptToWorld(world.get(), sourceCode, WebURL(), patterns, Vector<String>(),
    35223522                                    static_cast<UserScriptInjectionTime>(injectAt),
    35233523                                    static_cast<UserContentInjectedFrames>(injectIn));
     
    35293529                                WebView::UserStyleInjectionTime injectionTime)
    35303530{
    3531     OwnPtr<Vector<String> > patterns = adoptPtr(new Vector<String>);
     3531    Vector<String> patterns;
    35323532    for (size_t i = 0; i < patternsIn.size(); ++i)
    3533         patterns->append(patternsIn[i]);
     3533        patterns.append(patternsIn[i]);
    35343534
    35353535    PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
     
    35403540    //
    35413541    // FIXME: It would be nice to populate the URL correctly, instead of passing an empty URL.
    3542     pageGroup->addUserStyleSheetToWorld(world.get(), sourceCode, WebURL(), patterns.release(), nullptr,
     3542    pageGroup->addUserStyleSheetToWorld(world.get(), sourceCode, WebURL(), patterns, Vector<String>(),
    35433543                                        static_cast<UserContentInjectedFrames>(injectIn),
    35443544                                        UserStyleAuthorLevel,
  • trunk/Source/WebKit/efl/ChangeLog

    r131119 r131275  
     12012-10-14  Sam Weinig  <sam@webkit.org>
     2
     3        Make UserScript and UserStyleSheet value objects that are copyable
     4        https://bugs.webkit.org/show_bug.cgi?id=99275
     5
     6        Reviewed by Tim Horton.
     7
     8        * WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
     9        (DumpRenderTreeSupportEfl::addUserScript):
     10        (DumpRenderTreeSupportEfl::addUserStyleSheet):
     11        Update for new PageGroup function signatures.
     12
    1132012-10-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    214
  • trunk/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp

    r130612 r131275  
    297297
    298298    page->group().addUserScriptToWorld(WebCore::mainThreadNormalWorld(), sourceCode, WebCore::KURL(),
    299                                        nullptr, nullptr, runAtStart ? WebCore::InjectAtDocumentStart : WebCore::InjectAtDocumentEnd,
     299                                       Vector<String>(), Vector<String>(), runAtStart ? WebCore::InjectAtDocumentStart : WebCore::InjectAtDocumentEnd,
    300300                                       allFrames ? WebCore::InjectInAllFrames : WebCore::InjectInTopFrameOnly);
    301301}
     
    312312    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
    313313
    314     page->group().addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), sourceCode, WebCore::KURL(), nullptr, nullptr, allFrames ? WebCore::InjectInAllFrames : WebCore::InjectInTopFrameOnly);
     314    page->group().addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), sourceCode, WebCore::KURL(), Vector<String>(), Vector<String>(), allFrames ? WebCore::InjectInAllFrames : WebCore::InjectInTopFrameOnly);
    315315}
    316316
  • trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp

    r130159 r131275  
    209209    WebKitWebView* webView = getViewFromFrame(frame);
    210210    Page* page = core(webView);
    211     page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, KURL(), nullptr, nullptr, allFrames ? InjectInAllFrames : InjectInTopFrameOnly);
     211    page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, KURL(), Vector<String>(), Vector<String>(), allFrames ? InjectInAllFrames : InjectInTopFrameOnly);
    212212}
    213213
  • trunk/Source/WebKit/mac/ChangeLog

    r131085 r131275  
     12012-10-14  Sam Weinig  <sam@webkit.org>
     2
     3        Make UserScript and UserStyleSheet value objects that are copyable
     4        https://bugs.webkit.org/show_bug.cgi?id=99275
     5
     6        Reviewed by Tim Horton.
     7
     8        * WebView/WebView.mm:
     9        (-[WebView _injectMailQuirksScript]):
     10        (-[WebView _injectOutlookQuirksScript]):
     11        Update for new PageGroup function signatures.
     12
    1132012-10-10  Brady Eidson  <beidson@apple.com>
    214
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r131018 r131275  
    683683    static NSString *mailQuirksScriptContents = leakMailQuirksUserScriptContents();
    684684    core(self)->group().addUserScriptToWorld(core([WebScriptWorld world]),
    685         mailQuirksScriptContents, KURL(), nullptr, nullptr, InjectAtDocumentEnd, InjectInAllFrames);
     685        mailQuirksScriptContents, KURL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInAllFrames);
    686686}
    687687
     
    704704    static NSString *outlookQuirksScriptContents = leakOutlookQuirksUserScriptContents();
    705705    core(self)->group().addUserScriptToWorld(core([WebScriptWorld world]),
    706         outlookQuirksScriptContents, KURL(), nullptr, nullptr, InjectAtDocumentEnd, InjectInAllFrames);
     706        outlookQuirksScriptContents, KURL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInAllFrames);
    707707}
    708708
     
    26282628}
    26292629
    2630 static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
    2631 {
    2632     // Convert the patterns into Vectors.
     2630static Vector<String> toStringVector(NSArray* patterns)
     2631{
     2632    Vector<String> patternsVector;
     2633
    26332634    NSUInteger count = [patterns count];
    2634     if (count == 0)
    2635         return nullptr;
    2636     OwnPtr<Vector<String> > patternsVector = adoptPtr(new Vector<String>);
     2635    if (!count)
     2636        return patternsVector;
     2637
    26372638    for (NSUInteger i = 0; i < count; ++i) {
    26382639        id entry = [patterns objectAtIndex:i];
    26392640        if ([entry isKindOfClass:[NSString class]])
    2640             patternsVector->append(String((NSString*)entry));
    2641     }
    2642     return patternsVector.release();
     2641            patternsVector.append(String((NSString *)entry));
     2642    }
     2643    return patternsVector;
    26432644}
    26442645
  • trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

    r130898 r131275  
    836836void DumpRenderTreeSupportQt::addUserStyleSheet(QWebPage* page, const QString& sourceCode)
    837837{
    838     page->handle()->page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, QUrl(), nullptr, nullptr, WebCore::InjectInAllFrames);
     838    page->handle()->page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, QUrl(), Vector<String>(), Vector<String>(), WebCore::InjectInAllFrames);
    839839}
    840840
  • trunk/Source/WebKit2/ChangeLog

    r131273 r131275  
     12012-10-14  Sam Weinig  <sam@webkit.org>
     2
     3        Make UserScript and UserStyleSheet value objects that are copyable
     4        https://bugs.webkit.org/show_bug.cgi?id=99275
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/UserContentContainer.cpp:
     9        (WebKit::toStringVector):
     10        (WebKit::UserContentContainer::Item::Item):
     11        (WebKit::UserContentContainer::Item::encode):
     12        (WebKit::UserContentContainer::Item::decode):
     13        * Shared/UserContentContainer.h:
     14        (WebKit::UserContentContainer::Item::whitelist):
     15        (WebKit::UserContentContainer::Item::blacklist):
     16        Switch UserContentContainer::Item to store Vector<String> instead of ImmutableArray, easing
     17        transition to new PageGroup function signatures.
     18
     19        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     20        (WebKit::toStringVector):
     21        * WebProcess/WebPage/qt/WebPageQt.cpp:
     22        (WebKit::WebPage::setUserScripts):
     23        Update for new PageGroup function signatures.
     24
    1252012-10-14  Tim Horton  <timothy_horton@apple.com>
    226
  • trunk/Source/WebKit2/Shared/UserContentContainer.cpp

    r130948 r131275  
    3333namespace WebKit {
    3434
     35static Vector<String> toStringVector(ImmutableArray* array)
     36{
     37    Vector<String> patternVector;
     38    if (!array)
     39        return patternVector;
     40
     41    size_t size = array->size();
     42    if (!size)
     43        return patternVector;
     44   
     45    patternVector.reserveInitialCapacity(size);
     46    for (size_t i = 0; i < size; ++i) {
     47        WebString* webString = array->at<WebString>(i);
     48        ASSERT(webString);
     49        patternVector.uncheckedAppend(webString->string());
     50    }
     51   
     52    return patternVector;
     53}
     54
    3555UserContentContainer::Item::Item()
    3656{
     
    4060    : m_source(source)
    4161    , m_url(url)
    42     , m_whitelist(whitelist)
    43     , m_blacklist(blacklist)
     62    , m_whitelist(toStringVector(whitelist.get()))
     63    , m_blacklist(toStringVector(blacklist.get()))
    4464    , m_injectedFrames(injectedFrames)
    4565    , m_type(type)
     
    4868}
    4969
    50 static void encodeStringArray(CoreIPC::ArgumentEncoder* encoder, ImmutableArray* array)
    51 {
    52     ASSERT(encoder);
    53     uint32_t size = array ? array->size() : 0;
    54     encoder->encode(size);
    55     for (uint32_t i = 0; i < size; ++i) {
    56         WebString* webString = array->at<WebString>(i);
    57         ASSERT(webString);
    58         encoder->encode(webString->string());
    59     }
    60 }
    61 
    6270void UserContentContainer::Item::encode(CoreIPC::ArgumentEncoder* encoder) const
    6371{
    6472    encoder->encode(m_source->string());
    6573    encoder->encode(m_url ? m_url->string() : String());
    66     encodeStringArray(encoder, m_whitelist.get());
    67     encodeStringArray(encoder, m_blacklist.get());
     74    encoder->encode(m_whitelist);
     75    encoder->encode(m_blacklist);
    6876    encoder->encode(static_cast<uint32_t>(m_injectedFrames));
    6977    encoder->encode(static_cast<uint32_t>(m_type));
    70 }
    71 
    72 static bool decodeStringArray(CoreIPC::ArgumentDecoder* decoder, Vector<RefPtr<APIObject> >& vector)
    73 {
    74     ASSERT(decoder);
    75     ASSERT(vector.isEmpty());
    76 
    77     uint32_t size;
    78     if (!decoder->decode(size))
    79         return false;
    80 
    81     if (!size)
    82         return true;
    83 
    84     vector.reserveInitialCapacity(size);
    85     for (uint32_t i = 0; i < size; ++i) {
    86         String string;
    87         if (!decoder->decode(string))
    88             return false;
    89         vector.uncheckedAppend(WebString::create(string));
    90     }
    91 
    92     return true;
    9378}
    9479
     
    9782    ASSERT(!item.m_source);
    9883    ASSERT(!item.m_url);
    99     ASSERT(!item.m_whitelist);
    100     ASSERT(!item.m_blacklist);
     84    ASSERT(item.m_whitelist.isEmpty());
     85    ASSERT(item.m_blacklist.isEmpty());
    10186
    10287    String source;
     
    11095    item.m_url = WebURL::create(url);
    11196
    112     Vector<RefPtr<APIObject> > whitelist;
    113     if (!decodeStringArray(decoder, whitelist))
     97    if (!decoder->decode(item.m_whitelist))
    11498        return false;
    115     item.m_whitelist = ImmutableArray::adopt(whitelist);
    116 
    117     Vector<RefPtr<APIObject> > blacklist;
    118     if (!decodeStringArray(decoder, blacklist))
     99    if (!decoder->decode(item.m_blacklist))
    119100        return false;
    120     item.m_blacklist = ImmutableArray::adopt(blacklist);
    121101
    122102    uint32_t injectedFrames;
     
    131111
    132112    return true;
    133 }
    134 
    135 static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* array)
    136 {
    137     if (!array)
    138         return nullptr;
    139 
    140     size_t size = array->size();
    141     if (!size)
    142         return nullptr;
    143    
    144     OwnPtr<Vector<String> > stringVector = adoptPtr(new Vector<String>());
    145     stringVector->reserveInitialCapacity(size);
    146     for (size_t i = 0; i < size; ++i) {
    147         WebString* webString = array->at<WebString>(i);
    148         ASSERT(webString);
    149         stringVector->uncheckedAppend(webString->string());
    150     }
    151    
    152     return stringVector.release();
    153 }
    154 
    155 PassOwnPtr<Vector<String> > UserContentContainer::Item::whitelist() const
    156 {
    157     return toStringVector(m_whitelist.get());
    158 }
    159 
    160 PassOwnPtr<Vector<String> > UserContentContainer::Item::blacklist() const
    161 {
    162     return toStringVector(m_blacklist.get());
    163113}
    164114
  • trunk/Source/WebKit2/Shared/UserContentContainer.h

    r130948 r131275  
    3232#include <WebCore/KURL.h>
    3333#include <wtf/RefPtr.h>
     34#include <wtf/Vector.h>
    3435
    3536namespace CoreIPC {
     
    6263        const String& source() const { return m_source->string(); }
    6364        WebCore::KURL url() const { return !m_url || m_url->string().isEmpty() ? WebCore::blankURL() : WebCore::KURL(WebCore::KURL(), m_url->string()); }
    64         PassOwnPtr<Vector<String> > whitelist() const;
    65         PassOwnPtr<Vector<String> > blacklist() const;
     65        const Vector<String>& whitelist() const { return m_whitelist; }
     66        const Vector<String>& blacklist() const { return m_blacklist; }
    6667        InjectedFrames injectedFrames() const { return m_injectedFrames; }
    6768        Type type() const { return m_type; }
     
    7071        RefPtr<WebString> m_source;
    7172        RefPtr<WebURL> m_url;
    72         RefPtr<ImmutableArray> m_whitelist;
    73         RefPtr<ImmutableArray> m_blacklist;
     73        Vector<String> m_whitelist;
     74        Vector<String> m_blacklist;
    7475        InjectedFrames m_injectedFrames;
    7576        Type m_type;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r131151 r131275  
    427427}
    428428
    429 static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns)
    430 {
     429static Vector<String> toStringVector(ImmutableArray* patterns)
     430{
     431    Vector<String> patternsVector;
     432
    431433    if (!patterns)
    432         return nullptr;
    433 
    434     size_t size =  patterns->size();
     434        return patternsVector;
     435
     436    size_t size = patterns->size();
    435437    if (!size)
    436         return nullptr;
    437 
    438     OwnPtr<Vector<String> > patternsVector = adoptPtr(new Vector<String>);
    439     patternsVector->reserveInitialCapacity(size);
     438        return patternsVector;
     439
     440    patternsVector.reserveInitialCapacity(size);
    440441    for (size_t i = 0; i < size; ++i) {
    441442        WebString* entry = patterns->at<WebString>(i);
    442443        if (entry)
    443             patternsVector->uncheckedAppend(entry->string());
     444            patternsVector.uncheckedAppend(entry->string());
    444445    }
    445     return patternsVector.release();
     446    return patternsVector;
    446447}
    447448
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp

    r130216 r131275  
    424424    pageGroup->removeUserScriptsFromWorld(mainThreadNormalWorld());
    425425    for (unsigned i = 0; i < scripts.size(); ++i)
    426         pageGroup->addUserScriptToWorld(mainThreadNormalWorld(), scripts.at(i), KURL(), nullptr, nullptr, InjectAtDocumentEnd, InjectInTopFrameOnly);
     426        pageGroup->addUserScriptToWorld(mainThreadNormalWorld(), scripts.at(i), KURL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInTopFrameOnly);
    427427}
    428428
Note: See TracChangeset for help on using the changeset viewer.