Title: [149923] trunk/Source
Revision
149923
Author
[email protected]
Date
2013-05-10 22:03:10 -0700 (Fri, 10 May 2013)

Log Message

Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save
https://bugs.webkit.org/show_bug.cgi?id=115564

Patch by Brian J. Burg <[email protected]> on 2013-05-10
Reviewed by Benjamin Poulain.

Source/WebKit/mac:

Clean up save() and append() implementations.

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorFrontendClient::save):
(WebInspectorFrontendClient::append):

Source/WebKit2:

Implement InspectorFrontendHost's save() and append() methods for
Mac WebKit2. Add canSave() for all ports.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::save):
(WebKit):
(WebKit::WebInspectorProxy::append):
* UIProcess/WebInspectorProxy.h:
(WebInspectorProxy):
* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/efl/WebInspectorProxyEfl.cpp:
(WebKit::WebInspectorProxy::platformSave):
(WebKit):
(WebKit::WebInspectorProxy::platformAppend):
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformSave):
(WebKit):
(WebKit::WebInspectorProxy::platformAppend):
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::platformSave):
(WebKit):
(WebKit::WebInspectorProxy::platformAppend):
* UIProcess/qt/WebInspectorProxyQt.cpp:
(WebKit::WebInspectorProxy::platformSave):
(WebKit):
(WebKit::WebInspectorProxy::platformAppend):
* WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
(WebKit::WebInspectorFrontendClient::canSave):
(WebKit):
(WebKit::WebInspectorFrontendClient::save):
(WebKit::WebInspectorFrontendClient::append):
* WebProcess/WebCoreSupport/WebInspectorFrontendClient.h:
(WebInspectorFrontendClient):
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::save):
(WebKit):
(WebKit::WebInspector::append):
(WebKit::WebInspector::didSave):
(WebKit::WebInspector::didAppend):
* WebProcess/WebPage/WebInspector.h:
(WebInspector):
* WebProcess/WebPage/WebInspector.messages.in:
* WebProcess/WebPage/efl/WebInspectorEfl.cpp:
(WebKit::WebInspector::canSave):
(WebKit):
* WebProcess/WebPage/gtk/WebInspectorGtk.cpp:
(WebKit::WebInspector::canSave):
(WebKit):
* WebProcess/WebPage/mac/WebInspectorMac.mm:
(WebKit::WebInspector::canSave):
(WebKit):
* WebProcess/WebPage/qt/WebInspectorQt.cpp:
(WebKit::WebInspector::canSave):
(WebKit):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (149922 => 149923)


--- trunk/Source/WebKit/mac/ChangeLog	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-05-11 05:03:10 UTC (rev 149923)
@@ -1,3 +1,17 @@
+2013-05-10  Brian J. Burg  <[email protected]>
+
+        Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save
+        https://bugs.webkit.org/show_bug.cgi?id=115564
+
+        Reviewed by Benjamin Poulain.
+
+        Clean up save() and append() implementations.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorFrontendClient::save):
+        (WebInspectorFrontendClient::append):
+
 2013-05-10  Laszlo Gombos  <[email protected]>
 
         Remove Mac OS X Leopard (10.5) support

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h (149922 => 149923)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2013-05-11 05:03:10 UTC (rev 149923)
@@ -123,5 +123,5 @@
     WebView* m_inspectedWebView;
     RetainPtr<WebInspectorWindowController> m_windowController;
     String m_inspectedURL;
-    HashMap<String, RetainPtr<NSURL>> m_saveURLs;
+    HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
 };

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm (149922 => 149923)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2013-05-11 05:03:10 UTC (rev 149923)
@@ -298,28 +298,41 @@
     [[m_windowController.get() window] setTitle:title];
 }
 
-void WebInspectorFrontendClient::save(const String& refURL, const String& refContent, bool forceSaveAs)
+void WebInspectorFrontendClient::save(const String& suggestedURL, const String& content, bool forceSaveDialog)
 {
-    String url = ""
-    String content = refContent;
-    auto saveToURL = ^(NSURL *URL) {
-        m_saveURLs.set(url, URL);
+    ASSERT(!suggestedURL.isEmpty());
+    
+    NSURL *platformURL = m_suggestedToActualURLMap.get(suggestedURL).get();
+    if (!platformURL) {
+        platformURL = [NSURL URLWithString:suggestedURL];
+        // The user must confirm new filenames before we can save to them.
+        forceSaveDialog = true;
+    }
+    
+    ASSERT(platformURL);
+    if (!platformURL)
+        return;
 
-        [content writeToURL:URL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
-        core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", URL.absoluteString]);
+    // Necessary for the block below.
+    String suggestedURLCopy = suggestedURL;
+    String contentCopy = content;
+
+    auto saveToURL = ^(NSURL *actualURL) {
+        ASSERT(actualURL);
+        
+        m_suggestedToActualURLMap.set(suggestedURLCopy, actualURL);
+        [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
+        core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", actualURL.absoluteString]);
     };
 
-    NSURL *URL = ""
-    if (!URL)
-        URL = "" URLWithString:url];
-    else if (!forceSaveAs) {
-        saveToURL(URL);
+    if (!forceSaveDialog) {
+        saveToURL(platformURL);
         return;
     }
-
+    
     NSSavePanel *panel = [NSSavePanel savePanel];
-    panel.nameFieldStringValue = URL.lastPathComponent;
-    panel.directoryURL = [URL URLByDeletingLastPathComponent];
+    panel.nameFieldStringValue = platformURL.lastPathComponent;
+    panel.directoryURL = [platformURL URLByDeletingLastPathComponent];
 
     [panel beginSheetModalForWindow:[[m_windowController webView] window] completionHandler:^(NSInteger result) {
         if (result == NSFileHandlingPanelCancelButton)
@@ -329,18 +342,21 @@
     }];
 }
 
-void WebInspectorFrontendClient::append(const String& url, const String& content)
+void WebInspectorFrontendClient::append(const String& suggestedURL, const String& content)
 {
-    RetainPtr<NSURL> URL = ""
-    if (!URL)
-        URL = "" URLWithString:url];
+    ASSERT(!suggestedURL.isEmpty());
+    
+    RetainPtr<NSURL> actualURL = m_suggestedToActualURLMap.get(suggestedURL);
+    // do not append unless the user has already confirmed this filename in save().
+    if (!actualURL)
+        return;
 
-    NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:URL.get() error:NULL];
+    NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:actualURL.get() error:NULL];
     [handle seekToEndOfFile];
     [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
     [handle closeFile];
 
-    core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [URL absoluteString]]);
+    core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [actualURL absoluteString]]);
 }
 
 // MARK: -

Modified: trunk/Source/WebKit2/ChangeLog (149922 => 149923)


--- trunk/Source/WebKit2/ChangeLog	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-11 05:03:10 UTC (rev 149923)
@@ -1,3 +1,65 @@
+2013-05-10  Brian J. Burg  <[email protected]>
+
+        Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save
+        https://bugs.webkit.org/show_bug.cgi?id=115564
+
+        Reviewed by Benjamin Poulain.
+
+        Implement InspectorFrontendHost's save() and append() methods for
+        Mac WebKit2. Add canSave() for all ports.
+
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::save):
+        (WebKit):
+        (WebKit::WebInspectorProxy::append):
+        * UIProcess/WebInspectorProxy.h:
+        (WebInspectorProxy):
+        * UIProcess/WebInspectorProxy.messages.in:
+        * UIProcess/efl/WebInspectorProxyEfl.cpp:
+        (WebKit::WebInspectorProxy::platformSave):
+        (WebKit):
+        (WebKit::WebInspectorProxy::platformAppend):
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformSave):
+        (WebKit):
+        (WebKit::WebInspectorProxy::platformAppend):
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::platformSave):
+        (WebKit):
+        (WebKit::WebInspectorProxy::platformAppend):
+        * UIProcess/qt/WebInspectorProxyQt.cpp:
+        (WebKit::WebInspectorProxy::platformSave):
+        (WebKit):
+        (WebKit::WebInspectorProxy::platformAppend):
+        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
+        (WebKit::WebInspectorFrontendClient::canSave):
+        (WebKit):
+        (WebKit::WebInspectorFrontendClient::save):
+        (WebKit::WebInspectorFrontendClient::append):
+        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.h:
+        (WebInspectorFrontendClient):
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::save):
+        (WebKit):
+        (WebKit::WebInspector::append):
+        (WebKit::WebInspector::didSave):
+        (WebKit::WebInspector::didAppend):
+        * WebProcess/WebPage/WebInspector.h:
+        (WebInspector):
+        * WebProcess/WebPage/WebInspector.messages.in:
+        * WebProcess/WebPage/efl/WebInspectorEfl.cpp:
+        (WebKit::WebInspector::canSave):
+        (WebKit):
+        * WebProcess/WebPage/gtk/WebInspectorGtk.cpp:
+        (WebKit::WebInspector::canSave):
+        (WebKit):
+        * WebProcess/WebPage/mac/WebInspectorMac.mm:
+        (WebKit::WebInspector::canSave):
+        (WebKit):
+        * WebProcess/WebPage/qt/WebInspectorQt.cpp:
+        (WebKit::WebInspector::canSave):
+        (WebKit):
+
 2013-05-10  Remy Demarest  <[email protected]>
 
         Copy WKPluginInformation.h header to the WebKit2 Framework private headers.

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -474,6 +474,16 @@
     platformInspectedURLChanged(urlString);
 }
 
+void WebInspectorProxy::save(const String& filename, const String& content, bool forceSaveAs)
+{
+    platformSave(filename, content, forceSaveAs);
+}
+
+void WebInspectorProxy::append(const String& filename, const String& content)
+{
+    platformAppend(filename, content);
+}
+
 bool WebInspectorProxy::canAttach()
 {
     // Keep this in sync with InspectorFrontendClientLocal::canAttachWindow. There are two implementations

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2013-05-11 05:03:10 UTC (rev 149923)
@@ -38,9 +38,11 @@
 
 #if PLATFORM(MAC)
 #include "WKGeometry.h"
+#include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS NSButton;
+OBJC_CLASS NSURL;
 OBJC_CLASS NSWindow;
 OBJC_CLASS WKWebInspectorProxyObjCAdapter;
 OBJC_CLASS WKWebInspectorWKView;
@@ -164,7 +166,10 @@
     void platformDetach();
     void platformSetAttachedWindowHeight(unsigned);
     void platformSetAttachedWindowWidth(unsigned);
+    void platformSave(const String& filename, const String& content, bool forceSaveAs);
+    void platformAppend(const String& filename, const String& content);
 
+
     // Called by WebInspectorProxy messages
     void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
     void didClose();
@@ -172,6 +177,9 @@
     void attachAvailabilityChanged(bool);
     void inspectedURLChanged(const String&);
 
+    void save(const String& filename, const String& content, bool forceSaveAs);
+    void append(const String& filename, const String& content);
+
 #if ENABLE(INSPECTOR_SERVER)
     void sendMessageToRemoteFrontend(const String& message);
 #endif
@@ -217,6 +225,7 @@
     RetainPtr<NSButton> m_dockRightButton;
     RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
     String m_urlString;
+    HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
 #elif PLATFORM(GTK)
     WebInspectorClientGtk m_client;
     GtkWidget* m_inspectorView;

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in	2013-05-11 05:03:10 UTC (rev 149923)
@@ -28,6 +28,9 @@
     BringToFront()
     InspectedURLChanged(WTF::String urlString)
 
+    Save(WTF::String filename, WTF::String content, bool forceSaveAs)
+    Append(WTF::String filename, WTF::String content)
+
     AttachBottom()
     AttachRight()
     Detach()

Modified: trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -214,6 +214,16 @@
     notImplemented();
 }
 
+void WebInspectorProxy::platformSave(const String&, const String&, bool)
+{
+    notImplemented();
+}
+
+void WebInspectorProxy::platformAppend(const String&, const String&)
+{
+    notImplemented();
+}
+
 void WebInspectorProxy::platformAttachAvailabilityChanged(bool)
 {
     notImplemented();

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -234,6 +234,16 @@
     notImplemented();
 }
 
