| OLD | NEW |
| 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 838 } |
| 839 | 839 |
| 840 /** | 840 /** |
| 841 * @constructor | 841 * @constructor |
| 842 */ | 842 */ |
| 843 function TimelineImpl() | 843 function TimelineImpl() |
| 844 { | 844 { |
| 845 this.onEventRecorded = new EventSink(events.TimelineEventRecorded); | 845 this.onEventRecorded = new EventSink(events.TimelineEventRecorded); |
| 846 } | 846 } |
| 847 | 847 |
| 848 var keyboardEventRequestQueue = []; |
| 849 var forwardTimer = null; |
| 850 |
| 848 function forwardKeyboardEvent(event) | 851 function forwardKeyboardEvent(event) |
| 849 { | 852 { |
| 850 const Esc = "U+001B"; | 853 const Esc = "U+001B"; |
| 851 // We only care about global hotkeys, not about random text | 854 // We only care about global hotkeys, not about random text |
| 852 if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(even
t.keyIdentifier) && event.keyIdentifier !== Esc) | 855 if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(even
t.keyIdentifier) && event.keyIdentifier !== Esc) |
| 853 return; | 856 return; |
| 854 var request = { | 857 var requestPayload = { |
| 855 command: commands.ForwardKeyboardEvent, | |
| 856 eventType: event.type, | 858 eventType: event.type, |
| 857 ctrlKey: event.ctrlKey, | 859 ctrlKey: event.ctrlKey, |
| 858 altKey: event.altKey, | 860 altKey: event.altKey, |
| 859 metaKey: event.metaKey, | 861 metaKey: event.metaKey, |
| 860 keyIdentifier: event.keyIdentifier, | 862 keyIdentifier: event.keyIdentifier, |
| 861 location: event.location | 863 location: event.location, |
| 864 keyCode: event.keyCode |
| 865 }; |
| 866 keyboardEventRequestQueue.push(requestPayload); |
| 867 if (!forwardTimer) |
| 868 forwardTimer = setTimeout(forwardEventQueue, 0); |
| 869 } |
| 870 |
| 871 function forwardEventQueue() |
| 872 { |
| 873 forwardTimer = null; |
| 874 var request = { |
| 875 command: commands.ForwardKeyboardEvent, |
| 876 entries: keyboardEventRequestQueue |
| 862 }; | 877 }; |
| 863 extensionServer.sendRequest(request); | 878 extensionServer.sendRequest(request); |
| 879 keyboardEventRequestQueue = []; |
| 864 } | 880 } |
| 865 | 881 |
| 866 document.addEventListener("keydown", forwardKeyboardEvent, false); | 882 document.addEventListener("keydown", forwardKeyboardEvent, false); |
| 867 document.addEventListener("keypress", forwardKeyboardEvent, false); | 883 document.addEventListener("keypress", forwardKeyboardEvent, false); |
| 868 | 884 |
| 869 /** | 885 /** |
| 870 * @constructor | 886 * @constructor |
| 871 */ | 887 */ |
| 872 function ExtensionServerClient() | 888 function ExtensionServerClient() |
| 873 { | 889 { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 { | 1049 { |
| 1034 return "(function(injectedScriptId){ " + | 1050 return "(function(injectedScriptId){ " + |
| 1035 "var extensionServer;" + | 1051 "var extensionServer;" + |
| 1036 defineCommonExtensionSymbols.toString() + ";" + | 1052 defineCommonExtensionSymbols.toString() + ";" + |
| 1037 injectedExtensionAPI.toString() + ";" + | 1053 injectedExtensionAPI.toString() + ";" + |
| 1038 buildPlatformExtensionAPI(extensionInfo) + ";" + | 1054 buildPlatformExtensionAPI(extensionInfo) + ";" + |
| 1039 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + | 1055 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + |
| 1040 "return {};" + | 1056 "return {};" + |
| 1041 "})"; | 1057 "})"; |
| 1042 } | 1058 } |
| OLD | NEW |