Changeset 84358 in webkit


Ignore:
Timestamp:
Apr 20, 2011 5:27:15 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-04-20 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: add saveAs into the InspectorFrontendHost binding.
https://bugs.webkit.org/show_bug.cgi?id=58979

  • English.lproj/localizedStrings.js:
  • inspector/InspectorFrontendClient.h: (WebCore::InspectorFrontendClient::saveAs): (WebCore::InspectorFrontendClient::saveSessionSetting): (WebCore::InspectorFrontendClient::loadSessionSetting):
  • inspector/InspectorFrontendHost.cpp: (WebCore::InspectorFrontendHost::saveAs):
  • inspector/InspectorFrontendHost.h:
  • inspector/InspectorFrontendHost.idl:
  • inspector/front-end/InspectorFrontendHostStub.js: (.WebInspector.InspectorFrontendHostStub.prototype.saveAs.fr.onload): (.WebInspector.InspectorFrontendHostStub.prototype.saveAs):
  • inspector/front-end/NetworkPanel.js: (WebInspector.NetworkPanel.prototype._contextMenu): (WebInspector.NetworkPanel.prototype._copyAll): (WebInspector.NetworkPanel.prototype._copyResource): (WebInspector.NetworkPanel.prototype._exportAll): (WebInspector.NetworkPanel.prototype._exportResource):
  • inspector/front-end/Settings.js:
  • inspector/front-end/utilities.js: ():

