OLD | NEW |
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 GetExtensionAPIDefinition(); | 10 native function GetExtensionAPIDefinition(); |
11 native function StartRequest(); | 11 native function StartRequest(); |
12 native function GetCurrentPageActions(extensionId); | 12 native function GetCurrentPageActions(extensionId); |
13 native function GetExtensionViews(); | 13 native function GetExtensionViews(); |
14 native function GetChromeHidden(); | 14 native function GetChromeHidden(); |
15 native function GetNextRequestId(); | 15 native function GetNextRequestId(); |
16 native function GetNextContextMenuId(); | 16 native function GetNextContextMenuId(); |
17 native function GetNextTtsEventId(); | 17 native function GetNextTtsEventId(); |
18 native function OpenChannelToTab(); | 18 native function OpenChannelToTab(); |
19 native function GetRenderViewId(); | 19 native function GetRenderViewId(); |
20 native function SetIconCommon(); | 20 native function SetIconCommon(); |
21 native function IsExtensionProcess(); | 21 native function IsExtensionProcess(); |
22 native function IsIncognitoProcess(); | 22 native function IsIncognitoProcess(); |
23 native function GetUniqueSubEventName(eventName); | 23 native function GetUniqueSubEventName(eventName); |
24 native function GetLocalFileSystem(name, path); | 24 native function GetLocalFileSystem(name, path); |
25 native function DecodeJPEG(jpeg_image); | 25 native function DecodeJPEG(jpeg_image); |
| 26 native function Print(); |
26 | 27 |
27 var chromeHidden = GetChromeHidden(); | 28 var chromeHidden = GetChromeHidden(); |
28 | 29 |
29 // These bindings are for the extension process only. Since a chrome-extension | 30 // These bindings are for the extension process only. Since a chrome-extension |
30 // URL can be loaded in an iframe of a regular renderer, we check here to | 31 // URL can be loaded in an iframe of a regular renderer, we check here to |
31 // ensure we don't expose the APIs in that case. | 32 // ensure we don't expose the APIs in that case. |
32 if (!IsExtensionProcess()) { | 33 if (!IsExtensionProcess()) { |
33 chromeHidden.onLoad.addListener(function (extensionId) { | 34 chromeHidden.onLoad.addListener(function (extensionId) { |
34 if (!extensionId) { | 35 if (!extensionId) { |
35 return; | 36 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 71 } |
71 message += err.message; | 72 message += err.message; |
72 message = message.substring(0, message.length - 1); | 73 message = message.substring(0, message.length - 1); |
73 message += ", "; | 74 message += ", "; |
74 } | 75 } |
75 message = message.substring(0, message.length - 2); | 76 message = message.substring(0, message.length - 2); |
76 message += "."; | 77 message += "."; |
77 | 78 |
78 throw new Error(message); | 79 throw new Error(message); |
79 } else if (!schemas[i].optional) { | 80 } else if (!schemas[i].optional) { |
80 console.log(chromeHidden.JSON.stringify(args)); | |
81 console.log(chromeHidden.JSON.stringify(schemas)); | |
82 throw new Error("Parameter " + (i + 1) + " is required."); | 81 throw new Error("Parameter " + (i + 1) + " is required."); |
83 } | 82 } |
84 } | 83 } |
85 }; | 84 }; |
86 | 85 |
87 // Callback handling. | 86 // Callback handling. |
88 var requests = []; | 87 var requests = []; |
89 chromeHidden.handleResponse = function(requestId, name, | 88 chromeHidden.handleResponse = function(requestId, name, |
90 success, response, error) { | 89 success, response, error) { |
91 try { | 90 try { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 | 1046 |
1048 if (!chrome.experimental.accessibility) | 1047 if (!chrome.experimental.accessibility) |
1049 chrome.experimental.accessibility = {}; | 1048 chrome.experimental.accessibility = {}; |
1050 | 1049 |
1051 if (!chrome.tts) | 1050 if (!chrome.tts) |
1052 chrome.tts = {}; | 1051 chrome.tts = {}; |
1053 | 1052 |
1054 if (!chrome.ttsEngine) | 1053 if (!chrome.ttsEngine) |
1055 chrome.ttsEngine = {}; | 1054 chrome.ttsEngine = {}; |
1056 })(); | 1055 })(); |
OLD | NEW |