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

Unified Diff: Source/devtools/front_end/ExtensionServer.js

Issue 18835002: DevTools extensions: forward keyboard shortcuts to DevTools (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/externs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ExtensionServer.js
diff --git a/Source/devtools/front_end/ExtensionServer.js b/Source/devtools/front_end/ExtensionServer.js
index c3e0e97e9744c38f6135f7040af1b2fc69a0fdcd..b610d1b17b5c6c4f2f2b78c6f46df0c667b927b4 100644
--- a/Source/devtools/front_end/ExtensionServer.js
+++ b/Source/devtools/front_end/ExtensionServer.js
@@ -54,6 +54,7 @@ WebInspector.ExtensionServer = function()
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.ForwardKeyboardEvent, this._onForwardKeyboardEvent.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));
@@ -566,6 +567,25 @@ WebInspector.ExtensionServer.prototype = {
auditRun.done();
},
+ _onForwardKeyboardEvent: function(message)
+ {
+ const Esc = "U+001B";
+
+ if (!message.ctrlKey && !message.altKey && !message.metaKey && !/^F\d+$/.test(message.keyIdentifier) && message.keyIdentifier !== Esc)
+ return;
+ // Fool around closure compiler -- it has its own notion of both KeyboardEvent constructor
+ // and initKeyboardEvent methods and overriding these in externs.js does not have effect.
+ var event = new window.KeyboardEvent(message.eventType, {
+ keyIdentifier: message.keyIdentifier,
+ keyLocation: message.keyLocation,
+ ctrlKey: message.ctrlKey,
+ altKey: message.altKey,
+ shiftKey: message.shiftKey,
+ metaKey: message.metaKey
+ });
+ document.dispatchEvent(event);
+ },
+
_dispatchCallback: function(requestId, port, result)
{
if (requestId)
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698