Changeset 170303 in webkit


Ignore:
Timestamp:
Jun 23, 2014 11:25:12 AM (10 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] No way to grant storage quotas for WebSQL
https://bugs.webkit.org/show_bug.cgi?id=134175

Reviewed by Anders Carlsson.

  • Shared/WebSecurityOrigin.h:

(WebKit::WebSecurityOrigin::securityOrigin): Changed to return a non-const reference.

  • UIProcess/API/APIUIClient.h:

(API::UIClient::exceededDatabaseQuota): Added a completion handler parameter than takes the
new quota, and changed the return type to void.

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient): Changed the override of exceededDatabaseQuota to call the
completion handler with the new quota, or with the existing quota if the client doesn’t
implement the callback.

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared new delegate method.
  • UIProcess/API/Cocoa/_WKSecurityOrigin.h: Added.
  • UIProcess/API/Cocoa/_WKSecurityOrigin.mm: Added.

(-[_WKSecurityOrigin _initWithSecurityOrigin:WebCore::]): Store the origin in an ivar.
(-[_WKSecurityOrigin protocol]): Added this accessor.
(-[_WKSecurityOrigin host]): Ditto.
(-[_WKSecurityOrigin port]): Ditto.

  • UIProcess/API/Cocoa/_WKSecurityOriginInternal.h: Added.
  • UIProcess/Cocoa/UIDelegate.h: Override API::UIClient::exceededDatabaseQuota. Added flag

to m_delegateMethods struct for new delegate method.

  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate): Set new flag in m_delegateMethods struct.
(WebKit::UIDelegate::UIClient::exceededDatabaseQuota): Added. Calls the new delegate method.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::exceededDatabaseQuota): Updated for the new client interface: now
passing a completion handler that replies with the new quota.

  • WebKit2.xcodeproj/project.pbxproj: Added references to new files, sorted a group.
