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

Unified Diff: Source/devtools/front_end/ExtensionAPI.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
Index: Source/devtools/front_end/ExtensionAPI.js
diff --git a/Source/devtools/front_end/ExtensionAPI.js b/Source/devtools/front_end/ExtensionAPI.js
index 5577ddf41e9dea2557a6d960093e22799aa437cd..dc102a5b67680cca06b1c4a9358b2a89b0852e0e 100644
--- a/Source/devtools/front_end/ExtensionAPI.js
+++ b/Source/devtools/front_end/ExtensionAPI.js
@@ -80,6 +80,7 @@ function defineCommonExtensionSymbols(apiPrivate)
CreateSidebarPane: "createSidebarPane",
CreateStatusBarButton: "createStatusBarButton",
EvaluateOnInspectedPage: "evaluateOnInspectedPage",
+ ForwardKeyboardEvent: "_forwardKeyboardEvent",
GetConsoleMessages: "getConsoleMessages",
GetHAR: "getHAR",
GetPageResources: "getPageResources",
@@ -724,6 +725,27 @@ function TimelineImpl()
this.onEventRecorded = new EventSink(events.TimelineEventRecorded);
}
+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,
+ eventType: event.type,
+ ctrlKey: event.ctrlKey,
+ altKey: event.altKey,
+ metaKey: event.metaKey,
+ keyIdentifier: event.keyIdentifier,
+ keyLocation: event.keyLocation
+ };
+ extensionServer.sendRequest(request);
+}
+
+document.addEventListener("keydown", forwardKeyboardEvent, false);
+document.addEventListener("keypress", forwardKeyboardEvent, false);
+
/**
* @constructor
*/
« no previous file with comments | « LayoutTests/inspector/extensions/extensions-panel-expected.txt ('k') | Source/devtools/front_end/ExtensionServer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698