Web Inspector: implement runOpenPanel callback for WebKit2 inspector

https://bugs.webkit.org/show_bug.cgi?id=115865

Patch by Brian J. Burg <burg@cs.washington.edu> on 2013-05-10
Reviewed by Sam Weinig.

* UIProcess/WebInspectorProxy.h:
(WebKit::WebInspectorProxy::inspectorWindow):
Add an accessor for m_inspectorWindow.

* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::runOpenPanel):
Show the open panel dialog when requested.

(WebKit::WebInspectorProxy::platformCreateInspectorPage):
Register the callback when the inspector page is created.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f8664fdb
2013-05-10 Brian J. Burg <burg@cs.washington.edu>
Web Inspector: implement runOpenPanel callback for WebKit2 inspector
https://bugs.webkit.org/show_bug.cgi?id=115865
Reviewed by Sam Weinig.
* UIProcess/WebInspectorProxy.h:
(WebKit::WebInspectorProxy::inspectorWindow):
Add an accessor for m_inspectorWindow.
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::runOpenPanel):
Show the open panel dialog when requested.
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
Register the callback when the inspector page is created.
2013-05-10 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
[WK2][CoordinatedGraphics] WKViewSetThemePath is EFL specific
......
......@@ -96,6 +96,7 @@ public:
void updateInspectorWindowTitle() const;
void inspectedViewFrameDidChange(CGFloat = 0);
void windowFrameDidChange();
NSWindow* inspectorWindow() const { return m_inspectorWindow.get(); }
void setInspectorWindowFrame(WKRect&);
WKRect inspectorWindowFrame();
......
......@@ -31,6 +31,11 @@
#import "WKAPICast.h"
#import "WebContext.h"
#import "WKInspectorPrivateMac.h"
#import "WKMutableArray.h"
#import "WKOpenPanelParameters.h"
#import "WKOpenPanelResultListener.h"
#import "WKRetainPtr.h"
#import "WKURLCF.h"
#import "WKViewPrivate.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
......@@ -221,6 +226,37 @@ static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurit
return std::max<unsigned long long>(expectedUsage, currentDatabaseUsage * 1.25);
}
static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
{
WebInspectorProxy* webInspectorProxy = static_cast<WebInspectorProxy*>(const_cast<void*>(clientInfo));
ASSERT(webInspectorProxy);
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:WKOpenPanelParametersGetAllowsMultipleFiles(parameters)];
WKRetain(listener);
// If the inspector is detached, then openPanel will be window-modal; otherwise, openPanel is opened in a new window.
[openPanel beginSheetModalForWindow:webInspectorProxy->inspectorWindow() completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
WKMutableArrayRef fileURLs = WKMutableArrayCreate();
for (NSURL* nsURL in [openPanel URLs]) {
WKURLRef wkURL = WKURLCreateWithCFURL(reinterpret_cast<CFURLRef>(nsURL));
WKArrayAppendItem(fileURLs, wkURL);
WKRelease(wkURL);
}
WKOpenPanelResultListenerChooseFiles(listener, fileURLs);
WKRelease(fileURLs);
} else
WKOpenPanelResultListenerCancel(listener);
WKRelease(listener);
}];
}
void WebInspectorProxy::setInspectorWindowFrame(WKRect& frame)
{
if (m_isAttached)
......@@ -408,7 +444,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
0, // didDraw
0, // pageDidScroll
exceededDatabaseQuota,
0, // runOpenPanel
runOpenPanel,
0, // decidePolicyForGeolocationPermissionRequest
0, // headerHeight
0, // footerHeight
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment