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

Side by Side Diff: chrome/renderer/resources/extensions/schema_generated_bindings.js

Issue 8896013: Implement onEvent callback framework for UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put back the bracket. Created 9 years 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
« no previous file with comments | « chrome/renderer/extensions/schema_generated_bindings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 var chrome = chrome || {}; 8 var chrome = chrome || {};
9 (function() { 9 (function() {
10 native function GetChromeHidden();
10 native function GetExtensionAPIDefinition(); 11 native function GetExtensionAPIDefinition();
11 native function StartRequest();
12 native function GetChromeHidden();
13 native function GetNextRequestId(); 12 native function GetNextRequestId();
14 native function Print(); 13 native function Print();
14 native function StartRequest();
15 15
16 native function CreateBlob(filePath);
17 native function DecodeJPEG(jpegImage);
16 native function GetCurrentPageActions(extensionId); 18 native function GetCurrentPageActions(extensionId);
17 native function GetExtensionViews(); 19 native function GetExtensionViews();
20 native function GetLocalFileSystem(name, path);
18 native function GetNextContextMenuId(); 21 native function GetNextContextMenuId();
22 native function GetNextSocketEventId();
19 native function GetNextTtsEventId(); 23 native function GetNextTtsEventId();
24 native function GetRenderViewId();
25 native function GetUniqueSubEventName(eventName);
20 native function OpenChannelToTab(); 26 native function OpenChannelToTab();
21 native function GetRenderViewId(); 27 native function SendResponseAck(requestId);
22 native function SetIconCommon(); 28 native function SetIconCommon();
23 native function GetUniqueSubEventName(eventName);
24 native function GetLocalFileSystem(name, path);
25 native function DecodeJPEG(jpegImage);
26 native function CreateBlob(filePath);
27 native function SendResponseAck(requestId);
28 29
29 var chromeHidden = GetChromeHidden(); 30 var chromeHidden = GetChromeHidden();
30 31
31 if (!chrome) 32 if (!chrome)
32 chrome = {}; 33 chrome = {};
33 34
34 function forEach(dict, f) { 35 function forEach(dict, f) {
35 for (key in dict) { 36 for (key in dict) {
36 if (dict.hasOwnProperty(key)) 37 if (dict.hasOwnProperty(key))
37 f(key, dict[key]); 38 f(key, dict[key]);
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 delete chromeHidden.tts.handlers[event.srcId]; 579 delete chromeHidden.tts.handlers[event.srcId];
579 } 580 }
580 } 581 }
581 }); 582 });
582 } catch (e) { 583 } catch (e) {
583 // This extension doesn't have permission to access TTS, so we 584 // This extension doesn't have permission to access TTS, so we
584 // can safely ignore this. 585 // can safely ignore this.
585 } 586 }
586 } 587 }
587 588
589 function setupSocketEvents() {
590 chromeHidden.socket = {};
591 chromeHidden.socket.handlers = {};
592 try {
593 chrome.experimental.socket.onEvent.addListener(
594 function(event) {
595 var eventHandler = chromeHidden.socket.handlers[event.srcId];
596 if (eventHandler) {
597 eventHandler({
598 type: event.type,
599 resultCode: event.resultCode,
600 });
601 if (event.isFinalEvent) {
602 delete chromeHidden.socket.handlers[event.srcId];
603 }
604 }
605 });
606 } catch (e) {
607 console.error(e);
608 }
609 }
610
588 // Get the platform from navigator.appVersion. 611 // Get the platform from navigator.appVersion.
589 function getPlatform() { 612 function getPlatform() {
590 var platforms = [ 613 var platforms = [
591 [/CrOS Touch/, "chromeos touch"], 614 [/CrOS Touch/, "chromeos touch"],
592 [/CrOS/, "chromeos"], 615 [/CrOS/, "chromeos"],
593 [/Linux/, "linux"], 616 [/Linux/, "linux"],
594 [/Mac/, "mac"], 617 [/Mac/, "mac"],
595 [/Win/, "win"], 618 [/Win/, "win"],
596 ]; 619 ];
597 620
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 var args = arguments; 1108 var args = arguments;
1086 if (args.length > 1 && args[1] && args[1].onEvent) { 1109 if (args.length > 1 && args[1] && args[1].onEvent) {
1087 var id = GetNextTtsEventId(); 1110 var id = GetNextTtsEventId();
1088 args[1].srcId = id; 1111 args[1].srcId = id;
1089 chromeHidden.tts.handlers[id] = args[1].onEvent; 1112 chromeHidden.tts.handlers[id] = args[1].onEvent;
1090 } 1113 }
1091 sendRequest(this.name, args, this.definition.parameters); 1114 sendRequest(this.name, args, this.definition.parameters);
1092 return id; 1115 return id;
1093 }; 1116 };
1094 1117
1118 apiFunctions["experimental.socket.create"].handleRequest = function() {
1119 var args = arguments;
1120 if (args.length > 1 && args[1] && args[1].onEvent) {
1121 var id = GetNextSocketEventId();
1122 args[1].srcId = id;
1123 chromeHidden.socket.handlers[id] = args[1].onEvent;
1124 }
1125 sendRequest(this.name, args, this.definition.parameters);
1126 return id;
1127 };
1128
1095 if (chrome.test) { 1129 if (chrome.test) {
1096 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; 1130 chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
1097 } 1131 }
1098 1132
1099 setupPageActionEvents(extensionId);
1100 setupHiddenContextMenuEvent(extensionId); 1133 setupHiddenContextMenuEvent(extensionId);
1101 setupInputEvents(); 1134 setupInputEvents();
1102 setupOmniboxEvents(); 1135 setupOmniboxEvents();
1136 setupPageActionEvents(extensionId);
1137 setupSocketEvents();
1103 setupTtsEvents(); 1138 setupTtsEvents();
1104 }); 1139 });
1105 1140
1106 if (!chrome.experimental) 1141 if (!chrome.experimental)
1107 chrome.experimental = {}; 1142 chrome.experimental = {};
1108 1143
1109 if (!chrome.experimental.accessibility) 1144 if (!chrome.experimental.accessibility)
1110 chrome.experimental.accessibility = {}; 1145 chrome.experimental.accessibility = {};
1111 1146
1112 if (!chrome.experimental.speechInput) 1147 if (!chrome.experimental.speechInput)
1113 chrome.experimental.speechInput = {}; 1148 chrome.experimental.speechInput = {};
1114 1149
1150 if (!chrome.experimental.socket)
1151 chrome.experimental.socket = {};
1152
1115 if (!chrome.tts) 1153 if (!chrome.tts)
1116 chrome.tts = {}; 1154 chrome.tts = {};
1117 1155
1118 if (!chrome.ttsEngine) 1156 if (!chrome.ttsEngine)
1119 chrome.ttsEngine = {}; 1157 chrome.ttsEngine = {};
1120 1158
1121 if (!chrome.experimental.downloads) 1159 if (!chrome.experimental.downloads)
1122 chrome.experimental.downloads = {}; 1160 chrome.experimental.downloads = {};
1123 })(); 1161 })();
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/schema_generated_bindings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698