Title: [100994] trunk/Source/WebCore
Revision
100994
Author
ca...@chromium.org
Date
2011-11-22 05:40:41 -0800 (Tue, 22 Nov 2011)

Log Message

Web Inspector: [Extensions API][refactoring] remove dependencies on the ExtensionsServer from most of the insepctor
https://bugs.webkit.org/show_bug.cgi?id=72899

Reviewed by Pavel Feldman.

* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype._selectedNodeChanged):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._notifyResourceContentCommitted):
(WebInspector.ExtensionServer.prototype._notifyElementsSelectionChanged):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.addRevision):
* inspector/front-end/externs.js:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (100993 => 100994)


--- trunk/Source/WebCore/ChangeLog	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/ChangeLog	2011-11-22 13:40:41 UTC (rev 100994)
@@ -1,3 +1,19 @@
+2011-11-21  Andrey Kosyakov  <ca...@chromium.org>
+
+        Web Inspector: [Extensions API][refactoring] remove dependencies on the ExtensionsServer from most of the insepctor
+        https://bugs.webkit.org/show_bug.cgi?id=72899
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype._selectedNodeChanged):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype._notifyResourceContentCommitted):
+        (WebInspector.ExtensionServer.prototype._notifyElementsSelectionChanged):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.addRevision):
+        * inspector/front-end/externs.js:
+
 2011-11-22  Zoltan Horvath  <zol...@webkit.org>
 
         [Qt] Build fix for MHTML support

Modified: trunk/Source/WebCore/inspector/front-end/ElementsPanel.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/ElementsPanel.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/ElementsPanel.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -177,7 +177,6 @@
 
         if (selectedNode) {
             ConsoleAgent.addInspectedNode(selectedNode.id);
-            WebInspector.extensionServer.notifyObjectSelected(this.name);
             this._lastValidSelectedNode = selectedNode;
         }
     },

Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -48,6 +48,47 @@
         Warning: "warning",
         Error: "error"
     };
+    apiPrivate.Events = {
+        AuditStarted: "audit-started-",
+        ButtonClicked: "button-clicked-",
+        ConsoleMessageAdded: "console-message-added",
+        ElementsPanelObjectSelected: "panel-objectSelected-elements",
+        NetworkRequestFinished: "network-request-finished",
+        Reset: "reset",
+        OpenResource: "open-resource",
+        PanelSearch: "panel-search-",
+        Reload: "Reload",
+        ResourceAdded: "resource-added",
+        ResourceContentCommitted: "resource-content-committed",
+        TimelineEventRecorded: "timeline-event-recorded",
+        ViewShown: "view-shown-",
+        ViewHidden: "view-hidden-"
+    };
+    apiPrivate.Commands = {
+        AddAuditCategory: "addAuditCategory",
+        AddAuditResult: "addAuditResult",
+        AddConsoleMessage: "addConsoleMessage",
+        AddRequestHeaders: "addRequestHeaders",
+        CreatePanel: "createPanel",
+        CreateSidebarPane: "createSidebarPane",
+        CreateStatusBarButton: "createStatusBarButton",
+        EvaluateOnInspectedPage: "evaluateOnInspectedPage",
+        GetConsoleMessages: "getConsoleMessages",
+        GetHAR: "getHAR",
+        GetPageResources: "getPageResources",
+        GetRequestContent: "getRequestContent",
+        GetResourceContent: "getResourceContent",
+        Subscribe: "subscribe",
+        SetOpenResourceHandler: "setOpenResourceHandler",
+        SetResourceContent: "setResourceContent",
+        SetSidebarContent: "setSidebarContent",
+        SetSidebarHeight: "setSidebarHeight",
+        SetSidebarPage: "setSidebarPage",
+        StopAuditCategoryRun: "stopAuditCategoryRun",
+        Unsubscribe: "unsubscribe",
+        UpdateButton: "updateButton",
+        InspectedURLChanged: "inspectedURLChanged"
+    };
 }
 
 function injectedExtensionAPI(injectedScriptId)
@@ -57,6 +98,9 @@
 
 defineCommonExtensionSymbols(apiPrivate);
 
+var commands = apiPrivate.Commands;
+var events = apiPrivate.Events;
+
 // Here and below, all constructors are private to API implementation.
 // For a public type Foo, if internal fields are present, these are on
 // a private FooImpl type, an instance of FooImpl is used in a closure
@@ -76,10 +120,10 @@
 EventSinkImpl.prototype = {
     addListener: function(callback)
     {
-        if (typeof callback != "function")
+        if (typeof callback !== "function")
             throw "addListener: callback is not a function";
         if (this._listeners.length === 0)
-            extensionServer.sendRequest({ command: "subscribe", type: this._type });
+            extensionServer.sendRequest({ command: commands.Subscribe, type: this._type });
         this._listeners.push(callback);
         extensionServer.registerHandler("notify-" + this._type, bind(this._dispatch, this));
     },
@@ -95,7 +139,7 @@
             }
         }
         if (this._listeners.length === 0)
-            extensionServer.sendRequest({ command: "unsubscribe", type: this._type });
+            extensionServer.sendRequest({ command: commands.Unsubscribe, type: this._type });
     },
 
     _fire: function()
@@ -127,7 +171,7 @@
     this.timeline = new Timeline();
     this.console = new Console();
 
-    this._onReset_ = new EventSink("reset");
+    this._onReset_ = new EventSink(events.Reset);
 }
 
 /**
@@ -136,7 +180,7 @@
 InspectorExtensionAPI.prototype = {
     log: function(message)
     {
-        extensionServer.sendRequest({ command: "log", message: message });
+        extensionServer.sendRequest({ command: commands.Log, message: message });
     }
 }
 
@@ -145,18 +189,18 @@
  */
 function Console()
 {
-    this._onMessageAdded_ = new EventSink("console-message-added");
+    this._onMessageAdded_ = new EventSink(events.ConsoleMessageAdded);
 }
 
 Console.prototype = {
     getMessages: function(callback)
     {
-        extensionServer.sendRequest({ command: "getConsoleMessages" }, callback);
+        extensionServer.sendRequest({ command: commands.GetConsoleMessages }, callback);
     },
 
     addMessage: function(severity, text, url, line)
     {
-        extensionServer.sendRequest({ command: "addConsoleMessage", severity: severity, text: text, url: url, line: line });
+        extensionServer.sendRequest({ command: commands.AddConsoleMessage, severity: severity, text: text, url: url, line: line });
     },
 
     get Severity()
@@ -176,9 +220,9 @@
         request.__proto__ = new Request(message.arguments[0]);
         this._fire(request);
     }
-    this._onRequestFinished_ = new EventSink("network-request-finished", dispatchRequestEvent);
+    this._onRequestFinished_ = new EventSink(events.NetworkRequestFinished, dispatchRequestEvent);
     defineDeprecatedProperty(this, "network", "onFinished", "onRequestFinished");
-    this._onNavigated_ = new EventSink("inspectedURLChanged");
+    this._onNavigated_ = new EventSink(events.InspectedURLChanged);
 }
 
 Network.prototype = {
@@ -193,12 +237,12 @@
             }
             callback(result);
         }
-        return extensionServer.sendRequest({ command: "getHAR" }, callback && callbackWrapper);
+        return extensionServer.sendRequest({ command: commands.GetHAR }, callback && callbackWrapper);
     },
 
     addRequestHeaders: function(headers)
     {
-        return extensionServer.sendRequest({ command: "addRequestHeaders", headers: headers, extensionId: window.location.hostname });
+        return extensionServer.sendRequest({ command: commands.AddRequestHeaders, headers: headers, extensionId: window.location.hostname });
     }
 }
 
@@ -217,7 +261,7 @@
         {
             callback(response.content, response.encoding);
         }
-        extensionServer.sendRequest({ command: "getRequestContent", id: this._id }, callback && callbackWrapper);
+        extensionServer.sendRequest({ command: commands.GetRequestContent, id: this._id }, callback && callbackWrapper);
     }
 }
 
@@ -243,7 +287,7 @@
     {
         var id = "extension-panel-" + extensionServer.nextObjectId();
         var request = {
-            command: "createPanel",
+            command: commands.CreatePanel,
             id: id,
             title: title,
             icon: icon,
@@ -254,20 +298,20 @@
 
     setOpenResourceHandler: function(callback)
     {
-        var hadHandler = extensionServer.hasHandler("open-resource");
+        var hadHandler = extensionServer.hasHandler(events.OpenResource);
 
         if (!callback)
-            extensionServer.unregisterHandler("open-resource");
+            extensionServer.unregisterHandler(events.OpenResource);
         else {
             function callbackWrapper(message)
             {
                 callback.call(null, message.resource);
             }
-            extensionServer.registerHandler("open-resource", callbackWrapper);
+            extensionServer.registerHandler(events.OpenResource, callbackWrapper);
         }
         // Only send command if we either removed an existing handler or added handler and had none before.
         if (hadHandler === !callback)
-            extensionServer.sendRequest({ command: "setOpenResourceHandler", "handlerPresent": !!callback });
+            extensionServer.sendRequest({ command: commands.SetOpenResourceHandler, "handlerPresent": !!callback });
     }
 }
 
@@ -283,8 +327,8 @@
         var frameIndex = message.arguments[0];
         this._fire(window.top.frames[frameIndex]);
     }
-    this._onShown_ = new EventSink("view-shown-" + id, dispatchShowEvent);
-    this._onHidden_ = new EventSink("view-hidden-" + id);
+    this._onShown_ = new EventSink(events.ViewShown + id, dispatchShowEvent);
+    this._onHidden_ = new EventSink(events.ViewHidden + id);
 }
 
 /**
@@ -300,7 +344,7 @@
     {
         var id = "extension-sidebar-" + extensionServer.nextObjectId();
         var request = {
-            command: "createSidebarPane",
+            command: commands.CreateSidebarPane,
             panel: this._id,
             id: id,
             title: title
@@ -323,7 +367,7 @@
 {
     var id = "elements";
     PanelWithSidebar.call(this, id);
-    this._onSelectionChanged_ = new EventSink("panel-objectSelected-" + id);
+    this._onSelectionChanged_ = new EventSink(events.ElementsPanelObjectSelected);
 }
 
 /**
@@ -333,7 +377,7 @@
 function ExtensionPanelImpl(id)
 {
     ExtensionViewImpl.call(this, id);
-    this._onSearch_ = new EventSink("panel-search-" + id);
+    this._onSearch_ = new EventSink(events.PanelSearch + id);
 }
 
 ExtensionPanelImpl.prototype = {
@@ -341,7 +385,7 @@
     {
         var id = "button-" + extensionServer.nextObjectId();
         var request = {
-            command: "createStatusBarButton",
+            command: commands.CreateStatusBarButton,
             panel: this._id,
             id: id,
             icon: iconPath,
@@ -367,22 +411,22 @@
 ExtensionSidebarPaneImpl.prototype = {
     setHeight: function(height)
     {
-        extensionServer.sendRequest({ command: "setSidebarHeight", id: this._id, height: height });
+        extensionServer.sendRequest({ command: commands.SetSidebarHeight, id: this._id, height: height });
     },
 
     setExpression: function(_expression_, rootTitle, callback)
     {
-        extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: _expression_, rootTitle: rootTitle, evaluateOnPage: true }, callback);
+        extensionServer.sendRequest({ command: commands.SetSidebarContent, id: this._id, _expression_: _expression_, rootTitle: rootTitle, evaluateOnPage: true }, callback);
     },
 
     setObject: function(jsonObject, rootTitle, callback)
     {
-        extensionServer.sendRequest({ command: "setSidebarContent", id: this._id, _expression_: jsonObject, rootTitle: rootTitle }, callback);
+        extensionServer.sendRequest({ command: commands.SetSidebarContent, id: this._id, _expression_: jsonObject, rootTitle: rootTitle }, callback);
     },
 
     setPage: function(page)
     {
-        extensionServer.sendRequest({ command: "setSidebarPage", id: this._id, page: page });
+        extensionServer.sendRequest({ command: commands.SetSidebarPage, id: this._id, page: page });
     }
 }
 
@@ -392,14 +436,14 @@
 function ButtonImpl(id)
 {
     this._id = id;
-    this._onClicked_ = new EventSink("button-clicked-" + id);
+    this._onClicked_ = new EventSink(events.ButtonClicked + id);
 }
 
 ButtonImpl.prototype = {
     update: function(iconPath, tooltipText, disabled)
     {
         var request = {
-            command: "updateButton",
+            command: commands.UpdateButton,
             id: this._id,
             icon: iconPath,
             tooltip: tooltipText,
@@ -420,7 +464,7 @@
     addCategory: function(displayName, resultCount)
     {
         var id = "extension-audit-category-" + extensionServer.nextObjectId();
-        extensionServer.sendRequest({ command: "addAuditCategory", id: id, displayName: displayName, resultCount: resultCount });
+        extensionServer.sendRequest({ command: commands.AddAuditCategory, id: id, displayName: displayName, resultCount: resultCount });
         return new AuditCategory(id);
     }
 }
@@ -441,7 +485,7 @@
         }
     }
     this._id = id;
-    this._onAuditStarted_ = new EventSink("audit-started-" + id, dispatchAuditEvent);
+    this._onAuditStarted_ = new EventSink(events.AuditStarted + id, dispatchAuditEvent);
 }
 
 /**
@@ -465,7 +509,7 @@
             details = new AuditResultNode(details instanceof Array ? details : [details]);
 
         var request = {
-            command: "addAuditResult",
+            command: commands.AddAuditResult,
             resultId: this._id,
             displayName: displayName,
             description: description,
@@ -482,7 +526,7 @@
 
     done: function()
     {
-        extensionServer.sendRequest({ command: "stopAuditCategoryRun", resultId: this._id });
+        extensionServer.sendRequest({ command: commands.StopAuditCategoryRun, resultId: this._id });
     },
 
     get Severity()
@@ -531,8 +575,8 @@
     {
         this._fire(new Resource(message.arguments[0]), message.arguments[1]);
     }
-    this._onResourceAdded_ = new EventSink("resource-added", dispatchResourceEvent);
-    this._onResourceContentCommitted_ = new EventSink("resource-content-committed", dispatchResourceContentEvent);
+    this._onResourceAdded_ = new EventSink(events.ResourceAdded, dispatchResourceEvent);
+    this._onResourceContentCommitted_ = new EventSink(events.ResourceContentCommitted, dispatchResourceContentEvent);
 }
 
 InspectedWindow.prototype = {
@@ -546,7 +590,7 @@
             console.warn("Passing userAgent as string parameter to inspectedWindow.reload() is deprecated. " +
                          "Use inspectedWindow.reload({ userAgent: value}) instead.");
         }
-        return extensionServer.sendRequest({ command: "reload", options: options });
+        return extensionServer.sendRequest({ command: commands.Reload, options: options });
     },
 
     eval: function(_expression_, callback)
@@ -555,7 +599,7 @@
         {
             callback(result.value, result.isException);
         }
-        return extensionServer.sendRequest({ command: "evaluateOnInspectedPage", _expression_: _expression_ }, callback && callbackWrapper);
+        return extensionServer.sendRequest({ command: commands.EvaluateOnInspectedPage, _expression_: _expression_ }, callback && callbackWrapper);
     },
 
     getResources: function(callback)
@@ -568,7 +612,7 @@
         {
             callback(resources.map(wrapResource));
         }
-        return extensionServer.sendRequest({ command: "getPageResources" }, callback && callbackWrapper);
+        return extensionServer.sendRequest({ command: commands.GetPageResources }, callback && callbackWrapper);
     }
 }
 
@@ -599,12 +643,12 @@
             callback(response.content, response.encoding);
         }
 
-        return extensionServer.sendRequest({ command: "getResourceContent", url: this._url }, callback && callbackWrapper);
+        return extensionServer.sendRequest({ command: commands.GetResourceContent, url: this._url }, callback && callbackWrapper);
     },
 
     setContent: function(content, commit, callback)
     {
-        return extensionServer.sendRequest({ command: "setResourceContent", url: this._url, content: content, commit: commit }, callback);
+        return extensionServer.sendRequest({ command: commands.SetResourceContent, url: this._url, content: content, commit: commit }, callback);
     }
 }
 
@@ -613,7 +657,7 @@
  */
 function TimelineImpl()
 {
-    this._onEventRecorded_ = new EventSink("timeline-event-recorded");
+    this._onEventRecorded_ = new EventSink(events.TimelineEventRecorded);
 }
 
 /**

Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -44,70 +44,67 @@
     this._registeredExtensions = {};
     this._status = new WebInspector.ExtensionStatus();
 
-    this._registerHandler("addAuditCategory", this._onAddAuditCategory.bind(this));
-    this._registerHandler("addAuditResult", this._onAddAuditResult.bind(this));
-    this._registerHandler("addConsoleMessage", this._onAddConsoleMessage.bind(this));
-    this._registerHandler("addRequestHeaders", this._onAddRequestHeaders.bind(this));
-    this._registerHandler("createPanel", this._onCreatePanel.bind(this));
-    this._registerHandler("createSidebarPane", this._onCreateSidebarPane.bind(this));
-    this._registerHandler("createStatusBarButton", this._onCreateStatusBarButton.bind(this));
-    this._registerHandler("evaluateOnInspectedPage", this._onEvaluateOnInspectedPage.bind(this));
-    this._registerHandler("getHAR", this._onGetHAR.bind(this));
-    this._registerHandler("getConsoleMessages", this._onGetConsoleMessages.bind(this));
-    this._registerHandler("getPageResources", this._onGetPageResources.bind(this));
-    this._registerHandler("getRequestContent", this._onGetRequestContent.bind(this));
-    this._registerHandler("getResourceContent", this._onGetResourceContent.bind(this));
-    this._registerHandler("log", this._onLog.bind(this));
-    this._registerHandler("reload", this._onReload.bind(this));
-    this._registerHandler("setOpenResourceHandler", this._onSetOpenResourceHandler.bind(this));
-    this._registerHandler("setResourceContent", this._onSetResourceContent.bind(this));
-    this._registerHandler("setSidebarHeight", this._onSetSidebarHeight.bind(this));
-    this._registerHandler("setSidebarContent", this._onSetSidebarContent.bind(this));
-    this._registerHandler("setSidebarPage", this._onSetSidebarPage.bind(this));
-    this._registerHandler("stopAuditCategoryRun", this._onStopAuditCategoryRun.bind(this));
-    this._registerHandler("subscribe", this._onSubscribe.bind(this));
-    this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this));
-    this._registerHandler("updateButton", this._onUpdateButton.bind(this));
+    var commands = WebInspector.extensionAPI.Commands;
 
+    this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bind(this));
+    this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(this));
+    this._registerHandler(commands.AddConsoleMessage, this._onAddConsoleMessage.bind(this));
+    this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders.bind(this));
+    this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this));
+    this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane.bind(this));
+    this._registerHandler(commands.CreateStatusBarButton, this._onCreateStatusBarButton.bind(this));
+    this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnInspectedPage.bind(this));
+    this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this));
+    this._registerHandler(commands.GetConsoleMessages, this._onGetConsoleMessages.bind(this));
+    this._registerHandler(commands.GetPageResources, this._onGetPageResources.bind(this));
+    this._registerHandler(commands.GetRequestContent, this._onGetRequestContent.bind(this));
+    this._registerHandler(commands.GetResourceContent, this._onGetResourceContent.bind(this));
+    this._registerHandler(commands.Log, this._onLog.bind(this));
+    this._registerHandler(commands.Reload, this._onReload.bind(this));
+    this._registerHandler(commands.SetOpenResourceHandler, this._onSetOpenResourceHandler.bind(this));
+    this._registerHandler(commands.SetResourceContent, this._onSetResourceContent.bind(this));
+    this._registerHandler(commands.SetSidebarHeight, this._onSetSidebarHeight.bind(this));
+    this._registerHandler(commands.SetSidebarContent, this._onSetSidebarContent.bind(this));
+    this._registerHandler(commands.SetSidebarPage, this._onSetSidebarPage.bind(this));
+    this._registerHandler(commands.StopAuditCategoryRun, this._onStopAuditCategoryRun.bind(this));
+    this._registerHandler(commands.Subscribe, this._onSubscribe.bind(this));
+    this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this));
+    this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this));
+
     window.addEventListener("message", this._onWindowMessage.bind(this), false);
 }
 
 WebInspector.ExtensionServer.prototype = {
-    notifyObjectSelected: function(panelId, objectId)
-    {
-        this._postNotification("panel-objectSelected-" + panelId, objectId);
-    },
-
     notifySearchAction: function(panelId, action, searchString)
     {
-        this._postNotification("panel-search-" + panelId, action, searchString);
+        this._postNotification(WebInspector.extensionAPI.Events.PanelSearch + panelId, action, searchString);
     },
 
     notifyViewShown: function(identifier, frameIndex)
     {
-        this._postNotification("view-shown-" + identifier, frameIndex);
+        this._postNotification(WebInspector.extensionAPI.Events.ViewShown + identifier, frameIndex);
     },
 
     notifyViewHidden: function(identifier)
     {
-        this._postNotification("view-hidden-" + identifier);
+        this._postNotification(WebInspector.extensionAPI.Events.ViewHidden + identifier);
     },
 
     notifyButtonClicked: function(identifier)
     {
-        this._postNotification("button-clicked-" + identifier);
+        this._postNotification(WebInspector.extensionAPI.Events.ButtonClicked + identifier);
     },
 
     _inspectedURLChanged: function(event)
     {
         this._requests = {};
         var url = ""
-        this._postNotification("inspectedURLChanged", url);
+        this._postNotification(WebInspector.extensionAPI.Events.InspectedURLChanged, url);
     },
 
     _mainFrameNavigated: function(event)
     {
-        this._postNotification("reset");
+        this._postNotification(WebInspector.extensionAPI.Events.Reset);
     },
 
     startAuditRun: function(category, auditRun)
@@ -121,11 +118,6 @@
         delete this._clientObjects[auditRun.id];
     },
 
-    notifyResourceContentCommitted: function(resource, content)
-    {
-        this._postNotification("resource-content-committed", this._makeResource(resource), content);
-    },
-
     /**
      * @param {...*} vararg
      */
@@ -525,12 +517,22 @@
 
     initExtensions: function()
     {
-        this._registerAutosubscriptionHandler("console-message-added",
+        this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ConsoleMessageAdded,
             WebInspector.console, WebInspector.ConsoleModel.Events.MessageAdded, this._notifyConsoleMessageAdded);
-        this._registerAutosubscriptionHandler("network-request-finished",
+        this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.NetworkRequestFinished,
             WebInspector.networkManager, WebInspector.NetworkManager.EventTypes.ResourceFinished, this._notifyRequestFinished);
-        this._registerAutosubscriptionHandler("resource-added",
-            WebInspector.resourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._notifyResourceAdded);
+        this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ResourceAdded,
+            WebInspector.resourceTreeModel,
+            WebInspector.ResourceTreeModel.EventTypes.ResourceAdded,
+            this._notifyResourceAdded);
+        this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ElementsPanelObjectSelected,
+            WebInspector.panels.elements.treeOutline,
+            WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged,
+            this._notifyElementsSelectionChanged);
+        this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ResourceContentCommitted,
+            WebInspector.resourceTreeModel,
+            WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted,
+            this._notifyResourceContentCommitted);
 
         function onTimelineSubscriptionStarted()
         {
@@ -544,7 +546,8 @@
             WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded,
                 this._notifyTimelineEventRecorded, this);
         }
-        this._registerSubscriptionHandler("timeline-event-recorded", onTimelineSubscriptionStarted.bind(this), onTimelineSubscriptionStopped.bind(this));
+        this._registerSubscriptionHandler(WebInspector.extensionAPI.Events.TimelineEventRecorded,
+            onTimelineSubscriptionStarted.bind(this), onTimelineSubscriptionStopped.bind(this));
 
         WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,
             this._inspectedURLChanged, this);
@@ -554,24 +557,34 @@
 
     _notifyConsoleMessageAdded: function(event)
     {
-        this._postNotification("console-message-added", this._makeConsoleMessage(event.data));
+        this._postNotification(WebInspector.extensionAPI.Events.ConsoleMessageAdded, this._makeConsoleMessage(event.data));
     },
 
     _notifyResourceAdded: function(event)
     {
         var resource = event.data;
-        this._postNotification("resource-added", this._makeResource(resource));
+        this._postNotification(WebInspector.extensionAPI.Events.ResourceAdded, this._makeResource(resource));
     },
 
+    _notifyResourceContentCommitted: function(event)
+    {
+        this._postNotification(WebInspector.extensionAPI.Events.ResourceContentCommitted, this._makeResource(event.data.resource), event.data.content);
+    },
+
     _notifyRequestFinished: function(event)
     {
         var request = event.data;
-        this._postNotification("network-request-finished", this._requestId(request), (new WebInspector.HAREntry(request)).build());
+        this._postNotification(WebInspector.extensionAPI.Events.NetworkRequestFinished, this._requestId(request), (new WebInspector.HAREntry(request)).build());
     },
 
+    _notifyElementsSelectionChanged: function()
+    {
+        this._postNotification(WebInspector.extensionAPI.Events.ElementsPanelObjectSelected);
+    },
+
     _notifyTimelineEventRecorded: function(event)
     {
-        this._postNotification("timeline-event-recorded", event.data);
+        this._postNotification(WebInspector.extensionAPI.Events.TimelineEventRecorded, event.data);
     },
 
     /**
@@ -720,9 +733,9 @@
     WebInspector.extensionServer._addExtensions(extensions);
 }
 
-WebInspector.extensionServer = new WebInspector.ExtensionServer();
-
 WebInspector.extensionAPI = {};
 defineCommonExtensionSymbols(WebInspector.extensionAPI);
 
+WebInspector.extensionServer = new WebInspector.ExtensionServer();
+
 window.addExtension = WebInspector.extensionServer._addExtension.bind(WebInspector.extensionServer);

Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/Resource.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -249,7 +249,7 @@
 WebInspector.Resource.Events = {
     RevisionAdded: "revision-added",
     MessageAdded: "message-added",
-    MessagesCleared: "messages-cleared"
+    MessagesCleared: "messages-cleared",
 }
 
 WebInspector.Resource.prototype = {
@@ -855,10 +855,9 @@
         this._contentTimestamp = timestamp || new Date();
 
         this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision);
-
         if (!restoringHistory)
             this._persistRevision();
-        WebInspector.extensionServer.notifyResourceContentCommitted(this, newContent);
+        WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: newContent });
     },
 
     _persistRevision: function()

Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -56,6 +56,7 @@
     FrameDetached: "FrameDetached",
     MainFrameNavigated: "MainFrameNavigated",
     ResourceAdded: "ResourceAdded",
+    ResourceContentCommitted: "resource-content-committed",
     WillLoadCachedResources: "WillLoadCachedResources",
     CachedResourcesLoaded: "CachedResourcesLoaded",
     DOMContentLoaded: "DOMContentLoaded",

Modified: trunk/Source/WebCore/inspector/front-end/externs.js (100993 => 100994)


--- trunk/Source/WebCore/inspector/front-end/externs.js	2011-11-22 13:38:51 UTC (rev 100993)
+++ trunk/Source/WebCore/inspector/front-end/externs.js	2011-11-22 13:40:41 UTC (rev 100994)
@@ -75,12 +75,6 @@
 // FIXME: remove everything below.
 var WebInspector = {}
 
-WebInspector.extensionServer = {}
-WebInspector.extensionServer.notifyResourceContentCommitted = function(resource, content) {}
-WebInspector.extensionServer.notifyPanelShown = function(panel) {}
-WebInspector.extensionServer.notifyPanelHidden = function(panel) {}
-WebInspector.extensionServer.notifyObjectSelected = function(object) {}
-
 /**
  * @param {NetworkAgent.RequestId} requestId
  * @return {?WebInspector.Resource}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to