Location:
trunk/Source/WebKit2
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r170300 r170303  
     12014-06-23  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] No way to grant storage quotas for WebSQL
     4        https://bugs.webkit.org/show_bug.cgi?id=134175
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/WebSecurityOrigin.h:
     9        (WebKit::WebSecurityOrigin::securityOrigin): Changed to return a non-const reference.
     10
     11        * UIProcess/API/APIUIClient.h:
     12        (API::UIClient::exceededDatabaseQuota): Added a completion handler parameter than takes the
     13        new quota, and changed the return type to void.
     14
     15        * UIProcess/API/C/WKPage.cpp:
     16        (WKPageSetPageUIClient): Changed the override of exceededDatabaseQuota to call the
     17        completion handler with the new quota, or with the existing quota if the client doesn’t
     18        implement the callback.
     19
     20        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared new delegate method.
     21
     22        * UIProcess/API/Cocoa/_WKSecurityOrigin.h: Added.
     23        * UIProcess/API/Cocoa/_WKSecurityOrigin.mm: Added.
     24        (-[_WKSecurityOrigin _initWithSecurityOrigin:WebCore::]): Store the origin in an ivar.
     25        (-[_WKSecurityOrigin protocol]): Added this accessor.
     26        (-[_WKSecurityOrigin host]): Ditto.
     27        (-[_WKSecurityOrigin port]): Ditto.
     28        * UIProcess/API/Cocoa/_WKSecurityOriginInternal.h: Added.
     29
     30        * UIProcess/Cocoa/UIDelegate.h: Override API::UIClient::exceededDatabaseQuota. Added flag
     31        to m_delegateMethods struct for new delegate method.
     32        * UIProcess/Cocoa/UIDelegate.mm:
     33        (WebKit::UIDelegate::setDelegate): Set new flag in m_delegateMethods struct.
     34        (WebKit::UIDelegate::UIClient::exceededDatabaseQuota): Added. Calls the new delegate method.
     35
     36        * UIProcess/WebPageProxy.cpp:
     37        (WebKit::WebPageProxy::exceededDatabaseQuota): Updated for the new client interface: now
     38        passing a completion handler that replies with the new quota.
     39
     40        * WebKit2.xcodeproj/project.pbxproj: Added references to new files, sorted a group.
     41
    1422014-06-23  Simon Fraser  <simon.fraser@apple.com>
    243
  • trunk/Source/WebKit2/Shared/WebSecurityOrigin.h

    r170133 r170303  
    5252    }
    5353
    54     const WebCore::SecurityOrigin& securityOrigin() const { return *m_securityOrigin; }
     54    WebCore::SecurityOrigin& securityOrigin() const { return *m_securityOrigin; }
    5555
    5656private:
  • trunk/Source/WebKit2/UIProcess/API/APIUIClient.h

    r168325 r170303  
    111111    virtual void pageDidScroll(WebKit::WebPageProxy*) { }
    112112
    113     virtual unsigned long long exceededDatabaseQuota(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebSecurityOrigin*, const WTF::String&, const WTF::String&, unsigned long long currentQuota, unsigned long long, unsigned long long, unsigned long long)
     113    virtual void exceededDatabaseQuota(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebSecurityOrigin*, const WTF::String&, const WTF::String&, unsigned long long currentQuota, unsigned long long, unsigned long long, unsigned long long, std::function<void (unsigned long long)> completionHandler)
    114114    {
    115         return currentQuota;
     115        completionHandler(currentQuota);
    116116    }
    117117
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r170126 r170303  
    14391439        }
    14401440
    1441         virtual unsigned long long exceededDatabaseQuota(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) override
     1441        virtual void exceededDatabaseQuota(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)> completionHandler) override
    14421442        {
    14431443            if (!m_client.exceededDatabaseQuota)
    1444                 return currentQuota;
    1445 
    1446             return m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, m_client.base.clientInfo);
     1444                completionHandler(currentQuota);
     1445
     1446            completionHandler(m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, m_client.base.clientInfo));
    14471447        }
    14481448
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r169727 r170303  
    2929
    3030#import <WebKit/_WKActivatedElementInfo.h>
     31#import <WebKit/_WKSecurityOrigin.h>
    3132
    3233@class _WKFrameHandle;
     
    3536
    3637@optional
     38
     39// FIXME: This should be handled by the WKWebsiteDataStore delegate.
     40- (void)_webView:(WKWebView *)webView decideDatabaseQuotaForSecurityOrigin:(_WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota currentOriginUsage:(unsigned long long)currentOriginUsage currentDatabaseUsage:(unsigned long long)currentUsage expectedUsage:(unsigned long long)expectedUsage decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
    3741
    3842- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h

    r169727 r170303  
    6363        virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (bool)> completionHandler) override;
    6464        virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (const WTF::String&)> completionHandler) override;
     65        virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)>) override;
    6566        virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
    6667    #if PLATFORM(IOS)
     
    8182        bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
    8283        bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
     84        bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
    8385        bool webViewPrintFrame : 1;
    8486#if PLATFORM(IOS)
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r169854 r170303  
    3838#import "WKUIDelegatePrivate.h"
    3939#import "_WKFrameHandleInternal.h"
     40#import "_WKSecurityOriginInternal.h"
    4041
    4142namespace WebKit {
     
    6869    m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
    6970    m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
     71    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
    7072    m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
    7173#if PLATFORM(IOS)
     
    172174}
    173175
     176void UIDelegate::UIClient::exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin* securityOrigin, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)> completionHandler)
     177{
     178    if (!m_uiDelegate.m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler) {
     179        completionHandler(currentQuota);
     180        return;
     181    }
     182
     183    auto delegate = m_uiDelegate.m_delegate.get();
     184    if (!delegate) {
     185        completionHandler(currentQuota);
     186        return;
     187    }
     188
     189    RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:));
     190    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideDatabaseQuotaForSecurityOrigin:adoptNS([[_WKSecurityOrigin alloc] _initWithSecurityOrigin:&securityOrigin->securityOrigin()]).get() currentQuota:currentQuota currentOriginUsage:currentOriginUsage currentDatabaseUsage:currentUsage expectedUsage:expectedUsage decisionHandler:[completionHandler, checker](unsigned long long newQuota) {
     191        checker->didCallCompletionHandler();
     192        completionHandler(newQuota);
     193    }];
     194}
     195
    174196void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
    175197{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r170254 r170303  
    44454445
    44464446        RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(SecurityOrigin::createFromDatabaseIdentifier(record->originIdentifier));
    4447 
    4448         uint64_t newQuota = m_uiClient->exceededDatabaseQuota(this, frame, origin.get(),
     4447        auto currentReply = record->reply;
     4448        m_uiClient->exceededDatabaseQuota(this, frame, origin.get(),
    44494449            record->databaseName, record->displayName, record->currentQuota,
    4450             record->currentOriginUsage, record->currentDatabaseUsage, record->expectedUsage);
    4451 
    4452         record->reply->send(newQuota);
     4450            record->currentOriginUsage, record->currentDatabaseUsage, record->expectedUsage,
     4451            [currentReply](unsigned long long newQuota) { currentReply->send(newQuota); });
     4452
    44534453        record = records.next();
    44544454    }
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r170219 r170303  
    711711                3769079E18F340A2001DFF04 /* APIInjectedBundleFormClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3769079C18F340A2001DFF04 /* APIInjectedBundleFormClient.h */; };
    712712                37694525184FC6B600CDE21F /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCF5068412431861005955AE /* Security.framework */; };
     713                376C51191957452E0007B0FA /* _WKSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 376C51171957452E0007B0FA /* _WKSecurityOrigin.mm */; };
     714                376C511A1957452E0007B0FA /* _WKSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 376C51181957452E0007B0FA /* _WKSecurityOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; };
     715                376C511D19574F5F0007B0FA /* _WKSecurityOriginInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 376C511B195748C20007B0FA /* _WKSecurityOriginInternal.h */; };
    713716                377EAD4517E2C51A002D193D /* WKDeclarationSpecifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 377EAD4417E2C51A002D193D /* WKDeclarationSpecifiers.h */; settings = {ATTRIBUTES = (Private, ); }; };
    714717                377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */ = {isa = PBXBuildFile; fileRef = 377EAD4617E2C77B002D193D /* WKUserContentInjectedFrames.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    27042707                3769079818F31CB2001DFF04 /* APIInjectedBundlePageUIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APIInjectedBundlePageUIClient.h; path = API/APIInjectedBundlePageUIClient.h; sourceTree = "<group>"; };
    27052708                3769079C18F340A2001DFF04 /* APIInjectedBundleFormClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIInjectedBundleFormClient.h; sourceTree = "<group>"; };
     2709                376C51171957452E0007B0FA /* _WKSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKSecurityOrigin.mm; sourceTree = "<group>"; };
     2710                376C51181957452E0007B0FA /* _WKSecurityOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKSecurityOrigin.h; sourceTree = "<group>"; };
     2711                376C511B195748C20007B0FA /* _WKSecurityOriginInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKSecurityOriginInternal.h; sourceTree = "<group>"; };
    27062712                377EAD4417E2C51A002D193D /* WKDeclarationSpecifiers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDeclarationSpecifiers.h; sourceTree = "<group>"; };
    27072713                377EAD4617E2C77B002D193D /* WKUserContentInjectedFrames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentInjectedFrames.h; sourceTree = "<group>"; };
     
    49724978                                1A43E828188F3CDC009E4D30 /* _WKProcessPoolConfiguration.h */,
    49734979                                1A43E827188F3CDC009E4D30 /* _WKProcessPoolConfiguration.mm */,
     4980                                376C51181957452E0007B0FA /* _WKSecurityOrigin.h */,
     4981                                376C51171957452E0007B0FA /* _WKSecurityOrigin.mm */,
     4982                                376C511B195748C20007B0FA /* _WKSecurityOriginInternal.h */,
    49744983                                2D6B371918A967AD0042AE80 /* _WKThumbnailView.h */,
    49754984                                2D6B371A18A967AD0042AE80 /* _WKThumbnailView.mm */,
     
    49894998                                37C4C08818149F23003688B9 /* WKBackForwardListItemInternal.h */,
    49904999                                1AF4592D19464B2000F9D4A2 /* WKError.h */,
     5000                                1AF4592C19464B2000F9D4A2 /* WKError.mm */,
    49915001                                1A2D252A194688FD004537B0 /* WKErrorInternal.h */,
    4992                                 1AF4592C19464B2000F9D4A2 /* WKError.mm */,
    49935002                                1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */,
    49945003                                1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
     
    70437052                                1F7506B31859164500EC0FF7 /* WKWebProcessPlugInNodeHandle.h in Headers */,
    70447053                                377EAD4517E2C51A002D193D /* WKDeclarationSpecifiers.h in Headers */,
     7054                                376C511D19574F5F0007B0FA /* _WKSecurityOriginInternal.h in Headers */,
    70457055                                1FB00AC7185F76460019142E /* WKWebProcessPlugInPageGroup.h in Headers */,
    70467056                                377EAD4917E2C77B002D193D /* WKUserScriptInjectionTime.h in Headers */,
     
    70737083                                BC8F2F2B16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.h in Headers */,
    70747084                                1AD8790A18B6C38A006CAFD7 /* WKUIDelegate.h in Headers */,
     7085                                376C511A1957452E0007B0FA /* _WKSecurityOrigin.h in Headers */,
    70757086                                290F4272172A0C7400939FF0 /* ChildProcessSupplement.h in Headers */,
    70767087                                1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */,
     
    89888999                                1A44B95716B737AA00B7BBD8 /* StorageNamespaceImpl.cpp in Sources */,
    89899000                                1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */,
     9001                                376C51191957452E0007B0FA /* _WKSecurityOrigin.mm in Sources */,
    89909002                                517DD5BE180DA7D30081660B /* DatabaseProcessProxy.cpp in Sources */,
    89919003                                51654EFD184EF33F007DC837 /* UniqueIDBDatabaseBackingStoreSQLite.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.