2011-04-20 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: add saveAs into the InspectorFrontendHost binding.
https://bugs.webkit.org/show_bug.cgi?id=58979

  • public/WebDevToolsFrontendClient.h: (WebKit::WebDevToolsFrontendClient::saveAs):
  • src/InspectorFrontendClientImpl.cpp: (WebKit::InspectorFrontendClientImpl::saveAs):
  • src/InspectorFrontendClientImpl.h:
  • src/js/DevTools.js:
Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84357 r84358  
     12011-04-20  Pavel Feldman  <pfeldman@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: add saveAs into the InspectorFrontendHost binding.
     6        https://bugs.webkit.org/show_bug.cgi?id=58979
     7
     8        * English.lproj/localizedStrings.js:
     9        * inspector/InspectorFrontendClient.h:
     10        (WebCore::InspectorFrontendClient::saveAs):
     11        (WebCore::InspectorFrontendClient::saveSessionSetting):
     12        (WebCore::InspectorFrontendClient::loadSessionSetting):
     13        * inspector/InspectorFrontendHost.cpp:
     14        (WebCore::InspectorFrontendHost::saveAs):
     15        * inspector/InspectorFrontendHost.h:
     16        * inspector/InspectorFrontendHost.idl:
     17        * inspector/front-end/InspectorFrontendHostStub.js:
     18        (.WebInspector.InspectorFrontendHostStub.prototype.saveAs.fr.onload):
     19        (.WebInspector.InspectorFrontendHostStub.prototype.saveAs):
     20        * inspector/front-end/NetworkPanel.js:
     21        (WebInspector.NetworkPanel.prototype._contextMenu):
     22        (WebInspector.NetworkPanel.prototype._copyAll):
     23        (WebInspector.NetworkPanel.prototype._copyResource):
     24        (WebInspector.NetworkPanel.prototype._exportAll):
     25        (WebInspector.NetworkPanel.prototype._exportResource):
     26        * inspector/front-end/Settings.js:
     27        * inspector/front-end/utilities.js:
     28        ():
     29
    1302011-04-20  Yury Semikhatsky  <yurys@chromium.org>
    231
  • trunk/Source/WebCore/inspector/InspectorFrontendClient.h

    r81470 r84358  
    5959    virtual void requestDetachWindow() = 0;
    6060    virtual void changeAttachedWindowHeight(unsigned) = 0;
     61    virtual void saveAs(const WTF::String& fileName, const WTF::String& content) { }
    6162
    6263    virtual void inspectedURLChanged(const String&) = 0;
     
    6465    virtual void sendMessageToBackend(const String&) = 0;
    6566
    66     virtual void saveSessionSetting(const String&, const String&) {}
    67     virtual void loadSessionSetting(const String&, String*) {}
     67    virtual void saveSessionSetting(const String&, const String&) { }
     68    virtual void loadSessionSetting(const String&, String*) { }
    6869};
    6970
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp

    r81470 r84358  
    221221}
    222222
     223void InspectorFrontendHost::saveAs(const String& fileName, const String& content)
     224{
     225    if (m_client)
     226        m_client->saveAs(fileName, content);
     227}
     228
    223229void InspectorFrontendHost::saveSessionSetting(const String& key, const String& value)
    224230{
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.h

    r81470 r84358  
    7575
    7676    void copyText(const String& text);
     77    void saveAs(const String& fileName, const String& content);
    7778
    7879    void saveSessionSetting(const String& key, const String& value);
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.idl

    r81470 r84358  
    5252
    5353        void copyText(in DOMString text);
     54        void saveAs(in DOMString fileName, in DOMString content);
    5455
    5556        [Custom] DOMString platform();
  • trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js

    r82106 r84358  
    116116    },
    117117
     118    saveAs: function(fileName, content)
     119    {
     120        var builder = new WebKitBlobBuilder();
     121        builder.append(content);
     122        var blob = builder.getBlob("application/octet-stream");
     123   
     124        var fr = new FileReader();
     125        fr.onload = function(e) {
     126            // Force download
     127            window.location = this.result;
     128        }
     129        fr.readAsDataURL(blob);
     130    },
     131
    118132    canAttachWindow: function()
    119133    {
  • trunk/Source/WebCore/inspector/front-end/NetworkPanel.js

    r83564 r84358  
    998998        var gridNode = this._dataGrid.dataGridNodeFromNode(event.target);
    999999        var resource = gridNode && gridNode._resource;
     1000
    10001001        if (resource)
    1001             contextMenu.appendItem(WebInspector.UIString("Copy entry as HAR"), this._exportResource.bind(this, resource));
    1002         contextMenu.appendItem(WebInspector.UIString("Copy network log as HAR"), this._exportAll.bind(this));
     1002            contextMenu.appendItem(WebInspector.UIString("Copy entry as HAR"), this._copyResource.bind(this, resource));
     1003        contextMenu.appendItem(WebInspector.UIString("Copy all as HAR"), this._copyAll.bind(this));
     1004
     1005        if (Preferences.saveAsAvailable) {
     1006            contextMenu.appendSeparator();
     1007            if (resource)
     1008                contextMenu.appendItem(WebInspector.UIString("Save entry as HAR"), this._exportResource.bind(this, resource));
     1009            contextMenu.appendItem(WebInspector.UIString("Save all as HAR"), this._exportAll.bind(this));
     1010        }
     1011
    10031012        contextMenu.show(event);
    10041013    },
    10051014
    1006     _exportAll: function()
     1015    _copyAll: function()
    10071016    {
    10081017        var harArchive = {
    10091018            log: (new WebInspector.HARLog()).build()
    1010         }
     1019        };
    10111020        InspectorFrontendHost.copyText(JSON.stringify(harArchive));
    10121021    },
    10131022
    1014     _exportResource: function(resource)
     1023    _copyResource: function(resource)
    10151024    {
    10161025        var har = (new WebInspector.HAREntry(resource)).build();
    10171026        InspectorFrontendHost.copyText(JSON.stringify(har));
     1027    },
     1028
     1029    _exportAll: function()
     1030    {
     1031        var harArchive = {
     1032            log: (new WebInspector.HARLog()).build()
     1033        };
     1034        InspectorFrontendHost.saveAs(WebInspector.mainResource.domain + ".har", JSON.stringify(harArchive));
     1035    },
     1036
     1037    _exportResource: function(resource)
     1038    {
     1039        var har = (new WebInspector.HAREntry(resource)).build();
     1040        InspectorFrontendHost.saveAs(resource.displayName + ".har", JSON.stringify(har));
    10181041    },
    10191042
  • trunk/Source/WebCore/inspector/front-end/Settings.js

    r83864 r84358  
    5050    debugMode: false,
    5151    heapProfilerPresent: false,
    52     detailedHeapProfiles: false
     52    detailedHeapProfiles: false,
     53    saveAsAvailable: false
    5354}
    5455
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r83864 r84358  
    10751075    return new RegExp(regex, "i" + (extraFlags || ""));
    10761076}
    1077 
    1078 function offerFileForDownload(contents)
    1079 {
    1080     var builder = new BlobBuilder();
    1081     builder.append(contents);
    1082     var blob = builder.getBlob("application/octet-stream");
    1083     var url = window.webkitURL.createObjectURL(blob);
    1084     window.open(url);
    1085 }
  • trunk/Source/WebKit/chromium/ChangeLog

    r84342 r84358  
     12011-04-20  Pavel Feldman  <pfeldman@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: add saveAs into the InspectorFrontendHost binding.
     6        https://bugs.webkit.org/show_bug.cgi?id=58979
     7
     8        * public/WebDevToolsFrontendClient.h:
     9        (WebKit::WebDevToolsFrontendClient::saveAs):
     10        * src/InspectorFrontendClientImpl.cpp:
     11        (WebKit::InspectorFrontendClientImpl::saveAs):
     12        * src/InspectorFrontendClientImpl.h:
     13        * src/js/DevTools.js:
     14
    1152011-04-19  Naoki Takano  <takano.naoki@gmail.com>
    216
  • trunk/Source/WebKit/chromium/public/WebDevToolsFrontendClient.h

    r64729 r84358  
    5050    virtual void requestDockWindow() { }
    5151    virtual void requestUndockWindow() { }
     52    virtual void saveAs(const WebString& fileName, const WebString& content) { }
    5253
    5354    virtual bool shouldHideScriptsPanel() { return false; }
  • trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp

    r66720 r84358  
    126126}
    127127   
     128void InspectorFrontendClientImpl::saveAs(const String& fileName, const String& content)
     129{
     130    m_client->saveAs(fileName, content);
     131}
     132
    128133void InspectorFrontendClientImpl::inspectedURLChanged(const String& url)
    129134{
  • trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h

    r76248 r84358  
    6767    virtual void requestDetachWindow();
    6868    virtual void changeAttachedWindowHeight(unsigned);
     69    virtual void saveAs(const WTF::String& fileName, const WTF::String& content);
    6970
    7071    virtual void inspectedURLChanged(const WTF::String&);
  • trunk/Source/WebKit/chromium/src/js/DevTools.js

    r84254 r84358  
    5151    Preferences.showTimingTab = true;
    5252    Preferences.showCookiesTab = true;
     53    Preferences.saveAsAvailable = true;
    5354})();
    5455
Note: See TracChangeset for help on using the changeset viewer.