| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 OpenChannelToTab(); | 16 native function OpenChannelToTab(); |
| 17 native function GetRenderViewId(); | 17 native function GetRenderViewId(); |
| 18 native function GetPopupParentWindow(); | 18 native function GetPopupParentWindow(); |
| 19 native function GetPopupView(); | 19 native function GetPopupView(); |
| 20 native function SetIconCommon(); | 20 native function SetIconCommon(); |
| 21 native function IsExtensionProcess(); | 21 native function IsExtensionProcess(); |
| 22 | 22 |
| 23 var chromeHidden = GetChromeHidden(); | 23 var chromeHidden = GetChromeHidden(); |
| 24 | 24 |
| 25 // These bindings are for the extension process only. Since a chrome-extension | 25 // These bindings are for the extension process only. Since a chrome-extension |
| 26 // URL can be loaded in an iframe of a regular renderer, we check here to | 26 // URL can be loaded in an iframe of a regular renderer, we check here to |
| 27 // ensure we don't expose the APIs in that case. | 27 // ensure we don't expose the APIs in that case. |
| 28 if (!IsExtensionProcess()) { | 28 if (!IsExtensionProcess()) { |
| 29 chromeHidden.onLoad.addListener(function (extensionId) { | 29 chromeHidden.onLoad.addListener(function (extensionId) { |
| 30 if (!extensionId) { |
| 31 return; |
| 32 } |
| 30 chrome.initExtension(extensionId, false); | 33 chrome.initExtension(extensionId, false); |
| 31 }); | 34 }); |
| 32 return; | 35 return; |
| 33 } | 36 } |
| 34 | 37 |
| 35 if (!chrome) | 38 if (!chrome) |
| 36 chrome = {}; | 39 chrome = {}; |
| 37 | 40 |
| 38 // Validate arguments. | 41 // Validate arguments. |
| 39 chromeHidden.validationTypes = []; | 42 chromeHidden.validationTypes = []; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 chrome.experimental.omnibox.onInputChanged.dispatch = | 292 chrome.experimental.omnibox.onInputChanged.dispatch = |
| 290 function(text, requestId) { | 293 function(text, requestId) { |
| 291 var suggestCallback = function(suggestions) { | 294 var suggestCallback = function(suggestions) { |
| 292 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); | 295 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); |
| 293 } | 296 } |
| 294 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); | 297 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); |
| 295 }; | 298 }; |
| 296 } | 299 } |
| 297 | 300 |
| 298 chromeHidden.onLoad.addListener(function (extensionId) { | 301 chromeHidden.onLoad.addListener(function (extensionId) { |
| 302 if (!extensionId) { |
| 303 return; |
| 304 } |
| 299 chrome.initExtension(extensionId, false); | 305 chrome.initExtension(extensionId, false); |
| 300 | 306 |
| 301 // |apiFunctions| is a hash of name -> object that stores the | 307 // |apiFunctions| is a hash of name -> object that stores the |
| 302 // name & definition of the apiFunction. Custom handling of api functions | 308 // name & definition of the apiFunction. Custom handling of api functions |
| 303 // is implemented by adding a "handleRequest" function to the object. | 309 // is implemented by adding a "handleRequest" function to the object. |
| 304 var apiFunctions = {}; | 310 var apiFunctions = {}; |
| 305 | 311 |
| 306 // Read api definitions and setup api functions in the chrome namespace. | 312 // Read api definitions and setup api functions in the chrome namespace. |
| 307 // TODO(rafaelw): Consider defining a json schema for an api definition | 313 // TODO(rafaelw): Consider defining a json schema for an api definition |
| 308 // and validating either here, in a unit_test or both. | 314 // and validating either here, in a unit_test or both. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 721 |
| 716 if (!chrome.experimental) | 722 if (!chrome.experimental) |
| 717 chrome.experimental = {}; | 723 chrome.experimental = {}; |
| 718 | 724 |
| 719 if (!chrome.experimental.accessibility) | 725 if (!chrome.experimental.accessibility) |
| 720 chrome.experimental.accessibility = {}; | 726 chrome.experimental.accessibility = {}; |
| 721 | 727 |
| 722 if (!chrome.experimental.tts) | 728 if (!chrome.experimental.tts) |
| 723 chrome.experimental.tts = {}; | 729 chrome.experimental.tts = {}; |
| 724 })(); | 730 })(); |
| OLD | NEW |