Changeset 108450 in webkit


Ignore:
Timestamp:
Feb 21, 2012 11:28:04 PM (12 years ago)
Author:
abarth@webkit.org
Message:

Separate the implementation of registerProtocolHandler from Navigator.cpp
https://bugs.webkit.org/show_bug.cgi?id=78945

Reviewed by Eric Seidel.

The implementation of registerProtocolHandler needlessly complicates
the implementation of Navigator.cpp. In principle,
registerProtocolHandler (and possibly registerContentHandler, when we
implement that feature) could be its own module, but that seems like
overkill for one or two files.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • page/Navigator.cpp:

(WebCore):

  • page/Navigator.h:

(Navigator):

  • page/Navigator.idl:
Location:
trunk/Source/WebCore
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r108444 r108450  
    10311031    page/Navigator.cpp
    10321032    page/NavigatorBase.cpp
     1033    page/NavigatorRegisterProtocolHandler.cpp
    10331034    page/NavigatorSupplement.cpp
    10341035    page/OriginAccessEntry.cpp
  • trunk/Source/WebCore/ChangeLog

    r108449 r108450  
     12012-02-21  Adam Barth  <abarth@webkit.org>
     2
     3        Separate the implementation of registerProtocolHandler from Navigator.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=78945
     5
     6        Reviewed by Eric Seidel.
     7
     8        The implementation of registerProtocolHandler needlessly complicates
     9        the implementation of Navigator.cpp.  In principle,
     10        registerProtocolHandler (and possibly registerContentHandler, when we
     11        implement that feature) could be its own module, but that seems like
     12        overkill for one or two files.
     13
     14        * CMakeLists.txt:
     15        * GNUmakefile.list.am:
     16        * Target.pri:
     17        * WebCore.gypi:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * page/Navigator.cpp:
     21        (WebCore):
     22        * page/Navigator.h:
     23        (Navigator):
     24        * page/Navigator.idl:
     25
    1262012-02-21  MORITA Hajime  <morrita@google.com>
    227
  • trunk/Source/WebCore/GNUmakefile.list.am

    r108438 r108450  
    27412741        Source/WebCore/page/NavigatorBase.cpp \
    27422742        Source/WebCore/page/NavigatorBase.h \
     2743        Source/WebCore/page/NavigatorRegisterProtocolHandler.cpp \
     2744        Source/WebCore/page/NavigatorRegisterProtocolHandler.h \
    27432745        Source/WebCore/page/NavigatorSupplement.cpp \
    27442746        Source/WebCore/page/NavigatorSupplement.h \
  • trunk/Source/WebCore/Target.pri

    r108438 r108450  
    10021002    page/Navigator.cpp \
    10031003    page/NavigatorBase.cpp \
     1004    page/NavigatorRegisterProtocolHandler.cpp \
    10041005    page/NavigatorSupplement.cpp \
    10051006    page/OriginAccessEntry.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r108438 r108450  
    10131013            'page/MemoryInfo.idl',
    10141014            'page/Navigator.idl',
     1015            'page/NavigatorRegisterProtocolHandler.idl',
    10151016            'page/Performance.idl',
    10161017            'page/PerformanceNavigation.idl',
     
    26432644            'page/NavigatorBase.cpp',
    26442645            'page/NavigatorBase.h',
     2646            'page/NavigatorRegisterProtocolHandler.cpp',
     2647            'page/NavigatorRegisterProtocolHandler.h',
    26452648            'page/NavigatorSupplement.cpp',
    26462649            'page/NavigatorSupplement.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r108428 r108450  
    2558725587                        </File>
    2558825588                        <File
     25589                                RelativePath="..\page\NavigatorRegisterProtocolHandler.cpp"
     25590                                >
     25591                        </File>
     25592                        <File
     25593                                RelativePath="..\page\NavigatorRegisterProtocolHandler.h"
     25594                                >
     25595                        </File>
     25596                        <File
    2558925597                                RelativePath="..\page\NavigatorSupplement.cpp"
    2559025598                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r108428 r108450  
    34603460                97E4028F13A696ED00913D67 /* IconController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97E4028D13A696ED00913D67 /* IconController.cpp */; };
    34613461                97E4029013A696ED00913D67 /* IconController.h in Headers */ = {isa = PBXBuildFile; fileRef = 97E4028E13A696ED00913D67 /* IconController.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3462                97E4A12614F4C5D400870E43 /* NavigatorRegisterProtocolHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9730BE1514EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.h */; };
     3463                97E4A12714F4C5D700870E43 /* NavigatorRegisterProtocolHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9730BE1414EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.cpp */; };
    34623464                97EF7DFE107E55B700D7C49C /* ScriptControllerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */; };
    34633465                984264F112D5280A000D88A4 /* LinkLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 984264EF12D5280A000D88A4 /* LinkLoaderClient.h */; };
     
    1020410206                9728C3111268E4390041E89B /* MarkupAccumulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkupAccumulator.cpp; sourceTree = "<group>"; };
    1020510207                9728C3121268E4390041E89B /* MarkupAccumulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkupAccumulator.h; sourceTree = "<group>"; };
     10208                9730BE1414EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorRegisterProtocolHandler.cpp; sourceTree = "<group>"; };
     10209                9730BE1514EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorRegisterProtocolHandler.h; sourceTree = "<group>"; };
     10210                9730BE1614EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorRegisterProtocolHandler.idl; sourceTree = "<group>"; };
    1020610211                9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentWriter.cpp; sourceTree = "<group>"; };
    1020710212                9738899F116EA9DC00ADF313 /* DocumentWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentWriter.h; sourceTree = "<group>"; };
     
    1528315288                                E12719C90EEEC21300F61213 /* NavigatorBase.cpp */,
    1528415289                                E12719C60EEEC16800F61213 /* NavigatorBase.h */,
     15290                                9730BE1414EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.cpp */,
     15291                                9730BE1514EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.h */,
     15292                                9730BE1614EF286B00DF06B9 /* NavigatorRegisterProtocolHandler.idl */,
    1528515293                                97CC3AE014E8E4A200894988 /* NavigatorSupplement.cpp */,
    1528615294                                97CC3AE114E8E4A200894988 /* NavigatorSupplement.h */,
     
    1921419222                        isa = PBXGroup;
    1921519223                        children = (
    19216                                 A83B533814F399BB00720D9D /* IDLAttributes.txt */,
    1921719224                                B5D31DF711CF60E5009F22B4 /* generic */,
    1921819225                                BC1A3793097C6FB10019F3D8 /* js */,
     
    1922019227                                93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */,
    1922119228                                93F8B3070A300FEA00F61AB8 /* generate-bindings.pl */,
     19229                                A83B533814F399BB00720D9D /* IDLAttributes.txt */,
    1922219230                                14813BF309EDF88E00F757E1 /* IDLParser.pm */,
    1922319231                                93F8B3080A300FEA00F61AB8 /* IDLStructure.pm */,
     
    2235922367                                41885B9311B6FDA6003383BB /* FormSubmission.h in Headers */,
    2236022368                                935C476D09AC4D6300A6AAB4 /* FoundationExtras.h in Headers */,
     22369                                144FCFE114EF2509000D17A3 /* FractionalLayoutRect.h in Headers */,
    2236122370                                144FCE5D14EC79E7000D17A3 /* FractionalLayoutSize.h in Headers */,
    2236222371                                144FCE5214EC79BC000D17A3 /* FractionalLayoutUnit.h in Headers */,
     
    2331423323                                E12719C70EEEC16800F61213 /* NavigatorBase.h in Headers */,
    2331523324                                9711460414EF009A00674FD9 /* NavigatorGeolocation.h in Headers */,
     23325                                97E4A12614F4C5D400870E43 /* NavigatorRegisterProtocolHandler.h in Headers */,
    2331623326                                97CC3AE314E8E4A200894988 /* NavigatorSupplement.h in Headers */,
    2331723327                                8A309C9F123950BE00CB9204 /* NestingLevelIncrementer.h in Headers */,
     
    2345023460                                A715E653134BBBEC00D8E713 /* ProgressShadowElement.h in Headers */,
    2345123461                                1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */,
     23462                                E4BBED0F14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h in Headers */,
    2345223463                                514C76750CE923A1007EF3CD /* ProtectionSpace.h in Headers */,
    2345323464                                51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */,
     
    2432224333                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
    2432324334                                FD537353137B651800008DCE /* ZeroPole.h in Headers */,
    24324                                 E4BBED0F14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h in Headers */,
    24325                                 144FCFE114EF2509000D17A3 /* FractionalLayoutRect.h in Headers */,
    2432624335                        );
    2432724336                        runOnlyForDeploymentPostprocessing = 0;
     
    2543525444                                656D373B0ADBA5DE00A4554D /* FormState.cpp in Sources */,
    2543625445                                41885B9411B6FDA6003383BB /* FormSubmission.cpp in Sources */,
     25446                                144FCFE014EF2509000D17A3 /* FractionalLayoutRect.cpp in Sources */,
    2543725447                                144FCE5C14EC79E7000D17A3 /* FractionalLayoutSize.cpp in Sources */,
    2543825448                                65BF022E0974816300C43196 /* Frame.cpp in Sources */,
     
    2647026480                                E12719CA0EEEC21300F61213 /* NavigatorBase.cpp in Sources */,
    2647126481                                9711460314EF009A00674FD9 /* NavigatorGeolocation.cpp in Sources */,
     26482                                97E4A12714F4C5D700870E43 /* NavigatorRegisterProtocolHandler.cpp in Sources */,
    2647226483                                97CC3AE214E8E4A200894988 /* NavigatorSupplement.cpp in Sources */,
    2647326484                                5D874F130D161D3200796C3B /* NetscapePlugInStreamLoader.cpp in Sources */,
     
    2656526576                                A715E652134BBBEC00D8E713 /* ProgressShadowElement.cpp in Sources */,
    2656626577                                1A2A68230B5BEDE70002A480 /* ProgressTracker.cpp in Sources */,
     26578                                E4BBED0E14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp in Sources */,
    2656726579                                514C76740CE923A1007EF3CD /* ProtectionSpace.cpp in Sources */,
    2656826580                                1AF8E13312565A4400230FF7 /* ProxyServer.cpp in Sources */,
     
    2719227204                                518A34C11026C831001B6896 /* WebSocket.cpp in Sources */,
    2719327205                                510D4A4E103177A20049EA54 /* WebSocketChannel.cpp in Sources */,
     27206                                4AE02ABD14E8A9D200BC3BA7 /* WebSocketDeflater.cpp in Sources */,
    2719427207                                4A957F0614E2412A0049DBFB /* WebSocketExtensionDispatcher.cpp in Sources */,
    27195                                 4AE02ABD14E8A9D200BC3BA7 /* WebSocketDeflater.cpp in Sources */,
    2719627208                                51ABAE441043AB4A008C5260 /* WebSocketHandshake.cpp in Sources */,
    2719727209                                7637C541112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp in Sources */,
     
    2727127283                                977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
    2727227284                                FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
    27273                                 E4BBED0E14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp in Sources */,
    27274                                 144FCFE014EF2509000D17A3 /* FractionalLayoutRect.cpp in Sources */,
    2727527285                        );
    2727627286                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/page/Navigator.cpp

    r108428 r108450  
    2424#include "Navigator.h"
    2525
    26 #include "Chrome.h"
    2726#include "CookieJar.h"
    2827#include "DOMMimeTypeArray.h"
    2928#include "DOMPluginArray.h"
    3029#include "Document.h"
    31 #include "ExceptionCode.h"
    3230#include "Frame.h"
    3331#include "FrameLoader.h"
    3432#include "FrameLoaderClient.h"
    3533#include "Geolocation.h"
     34#include "Page.h"
    3635#include "PointerLock.h"
    37 #include "KURL.h"
    3836#include "Language.h"
    39 #include "Page.h"
    40 #include "PageGroup.h"
    41 #include "PlatformString.h"
    4237#include "PluginData.h"
    4338#include "Settings.h"
     
    160155}
    161156
    162 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
    163 static HashSet<String>* protocolWhitelist;
    164 
    165 static void initProtocolHandlerWhitelist()
    166 {
    167     protocolWhitelist = new HashSet<String>;
    168     static const char* protocols[] = {
    169         "irc",
    170         "mailto",
    171         "mms",
    172         "news",
    173         "nntp",
    174         "sms",
    175         "smsto",
    176         "tel",
    177         "urn",
    178         "webcal",
    179     };
    180     for (size_t i = 0; i < WTF_ARRAY_LENGTH(protocols); ++i)
    181         protocolWhitelist->add(protocols[i]);
    182 }
    183 
    184 static bool verifyCustomHandlerURL(const String& baseURL, const String& url, ExceptionCode& ec)
    185 {
    186     // The specification requires that it is a SYNTAX_ERR if the "%s" token is
    187     // not present.
    188     static const char token[] = "%s";
    189     int index = url.find(token);
    190     if (-1 == index) {
    191         ec = SYNTAX_ERR;
    192         return false;
    193     }
    194 
    195     // It is also a SYNTAX_ERR if the custom handler URL, as created by removing
    196     // the "%s" token and prepending the base url, does not resolve.
    197     String newURL = url;
    198     newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1);
    199 
    200     KURL base(ParsedURLString, baseURL);
    201     KURL kurl(base, newURL);
    202 
    203     if (kurl.isEmpty() || !kurl.isValid()) {
    204         ec = SYNTAX_ERR;
    205         return false;
    206     }
    207 
    208     return true;
    209 }
    210 
    211 static bool isProtocolWhitelisted(const String& scheme)
    212 {
    213     if (!protocolWhitelist)
    214         initProtocolHandlerWhitelist();
    215     return protocolWhitelist->contains(scheme);
    216 }
    217 
    218 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec)
    219 {
    220     if (scheme.startsWith("web+")) {
    221         if (isValidProtocol(scheme))
    222             return true;
    223         ec = SECURITY_ERR;
    224         return false;
    225     }
    226 
    227     if (isProtocolWhitelisted(scheme))
    228         return true;
    229     ec = SECURITY_ERR;
    230     return false;
    231 }
    232 
    233 void Navigator::registerProtocolHandler(const String& scheme, const String& url, const String& title, ExceptionCode& ec)
    234 {
    235     if (!m_frame)
    236         return;
    237 
    238     Document* document = m_frame->document();
    239     if (!document)
    240         return;
    241 
    242     String baseURL = document->baseURL().baseAsString();
    243 
    244     if (!verifyCustomHandlerURL(baseURL, url, ec))
    245         return;
    246 
    247     if (!verifyProtocolHandlerScheme(scheme, ec))
    248         return;
    249 
    250     Page* page = m_frame->page();
    251     if (!page)
    252         return;
    253 
    254     page->chrome()->registerProtocolHandler(scheme, baseURL, url, m_frame->displayStringModifiedByEncoding(title));
    255 }
    256 #endif
    257 
    258157} // namespace WebCore
  • trunk/Source/WebCore/page/Navigator.h

    r108428 r108450  
    6161    void getStorageUpdates();
    6262
    63 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
    64     void registerProtocolHandler(const String& scheme, const String& url, const String& title, ExceptionCode&);
    65 #endif
    66 
    6763    void provideSupplement(const AtomicString&, PassOwnPtr<NavigatorSupplement>);
    6864    NavigatorSupplement* requireSupplement(const AtomicString&);
  • trunk/Source/WebCore/page/Navigator.idl

    r108428 r108450  
    4646
    4747        void getStorageUpdates(); // FIXME: Remove this method or rename to yieldForStorageUpdates.
    48 
    49 #if defined(ENABLE_REGISTER_PROTOCOL_HANDLER) && ENABLE_REGISTER_PROTOCOL_HANDLER
    50         void registerProtocolHandler(in DOMString scheme, in DOMString url, in DOMString title)
    51             raises(DOMException);
    52 #endif
    5348    };
    5449
Note: See TracChangeset for help on using the changeset viewer.