Changeset 292084 in webkit


Ignore:
Timestamp:
Mar 29, 2022 5:12:28 PM (4 months ago)
Author:
Devin Rousso
Message:

Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
https://bugs.webkit.org/show_bug.cgi?id=238236
<rdar://problem/59009154>

Reviewed by Patrick Angle.

Source/WebCore:

This makes Response Local Overrides even more powerful by allowing developers to map the
contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
meaning that they can use their preferred editor of choice (and all the tools that may come
with it) to make changes instead of having to stay within Web Inspector.

Test: http/tests/inspector/network/local-resource-override-mapped-to-file.html

  • inspector/InspectorFrontendHost.idl:
  • inspector/InspectorFrontendHost.h:
  • inspector/InspectorFrontendHost.cpp:

(WebCore::InspectorFrontendHost::canLoad): Added.
(WebCore::InspectorFrontendHost::load): Added.
(WebCore::InspectorFrontendHost::getPath): Added.
Add helpers for loading the contents of a file on disk and getting the full path of a File.

  • inspector/InspectorFrontendClient.h:
  • inspector/InspectorFrontendClientLocal.h:

(WebCore::InspectorFrontendClientLocal::canLoad): Added.
(WebCore::InspectorFrontendClientLocal::load): Added.
Do not allow file mapping in tests (and WK1).

  • testing/Internals.idl:
  • testing/Internals.h:
  • testing/Internals.cpp:

(WebCore::Internals::createTemporaryFile): Added.
Add a way for tests to create a temporary file with given contents.

Source/WebInspectorUI:

This makes Response Local Overrides even more powerful by allowing developers to map the
contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
meaning that they can use their preferred editor of choice (and all the tools that may come
with it) to make changes instead of having to stay within Web Inspector.

  • UserInterface/Models/LocalResource.js:

(WI.LocalResource):
(WI.LocalResource.canMapToFile): Added.
(WI.LocalResource.prototype.toJSON):
(WI.LocalResource.prototype.get mappedFilePath): Added.
(WI.LocalResource.prototype.set mappedFilePath): Added.
(WI.LocalResource.prototype.async requestContent):
(WI.LocalResource.prototype.async _loadFromFileSystem): Added.

  • UserInterface/Models/LocalResourceOverride.js:

(WI.LocalResourceOverride.prototype.get canMapToFile): Added.
Save the given local file path as a member variable and use InspectorFrontendHost.load to
grab its contents (saving it inside the WI.LocalResource so that it can still be used in
case the file is moved/deleted) whenever anyone requestContent.

  • UserInterface/Views/ResourceContentView.js:

(WI.ResourceContentView):
(WI.ResourceContentView.prototype.get navigationItems):
(WI.ResourceContentView.prototype.showMessage):
(WI.ResourceContentView.prototype.addIssue):
(WI.ResourceContentView.prototype._contentAvailable):
(WI.ResourceContentView.prototype.async _handleMapLocalResourceOverrideToFile): Added.
(WI.ResourceContentView.prototype._handleMappedFilePathChanged): Added.
Add a new "[Disk.svg] Map to File" navigation item when viewing Response Local Overrides. If
the Response Local Override has already been mapped to a file, show the path of the file
instead of the contents of the resource. This allows us to not have to monitor the file for
changes, instead only grabbing the current contents when necessary (i.e. when replacing the
response of an intercepted network request).

  • UserInterface/Views/ResourceContentView.css: Added.

(.content-view.resource > .local-resource-override-label-view + .message-text-view):
Still show the Local Override banner if the Local Override has been mapped to a file.

  • UserInterface/Views/TextResourceContentView.js:

(WI.TextResourceContentView.prototype._contentWillPopulate):
Don't show the WI.SourceCodeTextEditor if there's already something else being shown.

  • UserInterface/Controllers/NetworkManager.js:

(WI.NetworkManager.prototype.async requestIntercepted):
(WI.NetworkManager.prototype.async responseIntercepted):
Make sure to requestContent before using the currentRevision so that any file-mapped
WI.LocalResource have a chance to load from disk before handling the interception.

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Main.html:
  • UserInterface/Images/Disk.svg: Added.

Source/WebKit:

This makes Response Local Overrides even more powerful by allowing developers to map the
contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
meaning that they can use their preferred editor of choice (and all the tools that may come
with it) to make changes instead of having to stay within Web Inspector.

  • WebProcess/Inspector/WebInspectorUI.h:
  • WebProcess/Inspector/WebInspectorUI.cpp:

(WebKit::WebInspectorUI::load): Added.
(WebKit::WebInspectorUI::canLoad): Added.

  • WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp:

(WebKit::WebInspectorUI::canLoad): Added.

  • WebProcess/Inspector/mac/WebInspectorUIMac.mm:

(WebKit::WebInspectorUI::canLoad): Added.

  • WebProcess/Inspector/win/WebInspectorUIWin.cpp:

(WebKit::WebInspectorUI::canLoad): Added.

  • WebProcess/Inspector/RemoteWebInspectorUI.h:
  • WebProcess/Inspector/RemoteWebInspectorUI.cpp:

(WebKit::RemoteWebInspectorUI::load): Added.

  • UIProcess/Inspector/WebInspectorUIProxy.messages.in:
  • UIProcess/Inspector/WebInspectorUIProxy.h:
  • UIProcess/Inspector/WebInspectorUIProxy.cpp:

(WebKit::WebInspectorUIProxy::load): Added.
(WebKit::WebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp:

(WebKit::WebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:

(WebKit::WebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp:

(WebKit::WebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in:
  • UIProcess/Inspector/RemoteWebInspectorUIProxy.h:
  • UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp:

(WebKit::RemoteWebInspectorUIProxy::initialize): Renamed from load.
(WebKit::RemoteWebInspectorUIProxy::reopen):
(WebKit::RemoteWebInspectorUIProxy::load): Added.
(WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp:

(WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm:

(WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.

  • UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp:

(WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.
Add helpers for loading the contents of a file on disk.

  • UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:

(-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:]):

  • UIProcess/Inspector/glib/RemoteInspectorClient.cpp:

(WebKit::RemoteInspectorProxy::initialize): Renamed from load.
(WebKit::RemoteInspectorClient::inspect):

  • UIProcess/Inspector/socket/RemoteInspectorClient.cpp:

(WebKit::RemoteInspectorProxy::initialize): Renamed from load.
(WebKit::RemoteInspectorClient::inspect):
Use renamed WebKit::RemoteWebInspectorUIProxy::initialize.

LayoutTests:

  • http/tests/inspector/network/local-resource-override-mapped-to-file.html: Added.
  • http/tests/inspector/network/local-resource-override-mapped-to-file-expected.txt: Added.
  • TestExpectations:
  • platform/mac-wk1/TestExpectations:
  • platform/mac-wk2/TestExpectations:

Skip this test everywhere except mac-wk2.

Location:
trunk
Files:
3 added
44 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r292079 r292084  
     12022-03-29  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
     4        https://bugs.webkit.org/show_bug.cgi?id=238236
     5        <rdar://problem/59009154>
     6
     7        Reviewed by Patrick Angle.
     8
     9        * http/tests/inspector/network/local-resource-override-mapped-to-file.html: Added.
     10        * http/tests/inspector/network/local-resource-override-mapped-to-file-expected.txt: Added.
     11
     12        * TestExpectations:
     13        * platform/mac-wk1/TestExpectations:
     14        * platform/mac-wk2/TestExpectations:
     15        Skip this test everywhere except mac-wk2.
     16
    1172022-03-29  Matt Woodrow  <mattwoodrow@apple.com>
    218
  • trunk/LayoutTests/TestExpectations

    r292079 r292084  
    12431243inspector/page/overrideSetting-PrivateClickMeasurementDebugModeEnabled.html [ Skip ]
    12441244inspector/page/overrideSetting-ITPDebugModeEnabled.html [ Skip ]
     1245
     1246# Network interception with a mapped file is only mac-wk2 for now.
     1247http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Skip ]
    12451248
    12461249# These conformance tests are no longer in sync with the latest specification
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r291948 r292084  
    926926http/tests/inspector/network/local-resource-override-basic.html [ Skip ]
    927927http/tests/inspector/network/local-resource-override-main-resource.html [ Skip ]
     928http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Skip ]
    928929http/tests/inspector/network/local-resource-override-script-tag.html [ Skip ]
    929930http/tests/inspector/network/resource-response-inspector-override.html [ Skip ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r291948 r292084  
    692692[ Mojave Catalina ] accessibility/mac/isolated-tree-mode-on-off.html [ Skip ]
    693693
     694# Network interception with a mapped file is only mac-wk2 for now.
     695http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Pass ]
     696
    694697# Content Extensions tests must be enabled explicitly on mac-wk2.
    695698http/tests/contentextensions [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r292079 r292084  
     12022-03-29  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
     4        https://bugs.webkit.org/show_bug.cgi?id=238236
     5        <rdar://problem/59009154>
     6
     7        Reviewed by Patrick Angle.
     8
     9        This makes Response Local Overrides even more powerful by allowing developers to map the
     10        contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
     11        meaning that they can use their preferred editor of choice (and all the tools that may come
     12        with it) to make changes instead of having to stay within Web Inspector.
     13
     14        Test: http/tests/inspector/network/local-resource-override-mapped-to-file.html
     15
     16        * inspector/InspectorFrontendHost.idl:
     17        * inspector/InspectorFrontendHost.h:
     18        * inspector/InspectorFrontendHost.cpp:
     19        (WebCore::InspectorFrontendHost::canLoad): Added.
     20        (WebCore::InspectorFrontendHost::load): Added.
     21        (WebCore::InspectorFrontendHost::getPath): Added.
     22        Add helpers for loading the contents of a file on disk and getting the full path of a `File`.
     23
     24        * inspector/InspectorFrontendClient.h:
     25        * inspector/InspectorFrontendClientLocal.h:
     26        (WebCore::InspectorFrontendClientLocal::canLoad): Added.
     27        (WebCore::InspectorFrontendClientLocal::load): Added.
     28        Do not allow file mapping in tests (and WK1).
     29
     30        * testing/Internals.idl:
     31        * testing/Internals.h:
     32        * testing/Internals.cpp:
     33        (WebCore::Internals::createTemporaryFile): Added.
     34        Add a way for tests to create a temporary file with given contents.
     35
    1362022-03-29  Matt Woodrow  <mattwoodrow@apple.com>
    237
  • trunk/Source/WebCore/inspector/InspectorFrontendClient.h

    r288999 r292084  
    110110    virtual void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) = 0;
    111111    virtual void append(const String& url, const String& content) = 0;
     112    virtual bool canLoad() = 0;
     113    virtual void load(const String& path, CompletionHandler<void(const String&)>&&) = 0;
    112114
    113115    virtual void inspectedURLChanged(const String&) = 0;
  • trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h

    r278253 r292084  
    8484    void save(const String&, const String&, bool, bool) override { }
    8585    void append(const String&, const String&) override { }
     86    bool canLoad()  override { return false; }
     87    void load(const String&, CompletionHandler<void(const String&)>&& completionHandler) override { completionHandler(nullString()); }
    8688
    8789    virtual void attachWindow(DockSide) = 0;
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp

    r291992 r292084  
    4040#include "Editor.h"
    4141#include "Event.h"
     42#include "File.h"
    4243#include "FloatRect.h"
    4344#include "FocusController.h"
     
    5051#include "JSDOMConvertInterface.h"
    5152#include "JSDOMExceptionHandling.h"
     53#include "JSDOMPromiseDeferred.h"
    5254#include "JSExecState.h"
    5355#include "JSInspectorFrontendHost.h"
     
    461463}
    462464
     465bool InspectorFrontendHost::canLoad()
     466{
     467    if (m_client)
     468        return m_client->canLoad();
     469    return false;
     470}
     471
     472void InspectorFrontendHost::load(const String& path, Ref<DeferredPromise>&& promise)
     473{
     474    if (!m_client) {
     475        promise->reject(InvalidStateError);
     476        return;
     477    }
     478
     479    m_client->load(path, [promise = WTFMove(promise)](const String& content) {
     480        if (!content)
     481            promise->reject(NotFoundError);
     482        else
     483            promise->resolve<IDLDOMString>(content);
     484    });
     485}
     486
    463487void InspectorFrontendHost::close(const String&)
    464488{
     489}
     490
     491String InspectorFrontendHost::getPath(const File& file)
     492{
     493    return file.path();
    465494}
    466495
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.h

    r288999 r292084  
    3939
    4040class DOMWrapperWorld;
     41class DeferredPromise;
    4142class Event;
     43class File;
    4244class FrontendMenuProvider;
    4345class HTMLIFrameElement;
     
    110112    void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
    111113    void append(const String& url, const String& content);
     114    bool canLoad();
     115    void load(const String& path, Ref<DeferredPromise>&&);
    112116    void close(const String& url);
     117
     118    String getPath(const File&);
    113119
    114120    struct ContextMenuItem {
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.idl

    r288999 r292084  
    7575    undefined save(DOMString url, DOMString content, boolean base64Encoded, boolean forceSaveAs);
    7676    undefined append(DOMString url, DOMString content);
     77    boolean canLoad();
     78    [NewObject] Promise<DOMString> load(DOMString path);
    7779    undefined close(DOMString url);
     80
     81    DOMString getPath(File file);
    7882
    7983    readonly attribute DOMString port;
  • trunk/Source/WebCore/testing/Internals.cpp

    r292027 r292084  
    235235#include <JavaScriptCore/JSCInlines.h>
    236236#include <JavaScriptCore/JSCJSValue.h>
     237#include <wtf/FileSystem.h>
    237238#include <wtf/HexNumber.h>
    238239#include <wtf/JSONValues.h>
     
    48724873}
    48734874
     4875String Internals::createTemporaryFile(const String& name, const String& contents)
     4876{
     4877    if (name.isEmpty())
     4878        return nullString();
     4879
     4880    auto file = FileSystem::invalidPlatformFileHandle;
     4881    auto path = FileSystem::openTemporaryFile(makeString("WebCoreTesting-", name), file);
     4882    if (!FileSystem::isHandleValid(file))
     4883        return nullString();
     4884
     4885    auto contentsUTF8 = contents.utf8();
     4886    FileSystem::writeToFile(file, contentsUTF8.data(), contentsUTF8.length());
     4887
     4888    FileSystem::closeFile(file);
     4889
     4890    return path;
     4891}
     4892
    48744893void Internals::queueMicroTask(int testNumber)
    48754894{
  • trunk/Source/WebCore/testing/Internals.h

    r291846 r292084  
    777777
    778778    RefPtr<File> createFile(const String&);
     779    String createTemporaryFile(const String& name, const String& contents);
     780
    779781    void queueMicroTask(int);
    780782    bool testPreloaderSettingViewport();
  • trunk/Source/WebCore/testing/Internals.idl

    r291846 r292084  
    843843
    844844    File? createFile(DOMString url);
     845    DOMString createTemporaryFile(DOMString name, DOMString contents);
     846
    845847    undefined queueMicroTask(long testNumber);
    846848    boolean testPreloaderSettingViewport();
  • trunk/Source/WebInspectorUI/ChangeLog

    r292037 r292084  
     12022-03-29  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
     4        https://bugs.webkit.org/show_bug.cgi?id=238236
     5        <rdar://problem/59009154>
     6
     7        Reviewed by Patrick Angle.
     8
     9        This makes Response Local Overrides even more powerful by allowing developers to map the
     10        contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
     11        meaning that they can use their preferred editor of choice (and all the tools that may come
     12        with it) to make changes instead of having to stay within Web Inspector.
     13
     14        * UserInterface/Models/LocalResource.js:
     15        (WI.LocalResource):
     16        (WI.LocalResource.canMapToFile): Added.
     17        (WI.LocalResource.prototype.toJSON):
     18        (WI.LocalResource.prototype.get mappedFilePath): Added.
     19        (WI.LocalResource.prototype.set mappedFilePath): Added.
     20        (WI.LocalResource.prototype.async requestContent):
     21        (WI.LocalResource.prototype.async _loadFromFileSystem): Added.
     22        * UserInterface/Models/LocalResourceOverride.js:
     23        (WI.LocalResourceOverride.prototype.get canMapToFile): Added.
     24        Save the given local file path as a member variable and use `InspectorFrontendHost.load` to
     25        grab its contents (saving it inside the `WI.LocalResource` so that it can still be used in
     26        case the file is moved/deleted) whenever anyone `requestContent`.
     27
     28        * UserInterface/Views/ResourceContentView.js:
     29        (WI.ResourceContentView):
     30        (WI.ResourceContentView.prototype.get navigationItems):
     31        (WI.ResourceContentView.prototype.showMessage):
     32        (WI.ResourceContentView.prototype.addIssue):
     33        (WI.ResourceContentView.prototype._contentAvailable):
     34        (WI.ResourceContentView.prototype.async _handleMapLocalResourceOverrideToFile): Added.
     35        (WI.ResourceContentView.prototype._handleMappedFilePathChanged): Added.
     36        Add a new "[Disk.svg] Map to File" navigation item when viewing Response Local Overrides. If
     37        the Response Local Override has already been mapped to a file, show the path of the file
     38        instead of the contents of the resource. This allows us to not have to monitor the file for
     39        changes, instead only grabbing the current contents when necessary (i.e. when replacing the
     40        response of an intercepted network request).
     41
     42        * UserInterface/Views/ResourceContentView.css: Added.
     43        (.content-view.resource > .local-resource-override-label-view + .message-text-view):
     44        Still show the Local Override banner if the Local Override has been mapped to a file.
     45
     46        * UserInterface/Views/TextResourceContentView.js:
     47        (WI.TextResourceContentView.prototype._contentWillPopulate):
     48        Don't show the `WI.SourceCodeTextEditor` if there's already something else being shown.
     49
     50        * UserInterface/Controllers/NetworkManager.js:
     51        (WI.NetworkManager.prototype.async requestIntercepted):
     52        (WI.NetworkManager.prototype.async responseIntercepted):
     53        Make sure to `requestContent` before using the `currentRevision` so that any file-mapped
     54        `WI.LocalResource` have a chance to load from disk before handling the interception.
     55
     56        * Localizations/en.lproj/localizedStrings.js:
     57        * UserInterface/Main.html:
     58        * UserInterface/Images/Disk.svg: Added.
     59
    1602022-03-29  Patrick Angle  <pangle@apple.com>
    261
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r292037 r292084  
    890890localizedStrings["Local File"] = "Local File";
    891891localizedStrings["Local Override"] = "Local Override";
     892localizedStrings["Local Override: could not load \u201C%s\u201D"] = "Local Override: could not load \u201C%s\u201D";
    892893localizedStrings["Local Override\u2026"] = "Local Override\u2026";
    893894localizedStrings["Local Overrides"] = "Local Overrides";
     
    923924localizedStrings["Main: %s"] = "Main: %s";
    924925localizedStrings["Manifest URL"] = "Manifest URL";
     926localizedStrings["Map to File"] = "Map to File";
     927localizedStrings["Mapped to \u201C%s\u201D"] = "Mapped to \u201C%s\u201D";
    925928localizedStrings["Mass"] = "Mass";
    926929localizedStrings["Matching"] = "Matching";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js

    r270604 r292084  
    947947    }
    948948
    949     requestIntercepted(target, requestId, request)
     949    async requestIntercepted(target, requestId, request)
    950950    {
    951951        let url = WI.urlWithoutFragment(request.url);
     
    955955
    956956            let localResource = localResourceOverride.localResource;
     957            await localResource.requestContent();
     958
    957959            let revision = localResource.currentRevision;
    958960
     
    993995    }
    994996
    995     responseIntercepted(target, requestId, response)
     997    async responseIntercepted(target, requestId, response)
    996998    {
    997999        let url = WI.urlWithoutFragment(response.url);
     
    10011003
    10021004            let localResource = localResourceOverride.localResource;
     1005            await localResource.requestContent();
     1006
    10031007            let revision = localResource.currentRevision;
    10041008
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r291093 r292084  
    195195    <link rel="stylesheet" href="Views/Resizer.css">
    196196    <link rel="stylesheet" href="Views/ResourceCollectionContentView.css">
     197    <link rel="stylesheet" href="Views/ResourceContentView.css">
    197198    <link rel="stylesheet" href="Views/ResourceCookiesContentView.css">
    198199    <link rel="stylesheet" href="Views/ResourceDetailsSection.css">
  • trunk/Source/WebInspectorUI/UserInterface/Models/LocalResource.js

    r292037 r292084  
    3737WI.LocalResource = class LocalResource extends WI.Resource
    3838{
    39     constructor({request, response, metrics, timing})
     39    constructor({request, response, metrics, timing, mappedFilePath})
    4040    {
    4141        console.assert(request);
     
    8888        this._originalRevision = new WI.SourceCodeRevision(this, content, base64Encoded, this._mimeType);
    8989        this._currentRevision = this._originalRevision;
     90
     91        this._mappedFilePath = mappedFilePath || null;
    9092    }
    9193
    9294    // Static
     95
     96    static canMapToFile()
     97    {
     98        return InspectorFrontendHost.canLoad();
     99    }
    93100
    94101    static headersArrayToHeadersObject(headers)
     
    228235                base64Encoded: this.currentRevision.base64Encoded,
    229236            },
     237            mappedFilePath: this._mappedFilePath,
    230238        };
    231239    }
     
    235243    get localResourceOverride() { return this._localResourceOverride; }
    236244
     245    get mappedFilePath()
     246    {
     247        return this._mappedFilePath;
     248    }
     249
     250    set mappedFilePath(mappedFilePath)
     251    {
     252        console.assert(WI.LocalResource.canMapToFile());
     253        console.assert(mappedFilePath);
     254
     255        if (mappedFilePath === this._mappedFilePath)
     256            return;
     257
     258        this._mappedFilePath = mappedFilePath;
     259
     260        const forceUpdate = true;
     261        this._loadFromFileSystem(forceUpdate).then(() => {
     262            this.dispatchEventToListeners(WI.LocalResource.Event.MappedFilePathChanged);
     263        });
     264    }
     265
    237266    // Protected
     267
     268    async requestContent()
     269    {
     270        await this._loadFromFileSystem();
     271
     272        return super.requestContent();
     273    }
    238274
    239275    requestContentFromBackend()
     
    253289        }
    254290    }
     291
     292    // Private
     293
     294    async _loadFromFileSystem(forceUpdate)
     295    {
     296        if (!this._mappedFilePath)
     297            return;
     298
     299        let content = "";
     300        try {
     301            content = await InspectorFrontendHost.load(this._mappedFilePath);
     302        } catch {
     303            if (this._didWarnAboutFailureToLoadFromFileSystem)
     304                return;
     305
     306            this._didWarnAboutFailureToLoadFromFileSystem = true;
     307            setTimeout(() => {
     308                this._didWarnAboutFailureToLoadFromFileSystem = false;
     309            });
     310
     311            let message = WI.UIString("Local Override: could not load \u201C%s\u201D").format(this._mappedFilePath);
     312
     313            if (window.InspectorTest) {
     314                console.warn(message);
     315                return;
     316            }
     317
     318            let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Warning, message);
     319            consoleMessage.shouldRevealConsole = true;
     320
     321            WI.consoleLogViewController.appendConsoleMessage(consoleMessage);
     322            return;
     323        }
     324
     325        if (!forceUpdate && content === this.currentRevision.content)
     326            return;
     327
     328        this.editableRevision.updateRevisionContent(content);
     329    }
    255330};
     331
     332WI.LocalResource.Event = {
     333    MappedFilePathChanged: "local-resource-mapped-file-path-changed",
     334};
  • trunk/Source/WebInspectorUI/UserInterface/Models/LocalResourceOverride.js

    r270604 r292084  
    165165    }
    166166
     167    get canMapToFile()
     168    {
     169        if (!WI.LocalResource.canMapToFile())
     170            return false;
     171
     172        switch (this._type) {
     173        case WI.LocalResourceOverride.InterceptType.Request:
     174            return false;
     175
     176        case WI.LocalResourceOverride.InterceptType.Response:
     177        case WI.LocalResourceOverride.InterceptType.ResponseSkippingNetwork:
     178            return true;
     179        }
     180
     181        console.assert(false, "not reached");
     182        return false;
     183    }
     184
    167185    matches(url)
    168186    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.css

    r292083 r292084  
    11/*
    2  * Copyright (C) 2017 Sony Interactive Entertainment Inc.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "WebInspectorUI.h"
    28 
    29 #include "RemoteWebInspectorUI.h"
    30 
    31 #include <WebCore/WebCoreBundleWin.h>
    32 #include <wtf/FileSystem.h>
    33 #include <wtf/text/WTFString.h>
    34 
    35 namespace WebKit {
    36 
    37 bool WebInspectorUI::canSave()
    38 {
    39     return false;
     26.content-view.resource > .local-resource-override-label-view + .message-text-view {
     27    top: var(--navigation-bar-height);
    4028}
    41 
    42 String WebInspectorUI::localizedStringsURL() const
    43 {
    44     return "inspector-resource:///localizedStrings.js"_s;
    45 }
    46 
    47 String RemoteWebInspectorUI::localizedStringsURL() const
    48 {
    49     return "inspector-resource:///localizedStrings.js"_s;
    50 }
    51 
    52 } // namespace WebKit
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js

    r276144 r292084  
    3838
    3939        this._spinnerTimeout = setTimeout(() => {
    40             // Append a spinner while waiting for contentAvailable. Subclasses are responsible for
    41             // removing the spinner before showing the resource content by calling removeLoadingIndicator.
    42             let spinner = new WI.IndeterminateProgressSpinner;
    43             this.element.appendChild(spinner.element);
     40            if (!this._hasContent()) {
     41                // Append a spinner while waiting for contentAvailable. Subclasses are responsible for
     42                // removing the spinner before showing the resource content by calling removeLoadingIndicator.
     43                let spinner = new WI.IndeterminateProgressSpinner;
     44                this.element.appendChild(spinner.element);
     45            }
    4446
    4547            this._spinnerTimeout = undefined;
     
    6769                this._importLocalResourceOverrideButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
    6870                this._importLocalResourceOverrideButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleImportLocalResourceOverride, this);
     71
     72                if (resource.localResourceOverride.canMapToFile) {
     73                    this._mapLocalResourceOverrideToFileButtonNavigationItem = new WI.ButtonNavigationItem("map-local-resource-override", WI.UIString("Map to File"), "Images/Disk.svg", 15, 15);
     74                    this._mapLocalResourceOverrideToFileButtonNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
     75                    this._mapLocalResourceOverrideToFileButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
     76                    this._mapLocalResourceOverrideToFileButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleMapLocalResourceOverrideToFile, this);
     77
     78                    resource.addEventListener(WI.LocalResource.Event.MappedFilePathChanged, this._handleMappedFilePathChanged, this);
     79                }
    6980
    7081                this._removeLocalResourceOverrideButtonNavigationItem = new WI.ButtonNavigationItem("remove-local-resource-override", WI.UIString("Delete Local Override"), "Images/NavigationItemTrash.svg", 15, 15);
     
    97108
    98109        if (this._importLocalResourceOverrideButtonNavigationItem)
    99             items.push(this._importLocalResourceOverrideButtonNavigationItem, new WI.DividerNavigationItem);
     110            items.push(this._importLocalResourceOverrideButtonNavigationItem);
     111        if (this._mapLocalResourceOverrideToFileButtonNavigationItem)
     112            items.push(this._mapLocalResourceOverrideToFileButtonNavigationItem);
     113
     114        if (items.length)
     115            items.push(new WI.DividerNavigationItem);
     116
    100117        if (this._removeLocalResourceOverrideButtonNavigationItem)
    101118            items.push(this._removeLocalResourceOverrideButtonNavigationItem);
     
    173190    showMessage(message)
    174191    {
    175         this.element.removeChildren();
     192        this.removeAllSubviews();
     193
    176194        this.element.appendChild(WI.createMessageTextView(message));
    177195    }
     
    180198    {
    181199        // This generically shows only the last issue, subclasses can override for better handling.
    182         this.element.removeChildren();
     200        this.removeAllSubviews();
     201
    183202        this.element.appendChild(WI.createMessageTextView(issue.text, issue.level === WI.IssueMessage.Level.Error));
    184203    }
     
    230249            this.showMessage(parameters.message);
    231250            return;
     251        }
     252
     253        if (parameters.sourceCode instanceof WI.LocalResource) {
     254            if (this.resource.mappedFilePath) {
     255                this._handleMappedFilePathChanged();
     256                return;
     257            }
    232258        }
    233259
     
    348374    }
    349375
     376    _handleMapLocalResourceOverrideToFile(event)
     377    {
     378        WI.FileUtilities.import((files) => {
     379            console.assert(files.length === 1, files);
     380
     381            this.resource.mappedFilePath = InspectorFrontendHost.getPath(files[0]);
     382        });
     383    }
     384
     385    _handleMappedFilePathChanged(event)
     386    {
     387        this.showMessage(WI.UIString("Mapped to \u201C%s\u201D").format(this.resource.mappedFilePath));
     388
     389        if (this._localResourceOverrideBannerView) {
     390            this.element.insertBefore(this._localResourceOverrideBannerView.element, this.element.firstChild);
     391            this.addSubview(this._localResourceOverrideBannerView);
     392        }
     393    }
     394
    350395    _handleRemoveLocalResourceOverride(event)
    351396    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js

    r270604 r292084  
    224224            return;
    225225
     226        if (this._hasContent())
     227            return;
     228
    226229        this.removeLoadingIndicator();
    227230
  • trunk/Source/WebKit/ChangeLog

    r292081 r292084  
     12022-03-29  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
     4        https://bugs.webkit.org/show_bug.cgi?id=238236
     5        <rdar://problem/59009154>
     6
     7        Reviewed by Patrick Angle.
     8
     9        This makes Response Local Overrides even more powerful by allowing developers to map the
     10        contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file),
     11        meaning that they can use their preferred editor of choice (and all the tools that may come
     12        with it) to make changes instead of having to stay within Web Inspector.
     13
     14        * WebProcess/Inspector/WebInspectorUI.h:
     15        * WebProcess/Inspector/WebInspectorUI.cpp:
     16        (WebKit::WebInspectorUI::load): Added.
     17        (WebKit::WebInspectorUI::canLoad): Added.
     18        * WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp:
     19        (WebKit::WebInspectorUI::canLoad): Added.
     20        * WebProcess/Inspector/mac/WebInspectorUIMac.mm:
     21        (WebKit::WebInspectorUI::canLoad): Added.
     22        * WebProcess/Inspector/win/WebInspectorUIWin.cpp:
     23        (WebKit::WebInspectorUI::canLoad): Added.
     24        * WebProcess/Inspector/RemoteWebInspectorUI.h:
     25        * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
     26        (WebKit::RemoteWebInspectorUI::load): Added.
     27        * UIProcess/Inspector/WebInspectorUIProxy.messages.in:
     28        * UIProcess/Inspector/WebInspectorUIProxy.h:
     29        * UIProcess/Inspector/WebInspectorUIProxy.cpp:
     30        (WebKit::WebInspectorUIProxy::load): Added.
     31        (WebKit::WebInspectorUIProxy::platformLoad): Added.
     32        * UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp:
     33        (WebKit::WebInspectorUIProxy::platformLoad): Added.
     34        * UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
     35        (WebKit::WebInspectorUIProxy::platformLoad): Added.
     36        * UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp:
     37        (WebKit::WebInspectorUIProxy::platformLoad): Added.
     38        * UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in:
     39        * UIProcess/Inspector/RemoteWebInspectorUIProxy.h:
     40        * UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp:
     41        (WebKit::RemoteWebInspectorUIProxy::initialize): Renamed from `load`.
     42        (WebKit::RemoteWebInspectorUIProxy::reopen):
     43        (WebKit::RemoteWebInspectorUIProxy::load): Added.
     44        (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.
     45        * UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp:
     46        (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.
     47        * UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm:
     48        (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.
     49        * UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp:
     50        (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added.
     51        Add helpers for loading the contents of a file on disk.
     52
     53        * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
     54        (-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:]):
     55        * UIProcess/Inspector/glib/RemoteInspectorClient.cpp:
     56        (WebKit::RemoteInspectorProxy::initialize): Renamed from `load`.
     57        (WebKit::RemoteInspectorClient::inspect):
     58        * UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
     59        (WebKit::RemoteInspectorProxy::initialize): Renamed from `load`.
     60        (WebKit::RemoteInspectorClient::inspect):
     61        Use renamed `WebKit::RemoteWebInspectorUIProxy::initialize`.
     62
    1632022-03-29  Jigen Zhou  <jigen.zhou@sony.com>
    264
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm

    r286329 r292084  
    124124- (void)loadForDebuggable:(_WKInspectorDebuggableInfo *)debuggableInfo backendCommandsURL:(NSURL *)backendCommandsURL
    125125{
    126     m_remoteInspectorProxy->load(static_cast<API::DebuggableInfo&>([debuggableInfo _apiObject]), backendCommandsURL.absoluteString);
     126    m_remoteInspectorProxy->initialize(static_cast<API::DebuggableInfo&>([debuggableInfo _apiObject]), backendCommandsURL.absoluteString);
    127127}
    128128
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp

    r290394 r292084  
    6868}
    6969
    70 void RemoteWebInspectorUIProxy::load(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL)
     70void RemoteWebInspectorUIProxy::initialize(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL)
    7171{
    7272    m_debuggableInfo = WTFMove(debuggableInfo);
     
    132132
    133133    closeFrontendPageAndWindow();
    134     load(m_debuggableInfo.copyRef(), m_backendCommandsURL);
     134    initialize(m_debuggableInfo.copyRef(), m_backendCommandsURL);
    135135}
    136136
     
    153153{
    154154    platformAppend(suggestedURL, content);
     155}
     156
     157void RemoteWebInspectorUIProxy::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     158{
     159    platformLoad(path, WTFMove(completionHandler));
    155160}
    156161
     
    234239void RemoteWebInspectorUIProxy::platformSave(const String&, const String&, bool, bool) { }
    235240void RemoteWebInspectorUIProxy::platformAppend(const String&, const String&) { }
     241void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) { completionHandler(nullString()); }
    236242void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect&) { }
    237243void RemoteWebInspectorUIProxy::platformSetForcedAppearance(InspectorFrontendClient::Appearance) { }
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h

    r283119 r292084  
    8686    void invalidate();
    8787
    88     void load(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);
     88    void initialize(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);
    8989    void closeFromBackend();
    9090    void show();
     
    134134    void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
    135135    void append(const String& filename, const String& content);
     136    void load(const String& path, CompletionHandler<void(const String&)>&&);
    136137    void setSheetRect(const WebCore::FloatRect&);
    137138    void setForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
     
    151152    void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
    152153    void platformAppend(const String& filename, const String& content);
     154    void platformLoad(const String& path, CompletionHandler<void(const String&)>&&);
    153155    void platformSetSheetRect(const WebCore::FloatRect&);
    154156    void platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in

    r274815 r292084  
    3030    Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
    3131    Append(String filename, String content)
     32    Load(String path) -> (String content)
    3233
    3334    SetForcedAppearance(WebCore::InspectorFrontendClient::Appearance appearance)
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp

    r290575 r292084  
    730730}
    731731
     732void WebInspectorUIProxy::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     733{
     734    if (!m_inspectedPage->preferences().developerExtrasEnabled())
     735        return;
     736
     737    ASSERT(!path.isEmpty());
     738    if (path.isEmpty())
     739        return;
     740
     741    platformLoad(path, WTFMove(completionHandler));
     742}
     743
    732744bool WebInspectorUIProxy::shouldOpenAttached()
    733745{
     
    824836}
    825837
     838void WebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     839{
     840    notImplemented();
     841    completionHandler(nullString());
     842}
     843
    826844unsigned WebInspectorUIProxy::platformInspectedWindowHeight()
    827845{
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h

    r289875 r292084  
    237237    void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
    238238    void platformAppend(const String& filename, const String& content);
     239    void platformLoad(const String& path, CompletionHandler<void(const String&)>&&);
    239240
    240241#if PLATFORM(MAC)
     
    263264    void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
    264265    void append(const String& filename, const String& content);
     266    void load(const String& path, CompletionHandler<void(const String&)>&&);
    265267
    266268    bool canAttach() const { return m_canAttach; }
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in

    r278253 r292084  
    4545    Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
    4646    Append(String filename, String content)
     47    Load(String path) -> (String content)
    4748
    4849    AttachBottom()
  • trunk/Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp

    r291152 r292084  
    6161    }
    6262
    63     void load(Inspector::DebuggableType debuggableType)
     63    void initialize(Inspector::DebuggableType debuggableType)
    6464    {
    6565        m_proxy = RemoteWebInspectorUIProxy::create();
     
    6868        Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty());
    6969        debuggableInfo->setDebuggableType(debuggableType);
    70         m_proxy->load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
     70        m_proxy->initialize(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
    7171    }
    7272
     
    244244    m_socketConnection->sendMessage("Setup", g_variant_new("(tt)", connectionID, targetID));
    245245    if (inspectorType == InspectorType::UI)
    246         addResult.iterator->value->load(debuggableType(targetType));
     246        addResult.iterator->value->initialize(debuggableType(targetType));
    247247}
    248248
  • trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp

    r290394 r292084  
    163163}
    164164
     165void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler)
     166{
     167    completionHandler(nullString());
     168}
     169
    165170void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect&)
    166171{
  • trunk/Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp

    r291835 r292084  
    563563}
    564564
     565void WebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler)
     566{
     567    notImplemented();
     568    completionHandler(nullString());
     569}
     570
    565571void WebInspectorUIProxy::platformAttachAvailabilityChanged(bool available)
    566572{
  • trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm

    r277740 r292084  
    234234}
    235235
     236void RemoteWebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     237{
     238    if (auto contents = FileSystem::readEntireFile(path))
     239        completionHandler(String::adopt(WTFMove(*contents)));
     240    else
     241        completionHandler(nullString());
     242}
     243
    236244void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect& rect)
    237245{
  • trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm

    r289875 r292084  
    578578}
    579579
     580void WebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     581{
     582    if (auto contents = FileSystem::readEntireFile(path))
     583        completionHandler(String::adopt(WTFMove(*contents)));
     584    else
     585        completionHandler(nullString());
     586}
     587
    580588void WebInspectorUIProxy::windowFrameDidChange()
    581589{
  • trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp

    r278619 r292084  
    5656    }
    5757
    58     void load()
     58    void initialize()
    5959    {
    6060        // FIXME <https://webkit.org/b/205537>: this should infer more useful data about the debug target.
    6161        Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty());
    6262        debuggableInfo->setDebuggableType(m_debuggableType);
    63         m_proxy->load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
     63        m_proxy->initialize(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());
    6464    }
    6565
     
    178178    sendWebInspectorEvent(setupEvent->toJSONString());
    179179
    180     addResult.iterator->value->load();
     180    addResult.iterator->value->initialize();
    181181}
    182182
  • trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp

    r274815 r292084  
    135135void RemoteWebInspectorUIProxy::platformSave(const String&, const String&, bool, bool) { }
    136136void RemoteWebInspectorUIProxy::platformAppend(const String&, const String&) { }
     137void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) { completionHandler(nullString()); }
    137138void RemoteWebInspectorUIProxy::platformSetSheetRect(const WebCore::FloatRect&) { }
    138139void RemoteWebInspectorUIProxy::platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance) { }
  • trunk/Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp

    r282889 r292084  
    419419}
    420420
     421void WebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler)
     422{
     423    notImplemented();
     424    completionHandler(nullString());
     425}
     426
    421427void WebInspectorUIProxy::platformAttachAvailabilityChanged(bool /* available */)
    422428{
  • trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp

    r288999 r292084  
    229229}
    230230
     231void RemoteWebInspectorUI::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler)
     232{
     233    WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::RemoteWebInspectorUIProxy::Load(path), WTFMove(completionHandler), m_page.identifier());
     234}
     235
    231236void RemoteWebInspectorUI::inspectedURLChanged(const String& urlString)
    232237{
  • trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h

    r288999 r292084  
    108108    void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) override;
    109109    void append(const String& url, const String& content) override;
     110    void load(const String& path, CompletionHandler<void(const String&)>&&) override;
    110111    void inspectedURLChanged(const String&) override;
    111112    void showCertificate(const WebCore::CertificateInfo&) override;
     
    129130
    130131    bool canSave() override { return true; }
     132    bool canLoad() override { return true; }
    131133    bool isUnderTest() override { return false; }
    132134    unsigned inspectionLevel() const override { return 1; }
  • trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp

    r288999 r292084  
    328328}
    329329
     330void WebInspectorUI::load(const WTF::String& path, CompletionHandler<void(const String&)>&& completionHandler)
     331{
     332    WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::WebInspectorUIProxy::Load(path), WTFMove(completionHandler), m_inspectedPageIdentifier);
     333}
     334
    330335void WebInspectorUI::inspectedURLChanged(const String& urlString)
    331336{
     
    496501}
    497502
     503bool WebInspectorUI::canLoad()
     504{
     505    notImplemented();
     506    return false;
     507}
     508
    498509String WebInspectorUI::localizedStringsURL() const
    499510{
  • trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h

    r288999 r292084  
    144144    void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) override;
    145145    void append(const WTF::String& url, const WTF::String& content) override;
     146    bool canLoad() override;
     147    void load(const WTF::String& path, WTF::CompletionHandler<void(const WTF::String&)>&&) override;
    146148
    147149    void inspectedURLChanged(const String&) override;
  • trunk/Source/WebKit/WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp

    r255214 r292084  
    4040}
    4141
     42bool WebInspectorUI::canLoad()
     43{
     44    return false;
     45}
     46
    4247String WebInspectorUI::localizedStringsURL() const
    4348{
  • trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm

    r274697 r292084  
    3838}
    3939
     40bool WebInspectorUI::canLoad()
     41{
     42    return true;
     43}
     44
    4045static String webInspectorUILocalizedStringsURL()
    4146{
  • trunk/Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp

    r274912 r292084  
    4040}
    4141
     42bool WebInspectorUI::canLoad()
     43{
     44    return false;
     45}
     46
    4247String WebInspectorUI::localizedStringsURL() const
    4348{
Note: See TracChangeset for help on using the changeset viewer.