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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 apiPrivate.Commands = { 74 apiPrivate.Commands = {
75 AddAuditCategory: "addAuditCategory", 75 AddAuditCategory: "addAuditCategory",
76 AddAuditResult: "addAuditResult", 76 AddAuditResult: "addAuditResult",
77 AddConsoleMessage: "addConsoleMessage", 77 AddConsoleMessage: "addConsoleMessage",
78 AddRequestHeaders: "addRequestHeaders", 78 AddRequestHeaders: "addRequestHeaders",
79 CreatePanel: "createPanel", 79 CreatePanel: "createPanel",
80 CreateSidebarPane: "createSidebarPane", 80 CreateSidebarPane: "createSidebarPane",
81 CreateStatusBarButton: "createStatusBarButton", 81 CreateStatusBarButton: "createStatusBarButton",
82 EvaluateOnInspectedPage: "evaluateOnInspectedPage", 82 EvaluateOnInspectedPage: "evaluateOnInspectedPage",
83 ForwardKeyboardEvent: "_forwardKeyboardEvent",
83 GetConsoleMessages: "getConsoleMessages", 84 GetConsoleMessages: "getConsoleMessages",
84 GetHAR: "getHAR", 85 GetHAR: "getHAR",
85 GetPageResources: "getPageResources", 86 GetPageResources: "getPageResources",
86 GetRequestContent: "getRequestContent", 87 GetRequestContent: "getRequestContent",
87 GetResourceContent: "getResourceContent", 88 GetResourceContent: "getResourceContent",
88 Reload: "Reload", 89 Reload: "Reload",
89 Subscribe: "subscribe", 90 Subscribe: "subscribe",
90 SetOpenResourceHandler: "setOpenResourceHandler", 91 SetOpenResourceHandler: "setOpenResourceHandler",
91 SetResourceContent: "setResourceContent", 92 SetResourceContent: "setResourceContent",
92 SetSidebarContent: "setSidebarContent", 93 SetSidebarContent: "setSidebarContent",
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 718 }
718 719
719 /** 720 /**
720 * @constructor 721 * @constructor
721 */ 722 */
722 function TimelineImpl() 723 function TimelineImpl()
723 { 724 {
724 this.onEventRecorded = new EventSink(events.TimelineEventRecorded); 725 this.onEventRecorded = new EventSink(events.TimelineEventRecorded);
725 } 726 }
726 727
728 function forwardKeyboardEvent(event)
729 {
730 const Esc = "U+001B";
731 // We only care about global hotkeys, not about random text
732 if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(even t.keyIdentifier) && event.keyIdentifier != Esc)
apavlov 2013/07/09 06:51:59 !==
733 return;
734 var request = {
735 command: commands.ForwardKeyboardEvent,
736 eventType: event.type,
737 ctrlKey: event.ctrlKey,
738 altKey: event.altKey,
739 metaKey: event.metaKey,
740 keyIdentifier: event.keyIdentifier,
741 keyLocation: event.keyLocation
742 };
743 extensionServer.sendRequest(request);
744 }
745
746 document.addEventListener("keydown", forwardKeyboardEvent, false);
747 document.addEventListener("keypress", forwardKeyboardEvent, false);
748
apavlov 2013/07/09 06:51:59 Would you want to forward "keyup" as well?
727 /** 749 /**
728 * @constructor 750 * @constructor
729 */ 751 */
730 function ExtensionServerClient() 752 function ExtensionServerClient()
731 { 753 {
732 this._callbacks = {}; 754 this._callbacks = {};
733 this._handlers = {}; 755 this._handlers = {};
734 this._lastRequestId = 0; 756 this._lastRequestId = 0;
735 this._lastObjectId = 0; 757 this._lastObjectId = 0;
736 758
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 { 898 {
877 return "(function(injectedScriptId){ " + 899 return "(function(injectedScriptId){ " +
878 "var extensionServer;" + 900 "var extensionServer;" +
879 defineCommonExtensionSymbols.toString() + ";" + 901 defineCommonExtensionSymbols.toString() + ";" +
880 injectedExtensionAPI.toString() + ";" + 902 injectedExtensionAPI.toString() + ";" +
881 buildPlatformExtensionAPI(extensionInfo) + ";" + 903 buildPlatformExtensionAPI(extensionInfo) + ";" +
882 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + 904 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" +
883 "return {};" + 905 "return {};" +
884 "})"; 906 "})";
885 } 907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698