+void WebInspectorProxy::platformSave(const String&, const String&, bool)
+{
+    notImplemented();
+}
+
+void WebInspectorProxy::platformAppend(const String&, const String&)
+{
+    notImplemented();
+}
+
 void WebInspectorProxy::platformAttachAvailabilityChanged(bool)
 {
     notImplemented();

Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2013-05-11 05:03:10 UTC (rev 149923)
@@ -37,6 +37,7 @@
 #import "WKRetainPtr.h"
 #import "WKURLCF.h"
 #import "WKViewPrivate.h"
+#import "WebInspectorMessages.h"
 #import "WebPageGroup.h"
 #import "WebPageProxy.h"
 #import "WebPreferences.h"
@@ -541,6 +542,67 @@
     updateInspectorWindowTitle();
 }
 
+void WebInspectorProxy::platformSave(const String& suggestedURL, const String& content, bool forceSaveDialog)
+{
+    ASSERT(!suggestedURL.isEmpty());
+    
+    NSURL *platformURL = m_suggestedToActualURLMap.get(suggestedURL).get();
+    if (!platformURL) {
+        platformURL = [NSURL URLWithString:suggestedURL];
+        // The user must confirm new filenames before we can save to them.
+        forceSaveDialog = true;
+    }
+    
+    ASSERT(platformURL);
+    if (!platformURL)
+        return;
+
+    // Necessary for the block below.
+    String suggestedURLCopy = suggestedURL;
+    String contentCopy = content;
+
+    auto saveToURL = ^(NSURL *actualURL) {
+        ASSERT(actualURL);
+        
+        m_suggestedToActualURLMap.set(suggestedURLCopy, actualURL);
+        [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
+        m_page->process()->send(Messages::WebInspector::DidSave([actualURL absoluteString]), m_page->pageID());
+    };
+
+    if (!forceSaveDialog) {
+        saveToURL(platformURL);
+        return;
+    }
+
+    NSSavePanel *panel = [NSSavePanel savePanel];
+    panel.nameFieldStringValue = platformURL.lastPathComponent;
+    panel.directoryURL = [platformURL URLByDeletingLastPathComponent];
+
+    [panel beginSheetModalForWindow:m_inspectorWindow.get() completionHandler:^(NSInteger result) {
+        if (result == NSFileHandlingPanelCancelButton)
+            return;
+        ASSERT(result == NSFileHandlingPanelOKButton);
+        saveToURL(panel.URL);
+    }];
+}
+
+void WebInspectorProxy::platformAppend(const String& suggestedURL, const String& content)
+{
+    ASSERT(!suggestedURL.isEmpty());
+    
+    RetainPtr<NSURL> actualURL = m_suggestedToActualURLMap.get(suggestedURL);
+    // Do not append unless the user has already confirmed this filename in save().
+    if (!actualURL)
+        return;
+
+    NSFileHandle *handle = [NSFileHandle fileHandleForWritingToURL:actualURL.get() error:NULL];
+    [handle seekToEndOfFile];
+    [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
+    [handle closeFile];
+
+    m_page->process()->send(Messages::WebInspector::DidAppend([actualURL absoluteString]), m_page->pageID());
+}
+
 void WebInspectorProxy::windowFrameDidChange()
 {
     ASSERT(!m_isAttached);

Modified: trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp (149922 => 149923)


--- trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -107,6 +107,16 @@
     notImplemented();
 }
 
+void WebInspectorProxy::platformSave(const String&, const String&, bool)
+{
+    notImplemented();
+}
+
+void WebInspectorProxy::platformAppend(const String&, const String&)
+{
+    notImplemented();
+}
+
 String WebInspectorProxy::inspectorPageURL() const
 {
     notImplemented();

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -61,6 +61,21 @@
     m_page->inspector()->didClose();
 }
 
+bool WebInspectorFrontendClient::canSave()
+{
+    return m_page->inspector()->canSave();
+}
+
+void WebInspectorFrontendClient::save(const String& filename, const String& content, bool forceSaveAs)
+{
+    m_page->inspector()->save(filename, content, forceSaveAs);
+}
+
+void WebInspectorFrontendClient::append(const String& filename, const String& content)
+{
+    m_page->inspector()->append(filename, content);
+}
+
 void WebInspectorFrontendClient::attachWindow(DockSide dockSide)
 {
     switch (dockSide) {

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h	2013-05-11 05:03:10 UTC (rev 149923)
@@ -44,6 +44,10 @@
     virtual void bringToFront() OVERRIDE;
     virtual void closeWindow() OVERRIDE;
 
+    virtual bool canSave() OVERRIDE;
+    virtual void save(const String&, const String&, bool) OVERRIDE;
+    virtual void append(const String&, const String&) OVERRIDE;
+
     virtual void attachWindow(DockSide) OVERRIDE;
     virtual void detachWindow() OVERRIDE;
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -33,10 +33,14 @@
 #include "WebPage.h"
 #include "WebPageCreationParameters.h"
 #include "WebProcess.h"
+#include <WebCore/Frame.h>
 #include <WebCore/InspectorController.h>
 #include <WebCore/InspectorFrontendChannel.h>
 #include <WebCore/InspectorFrontendClient.h>
 #include <WebCore/Page.h>
+#include <WebCore/ScriptController.h>
+#include <WebCore/ScriptValue.h>
+#include <wtf/text/StringConcatenate.h>
 
 using namespace WebCore;
 
@@ -117,6 +121,16 @@
     WebProcess::shared().connection()->send(Messages::WebInspectorProxy::InspectedURLChanged(urlString), m_page->pageID());
 }
 
+void WebInspector::save(const String& filename, const String& content, bool forceSaveAs)
+{
+    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::Save(filename, content, forceSaveAs), m_page->pageID());
+}
+
+void WebInspector::append(const String& filename, const String& content)
+{
+    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::Append(filename, content), m_page->pageID());
+}
+
 void WebInspector::attachBottom()
 {
     WebProcess::shared().connection()->send(Messages::WebInspectorProxy::AttachBottom(), m_page->pageID());
@@ -153,6 +167,18 @@
     m_page->corePage()->inspectorController()->close();
 }
 
+void WebInspector::didSave(const String& url)
+{
+    ASSERT(m_inspectorPage);
+    m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.savedURL(\"", url, "\")"));
+}
+
+void WebInspector::didAppend(const String& url)
+{
+    ASSERT(m_inspectorPage);
+    m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.appendedToURL(\"", url, "\")"));
+}
+
 void WebInspector::attachedBottom()
 {
     if (m_frontendClient)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2013-05-11 05:03:10 UTC (rev 149923)
@@ -57,6 +57,9 @@
     void show();
     void close();
 
+    void didSave(const String& url);
+    void didAppend(const String& url);
+
     void attachedBottom();
     void attachedRight();
     void detached();
@@ -94,6 +97,10 @@
     void bringToFront();
     void inspectedURLChanged(const String&);
 
+    bool canSave() const;
+    void save(const String& filename, const String& content, bool forceSaveAs);
+    void append(const String& filename, const String& content);
+
     void attachBottom();
     void attachRight();
     void detach();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in	2013-05-11 05:03:10 UTC (rev 149923)
@@ -28,6 +28,8 @@
     AttachedBottom()
     AttachedRight()
     Detached()
+    DidSave(WTF::String url)
+    DidAppend(WTF::String url)
     ShowConsole()
     ShowResources()
     ShowMainResourceForFrame(uint64_t frameID)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorEfl.cpp (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorEfl.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorEfl.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -33,6 +33,11 @@
 
 namespace WebKit {
 
+bool WebInspector::canSave() const
+{
+    return false;
+}
+
 String WebInspector::localizedStringsURL() const
 {
     return "file://" + WebCore::inspectorResourcePath() + "/localizedStrings.js";

Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -36,6 +36,11 @@
 
 namespace WebKit {
 
+bool WebInspector::canSave() const
+{
+    return false;
+}
+
 String WebInspector::localizedStringsURL() const
 {
     GOwnPtr<gchar> filePath;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm	2013-05-11 05:03:10 UTC (rev 149923)
@@ -57,6 +57,11 @@
     m_hasLocalizedStringsURL = false;
 }
 
+bool WebInspector::canSave() const
+{
+    return true;
+}
+
 String WebInspector::localizedStringsURL() const
 {
     if (!m_hasLocalizedStringsURL) {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorQt.cpp (149922 => 149923)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorQt.cpp	2013-05-11 01:59:15 UTC (rev 149922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorQt.cpp	2013-05-11 05:03:10 UTC (rev 149923)
@@ -33,6 +33,11 @@
 
 namespace WebKit {
 
+bool WebInspector::canSave() const
+{
+    return false;
+}
+
 String WebInspector::localizedStringsURL() const
 {
     notImplemented();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to