Changeset 69460 in webkit


Ignore:
Timestamp:
Oct 9, 2010 2:58:16 PM (14 years ago)
Author:
weinig@apple.com
Message:

Add WebKit2 version of runBeforeUnloadConfirmPanelWithMessage
<rdar://problem/8447690>
https://bugs.webkit.org/show_bug.cgi?id=47459

Reviewed by Dan Bernstein.

WebKit2:

  • UIProcess/API/C/WKPage.h:
  • UIProcess/API/qt/qwkpage.cpp:

(QWKPage::QWKPage):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setWindowFrame):
(WebKit::WebPageProxy::getWindowFrame):
(WebKit::WebPageProxy::canRunBeforeUnloadConfirmPanel):
(WebKit::WebPageProxy::runBeforeUnloadConfirmPanel):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/WebUIClient.cpp:

(WebKit::WebUIClient::canRunBeforeUnloadConfirmPanel):
(WebKit::WebUIClient::runBeforeUnloadConfirmPanel):

  • UIProcess/WebUIClient.h:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::canRunBeforeUnloadConfirmPanel):
(WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
Pipe calls through to the UIProcess.

WebKitTools:

  • MiniBrowser/mac/BrowserWindowController.m:

(runBeforeUnloadConfirmPanel):
(-[BrowserWindowController awakeFromNib]):

  • WebKitTestRunner/TestController.cpp:

(WTR::createOtherPage):
(WTR::TestController::initialize):

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r69457 r69460  
     12010-10-09  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Add WebKit2 version of runBeforeUnloadConfirmPanelWithMessage
     6        <rdar://problem/8447690>
     7        https://bugs.webkit.org/show_bug.cgi?id=47459
     8
     9        * UIProcess/API/C/WKPage.h:
     10        * UIProcess/API/qt/qwkpage.cpp:
     11        (QWKPage::QWKPage):
     12        * UIProcess/WebPageProxy.cpp:
     13        (WebKit::WebPageProxy::setWindowFrame):
     14        (WebKit::WebPageProxy::getWindowFrame):
     15        (WebKit::WebPageProxy::canRunBeforeUnloadConfirmPanel):
     16        (WebKit::WebPageProxy::runBeforeUnloadConfirmPanel):
     17        * UIProcess/WebPageProxy.h:
     18        * UIProcess/WebPageProxy.messages.in:
     19        * UIProcess/WebUIClient.cpp:
     20        (WebKit::WebUIClient::canRunBeforeUnloadConfirmPanel):
     21        (WebKit::WebUIClient::runBeforeUnloadConfirmPanel):
     22        * UIProcess/WebUIClient.h:
     23        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     24        (WebKit::WebChromeClient::canRunBeforeUnloadConfirmPanel):
     25        (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
     26        Pipe calls through to the UIProcess.
     27
    1282010-10-09  Sam Weinig  <sam@webkit.org>
    229
  • trunk/WebKit2/UIProcess/API/C/WKPage.h

    r69457 r69460  
    142142typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
    143143typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
     144typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
    144145
    145146struct WKPageUIClient {
     
    158159    WKPageGetWindowFrameCallback                                        getWindowFrame;
    159160    WKPageSetWindowFrameCallback                                        setWindowFrame;
     161    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
    160162};
    161163typedef struct WKPageUIClient WKPageUIClient;
  • trunk/WebKit2/UIProcess/API/qt/qwkpage.cpp

    r69457 r69460  
    284284        0,  /* contentsSizeChanged */
    285285        0,  /* didNotHandleKeyEvent */
    286         0,  /* getWindowRect */
    287         0   /* setWindowRect */
     286        0,  /* getWindowFrame */
     287        0,  /* setWindowFrame */
     288        0   /* runBeforeUnloadConfirmPanel */
    288289    };
    289290    WKPageSetPageUIClient(pageRef(), &uiClient);
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r69457 r69460  
    866866}
    867867
     868void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
     869{
     870    m_uiClient.setWindowFrame(this, m_pageClient->transformToDeviceSpace(newWindowFrame));
     871}
     872
     873void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
     874{
     875    newWindowFrame = m_pageClient->transformToUserSpace(m_uiClient.windowFrame(this));
     876}
     877
     878void WebPageProxy::canRunBeforeUnloadConfirmPanel(bool& canRun)
     879{
     880    canRun = m_uiClient.canRunBeforeUnloadConfirmPanel();
     881}
     882
     883void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
     884{
     885    shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, process()->webFrame(frameID));
     886}
     887
    868888// BackForwardList
    869889
     
    970990{
    971991    m_pageClient->setEditCommandState(commandName, isEnabled, state);
    972 }
    973 
    974 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
    975 {
    976     m_uiClient.setWindowFrame(this, m_pageClient->transformToDeviceSpace(newWindowFrame));
    977 }
    978 
    979 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
    980 {
    981     newWindowFrame = m_pageClient->transformToUserSpace(m_uiClient.windowFrame(this));
    982992}
    983993
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r69457 r69460  
    248248    void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
    249249
     250    // UI client
    250251    void createNewPage(uint64_t& newPageID, WebPageCreationParameters&);
    251252    void showPage();
     
    257258    void mouseDidMoveOverElement(uint32_t modifiers, CoreIPC::ArgumentDecoder*);
    258259    void contentsSizeChanged(uint64_t frameID, const WebCore::IntSize&);
     260    void setWindowFrame(const WebCore::FloatRect&);
     261    void getWindowFrame(WebCore::FloatRect&);
     262    void canRunBeforeUnloadConfirmPanel(bool& canRun);
     263    void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose);
    259264
    260265    // Back/Forward list management
     
    279284    void setCursor(const WebCore::Cursor&);
    280285    void didValidateMenuItem(const String& commandName, bool isEnabled, int32_t state);
    281 
    282     void setWindowFrame(const WebCore::FloatRect&);
    283     void getWindowFrame(WebCore::FloatRect&);
    284 
     286   
    285287    void didReceiveEvent(uint32_t opaqueType, bool handled);
    286288
  • trunk/WebKit2/UIProcess/WebPageProxy.messages.in

    r69457 r69460  
    3939    SetWindowFrame(WebCore::FloatRect windowFrame)
    4040    GetWindowFrame() -> (WebCore::FloatRect windowFrame)
     41    CanRunBeforeUnloadConfirmPanel() -> (bool canRun)
     42    RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose)
    4143
    4244    # Policy messages.
  • trunk/WebKit2/UIProcess/WebUIClient.cpp

    r69457 r69460  
    154154}
    155155
     156bool WebUIClient::canRunBeforeUnloadConfirmPanel()
     157{
     158    return m_pageUIClient.runBeforeUnloadConfirmPanel;
     159}
     160
     161bool WebUIClient::runBeforeUnloadConfirmPanel(WebPageProxy* page, const String& message, WebFrameProxy* frame)
     162{
     163    if (!m_pageUIClient.runBeforeUnloadConfirmPanel)
     164        return true;
     165
     166    return m_pageUIClient.runBeforeUnloadConfirmPanel(toAPI(page), toAPI(message.impl()), toAPI(frame), m_pageUIClient.clientInfo);
     167}
     168
    156169} // namespace WebKit
  • trunk/WebKit2/UIProcess/WebUIClient.h

    r69457 r69460  
    5151    void showPage(WebPageProxy*);
    5252    void close(WebPageProxy*);
     53
    5354    void runJavaScriptAlert(WebPageProxy*, const String&, WebFrameProxy*);
    5455    bool runJavaScriptConfirm(WebPageProxy*, const String&, WebFrameProxy*);
    5556    String runJavaScriptPrompt(WebPageProxy*, const String&, const String&, WebFrameProxy*);
     57
    5658    void setStatusText(WebPageProxy*, const String&);
    5759    void mouseDidMoveOverElement(WebPageProxy*, WebEvent::Modifiers, APIObject*);
     60
    5861    void contentsSizeChanged(WebPageProxy*, const WebCore::IntSize&, WebFrameProxy*);
    5962    void didNotHandleKeyEvent(WebPageProxy*, const NativeWebKeyboardEvent&);
     
    6164    void setWindowFrame(WebPageProxy*, const WebCore::FloatRect&);
    6265    WebCore::FloatRect windowFrame(WebPageProxy*);
     66
     67    bool canRunBeforeUnloadConfirmPanel();
     68    bool runBeforeUnloadConfirmPanel(WebPageProxy*, const String&, WebFrameProxy*);
    6369
    6470private:
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r69457 r69460  
    205205bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
    206206{
    207     notImplemented();
    208     return false;
     207    bool canRun = false;
     208    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CanRunBeforeUnloadConfirmPanel(),
     209            Messages::WebPageProxy::CanRunBeforeUnloadConfirmPanel::Reply(canRun),
     210            m_page->pageID(), CoreIPC::Connection::NoTimeout))
     211        return false;
     212
     213    return canRun;
    209214}
    210215
    211216bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
    212217{
    213     notImplemented();
    214     return false;
     218    WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     219
     220    bool shouldClose = false;
     221    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()),
     222            Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose),
     223            m_page->pageID(), CoreIPC::Connection::NoTimeout))
     224        return false;
     225
     226    return shouldClose;
    215227}
    216228
  • trunk/WebKitTools/ChangeLog

    r69457 r69460  
     12010-10-09  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Add WebKit2 version of runBeforeUnloadConfirmPanelWithMessage
     6        <rdar://problem/8447690>
     7        https://bugs.webkit.org/show_bug.cgi?id=47459
     8
     9        * MiniBrowser/mac/BrowserWindowController.m:
     10        (runBeforeUnloadConfirmPanel):
     11        (-[BrowserWindowController awakeFromNib]):
     12        * WebKitTestRunner/TestController.cpp:
     13        (WTR::createOtherPage):
     14        (WTR::TestController::initialize):
     15
    1162010-10-09  Sam Weinig  <sam@webkit.org>
    217
  • trunk/WebKitTools/MiniBrowser/mac/BrowserWindowController.m

    r69457 r69460  
    499499{
    500500    [[(BrowserWindowController *)clientInfo window] setFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height) display:YES];
     501}
     502
     503static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
     504{
     505    NSAlert *alert = [[NSAlert alloc] init];
     506
     507    WKURLRef wkURL = WKFrameCopyURL(frame);
     508    CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
     509    WKRelease(wkURL);
     510
     511    [alert setMessageText:[NSString stringWithFormat:@"BeforeUnload confirm dialog from %@.", [(NSURL *)cfURL absoluteString]]];
     512    CFRelease(cfURL);
     513
     514    CFStringRef cfMessage = WKStringCopyCFString(0, message);
     515    [alert setInformativeText:(NSString *)cfMessage];
     516    CFRelease(cfMessage);
     517
     518    [alert addButtonWithTitle:@"OK"];
     519    [alert addButtonWithTitle:@"Cancel"];
     520
     521    NSInteger button = [alert runModal];
     522    [alert release];
     523
     524    return button == NSAlertFirstButtonReturn;
    501525}
    502526
     
    557581        0,          /* didNotHandleKeyEvent */
    558582        getWindowFrame,
    559         setWindowFrame
     583        setWindowFrame,
     584        runBeforeUnloadConfirmPanel
    560585    };
    561586    WKPageSetPageUIClient(_webView.pageRef, &uiClient);
  • trunk/WebKitTools/WebKitTestRunner/TestController.cpp

    r69457 r69460  
    120120        0,
    121121        getWindowFrameOtherPage,
    122         setWindowFrameOtherPage
     122        setWindowFrameOtherPage,
     123        0
    123124    };
    124125    WKPageSetPageUIClient(newPage, &otherPageUIClient);
     
    203204        0,
    204205        getWindowFrameMainPage,
    205         setWindowFrameMainPage
     206        setWindowFrameMainPage,
     207        0,
    206208    };
    207209    WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
Note: See TracChangeset for help on using the changeset viewer.