Title: [149903] trunk/Source/WebKit2
- Revision
- 149903
- Author
- [email protected]
- Date
- 2013-05-10 13:35:04 -0700 (Fri, 10 May 2013)
Log Message
Web Inspector: implement runOpenPanel callback for WebKit2 inspector
https://bugs.webkit.org/show_bug.cgi?id=115865
Patch by Brian J. Burg <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (149902 => 149903)
--- trunk/Source/WebKit2/ChangeLog 2013-05-10 20:34:16 UTC (rev 149902)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-10 20:35:04 UTC (rev 149903)
@@ -1,3 +1,21 @@
+2013-05-10 Brian J. Burg <[email protected]>
+
+ 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 <[email protected]>
[WK2][CoordinatedGraphics] WKViewSetThemePath is EFL specific
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (149902 => 149903)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2013-05-10 20:34:16 UTC (rev 149902)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2013-05-10 20:35:04 UTC (rev 149903)
@@ -96,6 +96,7 @@
void updateInspectorWindowTitle() const;
void inspectedViewFrameDidChange(CGFloat = 0);
void windowFrameDidChange();
+ NSWindow* inspectorWindow() const { return m_inspectorWindow.get(); }
void setInspectorWindowFrame(WKRect&);
WKRect inspectorWindowFrame();
Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (149902 => 149903)
--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm 2013-05-10 20:34:16 UTC (rev 149902)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm 2013-05-10 20:35:04 UTC (rev 149903)
@@ -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 @@
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 @@
0, // didDraw
0, // pageDidScroll
exceededDatabaseQuota,
- 0, // runOpenPanel
+ runOpenPanel,
0, // decidePolicyForGeolocationPermissionRequest
0, // headerHeight
0, // footerHeight
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes