Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome_linux64/resources/inspector/devtools_extension_api.js

Issue 310483004: Roll reference builds to 35.0.1916.114. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome_linux64/resources/inspector/devtools_extension_api.js
===================================================================
--- chrome_linux64/resources/inspector/devtools_extension_api.js (revision 273864)
+++ chrome_linux64/resources/inspector/devtools_extension_api.js (working copy)
@@ -250,12 +250,12 @@
}
callback(result);
}
- return extensionServer.sendRequest({ command: commands.GetHAR }, callback && callbackWrapper);
+ extensionServer.sendRequest({ command: commands.GetHAR }, callback && callbackWrapper);
},
addRequestHeaders: function(headers)
{
- return extensionServer.sendRequest({ command: commands.AddRequestHeaders, headers: headers, extensionId: window.location.hostname });
+ extensionServer.sendRequest({ command: commands.AddRequestHeaders, headers: headers, extensionId: window.location.hostname });
}
}
@@ -365,16 +365,21 @@
else
this._fire();
}
- this.onShown = new EventSink(events.ViewShown + id, dispatchShowEvent);
- this.onHidden = new EventSink(events.ViewHidden + id);
+
+ if (id) {
+ this.onShown = new EventSink(events.ViewShown + id, dispatchShowEvent);
+ this.onHidden = new EventSink(events.ViewHidden + id);
+ }
}
/**
* @constructor
* @extends {ExtensionViewImpl}
+ * @param {string} hostPanelName
*/
function PanelWithSidebarImpl(hostPanelName)
{
+ ExtensionViewImpl.call(this, null);
this._hostPanelName = hostPanelName;
this.onSelectionChanged = new EventSink(events.PanelObjectSelected + hostPanelName);
}
@@ -477,6 +482,9 @@
}
ExtensionPanelImpl.prototype = {
+ /**
+ * @return {!Object}
+ */
createStatusBarButton: function(iconPath, tooltipText, disabled)
{
var id = "button-" + extensionServer.nextObjectId();
@@ -580,6 +588,9 @@
}
Audits.prototype = {
+ /**
+ * @return {!AuditCategory}
+ */
addCategory: function(displayName, resultCount)
{
var id = "extension-audit-category-" + extensionServer.nextObjectId();
@@ -619,11 +630,11 @@
{
this._id = id;
- this.createURL = this._nodeFactory.bind(null, "url");
- this.createSnippet = this._nodeFactory.bind(null, "snippet");
- this.createText = this._nodeFactory.bind(null, "text");
- this.createObject = this._nodeFactory.bind(null, "object");
- this.createNode = this._nodeFactory.bind(null, "node");
+ this.createURL = this._nodeFactory.bind(this, "url");
+ this.createSnippet = this._nodeFactory.bind(this, "snippet");
+ this.createText = this._nodeFactory.bind(this, "text");
+ this.createObject = this._nodeFactory.bind(this, "object");
+ this.createNode = this._nodeFactory.bind(this, "node");
}
AuditResultImpl.prototype = {
@@ -644,6 +655,9 @@
extensionServer.sendRequest(request);
},
+ /**
+ * @return {!Object}
+ */
createResult: function()
{
return new AuditResultNode(Array.prototype.slice.call(arguments));
@@ -659,11 +673,17 @@
extensionServer.sendRequest({ command: commands.StopAuditCategoryRun, resultId: this._id });
},
+ /**
+ * @type {!Object.<string, string>}
+ */
get Severity()
{
return apiPrivate.audits.Severity;
},
+ /**
+ * @return {!{type: string, arguments: !Array.<string|number>}}
+ */
createResourceLink: function(url, lineNumber)
{
return {
@@ -672,6 +692,9 @@
};
},
+ /**
+ * @return {!{type: string, arguments: !Array.<string|number>}}
+ */
_nodeFactory: function(type)
{
return {
@@ -692,6 +715,9 @@
}
AuditResultNode.prototype = {
+ /**
+ * @return {!Object}
+ */
addChild: function()
{
var node = new AuditResultNode(Array.prototype.slice.call(arguments));
@@ -736,9 +762,12 @@
console.warn("Passing userAgent as string parameter to inspectedWindow.reload() is deprecated. " +
"Use inspectedWindow.reload({ userAgent: value}) instead.");
}
- return extensionServer.sendRequest({ command: commands.Reload, options: options });
+ extensionServer.sendRequest({ command: commands.Reload, options: options });
},
+ /**
+ * @return {?Object}
+ */
eval: function(expression, evaluateOptions)
{
var callback = extractCallbackArgument(arguments);
@@ -755,7 +784,8 @@
};
if (typeof evaluateOptions === "object")
request.evaluateOptions = evaluateOptions;
- return extensionServer.sendRequest(request, callback && callbackWrapper);
+ extensionServer.sendRequest(request, callback && callbackWrapper);
+ return null;
},
getResources: function(callback)
@@ -768,7 +798,7 @@
{
callback(resources.map(wrapResource));
}
- return extensionServer.sendRequest({ command: commands.GetPageResources }, callback && callbackWrapper);
+ extensionServer.sendRequest({ command: commands.GetPageResources }, callback && callbackWrapper);
}
}
@@ -799,12 +829,12 @@
callback(response.content, response.encoding);
}
- return extensionServer.sendRequest({ command: commands.GetResourceContent, url: this._url }, callback && callbackWrapper);
+ extensionServer.sendRequest({ command: commands.GetResourceContent, url: this._url }, callback && callbackWrapper);
},
setContent: function(content, commit, callback)
{
- return extensionServer.sendRequest({ command: commands.SetResourceContent, url: this._url, content: content, commit: commit }, callback);
+ extensionServer.sendRequest({ command: commands.SetResourceContent, url: this._url, content: content, commit: commit }, callback);
}
}
@@ -816,22 +846,38 @@
this.onEventRecorded = new EventSink(events.TimelineEventRecorded);
}
+var keyboardEventRequestQueue = [];
+var forwardTimer = null;
+
function forwardKeyboardEvent(event)
{
const Esc = "U+001B";
// We only care about global hotkeys, not about random text
if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(event.keyIdentifier) && event.keyIdentifier !== Esc)
return;
- var request = {
- command: commands.ForwardKeyboardEvent,
+ var requestPayload = {
eventType: event.type,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
metaKey: event.metaKey,
keyIdentifier: event.keyIdentifier,
- location: event.location
+ location: event.location,
+ keyCode: event.keyCode
};
+ keyboardEventRequestQueue.push(requestPayload);
+ if (!forwardTimer)
+ forwardTimer = setTimeout(forwardEventQueue, 0);
+}
+
+function forwardEventQueue()
+{
+ forwardTimer = null;
+ var request = {
+ command: commands.ForwardKeyboardEvent,
+ entries: keyboardEventRequestQueue
+ };
extensionServer.sendRequest(request);
+ keyboardEventRequestQueue = [];
}
document.addEventListener("keydown", forwardKeyboardEvent, false);
@@ -865,9 +911,12 @@
{
if (typeof callback === "function")
message.requestId = this._registerCallback(callback);
- return this._port.postMessage(message);
+ this._port.postMessage(message);
},
+ /**
+ * @return {boolean}
+ */
hasHandler: function(command)
{
return !!this._handlers[command];
@@ -883,6 +932,9 @@
delete this._handlers[command];
},
+ /**
+ * @return {string}
+ */
nextObjectId: function()
{
return injectedScriptId + "_" + ++this._lastObjectId;
@@ -941,50 +993,8 @@
}
/**
- * @param {!ExtensionDescriptor} extensionInfo
- * @return {string}
+ * @suppress {checkVars, checkTypes}
*/
-function buildExtensionAPIInjectedScript(extensionInfo)
-{
- return "(function(injectedScriptId){ " +
- "var extensionServer;" +
- defineCommonExtensionSymbols.toString() + ";" +
- injectedExtensionAPI.toString() + ";" +
- buildPlatformExtensionAPI(extensionInfo) + ";" +
- "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" +
- "return {};" +
- "})";
-}
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
function platformExtensionAPI(coreAPI)
{
function getTabId()
@@ -1021,6 +1031,33 @@
window.webInspector = coreAPI;
}
+/**
+ * @param {!ExtensionDescriptor} extensionInfo
+ * @return {string}
+ */
+function buildPlatformExtensionAPI(extensionInfo)
+{
+ return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" +
+ "var tabId = " + WebInspector._inspectedTabId + ";" +
+ platformExtensionAPI.toString();
+}
+
+/**
+ * @param {!ExtensionDescriptor} extensionInfo
+ * @return {string}
+ */
+function buildExtensionAPIInjectedScript(extensionInfo)
+{
+ return "(function(injectedScriptId){ " +
+ "var extensionServer;" +
+ defineCommonExtensionSymbols.toString() + ";" +
+ injectedExtensionAPI.toString() + ";" +
+ buildPlatformExtensionAPI(extensionInfo) + ";" +
+ "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" +
+ "return {};" +
+ "})";
+}
+
var tabId;
var extensionInfo = {};
var extensionServer;
« no previous file with comments | « chrome_linux64/resources/inspector/devtools.html ('k') | chrome_linux64/resources/inspector/elementsPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698