Changeset 188255 in webkit


Ignore:
Timestamp:
Aug 11, 2015 9:14:15 AM (9 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] The UI delegate can't tell if printing was user-initiated
https://bugs.webkit.org/show_bug.cgi?id=147869

Reviewed by Sam Weinig.

Source/WebKit2:

  • UIProcess/API/APIUIClient.h:

(API::UIClient::printFrame): Added processingUserGesture argument.

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient): Updated for new client function signature.

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added userInitiated boolean argument to -_webView:printFrame:.
  • UIProcess/Cocoa/UIDelegate.h: Added bool to m_delegateMethods for the new method.
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::UIDelegate):
(WebKit::UIDelegate::setDelegate): Initialized new bool.
(WebKit::UIDelegate::UIClient::printFrame): Pass processingUserGesture as the delegate’s

userInitiated argument.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::printFrame): Added processingUserGesture argument, passing it along

to the client.

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in: Added processingUserGesture argument to printFrame.
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::print): Pass new argument.

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm: Added.

(-[PrintFrameController webView:didFinishNavigation:]):
(-[PrintFrameController _webView:printFrame:userInitiated:]):
(TEST):

Location:
trunk
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r188236 r188255  
     12015-08-11  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] The UI delegate can't tell if printing was user-initiated
     4        https://bugs.webkit.org/show_bug.cgi?id=147869
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/APIUIClient.h:
     9        (API::UIClient::printFrame): Added processingUserGesture argument.
     10
     11        * UIProcess/API/C/WKPage.cpp:
     12        (WKPageSetPageUIClient): Updated for new client function signature.
     13
     14        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added userInitiated boolean argument to
     15          -_webView:printFrame:.
     16
     17        * UIProcess/Cocoa/UIDelegate.h: Added bool to m_delegateMethods for the new method.
     18        * UIProcess/Cocoa/UIDelegate.mm:
     19        (WebKit::UIDelegate::UIDelegate):
     20        (WebKit::UIDelegate::setDelegate): Initialized new bool.
     21        (WebKit::UIDelegate::UIClient::printFrame): Pass processingUserGesture as the delegate’s
     22          userInitiated argument.
     23
     24        * UIProcess/WebPageProxy.cpp:
     25        (WebKit::WebPageProxy::printFrame): Added processingUserGesture argument, passing it along
     26          to the client.
     27        * UIProcess/WebPageProxy.h:
     28
     29        * UIProcess/WebPageProxy.messages.in: Added processingUserGesture argument to printFrame.
     30
     31        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     32        (WebKit::WebChromeClient::print): Pass new argument.
     33
    1342015-08-10  Matthew Daiter  <mdaiter@apple.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/APIUIClient.h

    r187272 r188255  
    140140    virtual void drawHeader(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
    141141    virtual void drawFooter(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
    142     virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { }
     142    virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) { }
    143143
    144144    virtual bool canRunModal() const { return false; }
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r188228 r188255  
    17311731        }
    17321732
    1733         virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame) override
     1733        virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame, bool) override
    17341734        {
    17351735            if (!m_client.printFrame)
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r187272 r188255  
    4949- (void)_webView:(WKWebView *)webView decideWebApplicationCacheQuotaForSecurityOrigin:(WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota totalBytesNeeded:(unsigned long long)totalBytesNeeded decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
    5050
    51 - (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
     51- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame userInitiated:(BOOL)userInitiated WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
    5252
    5353- (void)_webViewClose:(WKWebView *)webView;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h

    r187272 r188255  
    6969        virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::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)>) override;
    7070        virtual void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
    71         virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
     71        virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) override;
    7272#if PLATFORM(IOS)
    7373#if HAVE(APP_LINKS)
     
    9595        bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
    9696        bool webViewPrintFrame : 1;
     97        bool webViewPrintFrameUserInitiated : 1;
    9798        bool webViewDidClose : 1;
    9899        bool webViewClose : 1;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r187272 r188255  
    4242#import <WebCore/URL.h>
    4343
     44@protocol WKUIDelegatePrivateDeprecated <WKUIDelegatePrivate>
     45@optional
     46- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
     47@end
     48
    4449namespace WebKit {
    4550
     
    7479    m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
    7580    m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
     81    m_delegateMethods.webViewPrintFrameUserInitiated = [delegate respondsToSelector:@selector(_webView:printFrame:userInitiated:)];
    7682    m_delegateMethods.webViewDidClose = [delegate respondsToSelector:@selector(webViewDidClose:)];
    7783    m_delegateMethods.webViewClose = [delegate respondsToSelector:@selector(_webViewClose:)];
     
    231237}
    232238
    233 void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
     239void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy, bool processingUserGesture)
    234240{
    235241    ASSERT_ARG(webFrameProxy, webFrameProxy);
    236242
    237     if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame)
    238         return;
    239 
    240     auto delegate = m_uiDelegate.m_delegate.get();
    241     if (!delegate)
    242         return;
    243 
    244     [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
     243    if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame  && !m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
     244        return;
     245
     246    auto delegate = m_uiDelegate.m_delegate.get();
     247    if (!delegate)
     248        return;
     249
     250    if (m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
     251        [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID())) userInitiated:processingUserGesture];
     252    else
     253        [(id <WKUIDelegatePrivateDeprecated>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
    245254}
    246255
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r188228 r188255  
    38373837}
    38383838
    3839 void WebPageProxy::printFrame(uint64_t frameID)
     3839void WebPageProxy::printFrame(uint64_t frameID, bool processingUserGesture)
    38403840{
    38413841    ASSERT(!m_isPerformingDOMPrintOperation);
     
    38453845    MESSAGE_CHECK(frame);
    38463846
    3847     m_uiClient->printFrame(this, frame);
     3847    m_uiClient->printFrame(this, frame, processingUserGesture);
    38483848
    38493849    endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
    38503850    m_isPerformingDOMPrintOperation = false;
    3851 }
    3852 
    3853 void WebPageProxy::printMainFrame()
    3854 {
    3855     printFrame(m_mainFrame->frameID());
    38563851}
    38573852
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r188228 r188255  
    914914    void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
    915915
    916     void printMainFrame();
    917    
    918916    void setMediaVolume(float);
    919917    void setMuted(bool);
     
    11811179    void pageDidScroll();
    11821180    void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
    1183     void printFrame(uint64_t frameID);
     1181    void printFrame(uint64_t frameID, bool processingUserGesture);
    11841182    void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
    11851183    void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply>);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r188121 r188255  
    7777    PageDidScroll()
    7878    RunOpenPanel(uint64_t frameID, struct WebCore::FileChooserSettings parameters)
    79     PrintFrame(uint64_t frameID) -> ()
     79    PrintFrame(uint64_t frameID, bool processingUserGesture) -> ()
    8080    RunModal()
    8181    NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r188121 r188255  
    681681        syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
    682682   
    683     m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
     683    m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID(), ScriptController::processingUserGesture()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
    684684}
    685685
  • trunk/Tools/ChangeLog

    r188251 r188255  
     12015-08-11  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] The UI delegate can't tell if printing was user-initiated
     4        https://bugs.webkit.org/show_bug.cgi?id=147869
     5
     6        Reviewed by Sam Weinig.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm: Added.
     10        (-[PrintFrameController webView:didFinishNavigation:]):
     11        (-[PrintFrameController _webView:printFrame:userInitiated:]):
     12        (TEST):
     13
    1142015-08-10  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r188169 r188255  
    4040                33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
    4141                33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
     42                376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3764817D1B79CD7D00D24B97 /* PrintFrame.mm */; settings = {ASSET_TAGS = (); }; };
    4243                378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
    4344                378E64791632707400B6C676 /* link-with-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 378E647816326FDF00B6C676 /* link-with-title.html */; };
     
    497498                3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMRange.mm; sourceTree = "<group>"; };
    498499                3751AF7A169518F800764319 /* DOMNodeFromJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMNodeFromJSObject.mm; sourceTree = "<group>"; };
     500                3764817D1B79CD7D00D24B97 /* PrintFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrintFrame.mm; sourceTree = "<group>"; };
    499501                3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorInDashboardRegions.mm; sourceTree = "<group>"; };
    500502                378E64711632646D00B6C676 /* InjectedBundleFrameHitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFrameHitTest.cpp; sourceTree = "<group>"; };
     
    867869                                CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
    868870                                C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
     871                                3764817D1B79CD7D00D24B97 /* PrintFrame.mm */,
    869872                                37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
    870873                                37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
     
    15621565                                7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,
    15631566                                7CCE7F0C1A411AE600447C4C /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
     1567                                376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */,
    15641568                                7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
    15651569                                7CCE7F3E1A411B8E00447C4C /* RedBlackTree.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.