| 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 native function IsIncognitoProcess(); |
| 22 | 23 |
| 23 var chromeHidden = GetChromeHidden(); | 24 var chromeHidden = GetChromeHidden(); |
| 24 | 25 |
| 25 // These bindings are for the extension process only. Since a chrome-extension | 26 // 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 | 27 // 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. | 28 // ensure we don't expose the APIs in that case. |
| 28 if (!IsExtensionProcess()) { | 29 if (!IsExtensionProcess()) { |
| 29 chromeHidden.onLoad.addListener(function (extensionId) { | 30 chromeHidden.onLoad.addListener(function (extensionId) { |
| 30 chrome.initExtension(extensionId, false); | 31 chrome.initExtension(extensionId, false); |
| 31 }); | 32 }); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 chrome.experimental.omnibox.onInputChanged.dispatch = | 290 chrome.experimental.omnibox.onInputChanged.dispatch = |
| 290 function(text, requestId) { | 291 function(text, requestId) { |
| 291 var suggestCallback = function(suggestions) { | 292 var suggestCallback = function(suggestions) { |
| 292 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); | 293 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); |
| 293 } | 294 } |
| 294 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); | 295 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); |
| 295 }; | 296 }; |
| 296 } | 297 } |
| 297 | 298 |
| 298 chromeHidden.onLoad.addListener(function (extensionId) { | 299 chromeHidden.onLoad.addListener(function (extensionId) { |
| 299 chrome.initExtension(extensionId, false); | 300 chrome.initExtension(extensionId, false, IsIncognitoProcess()); |
| 300 | 301 |
| 301 // |apiFunctions| is a hash of name -> object that stores the | 302 // |apiFunctions| is a hash of name -> object that stores the |
| 302 // name & definition of the apiFunction. Custom handling of api functions | 303 // name & definition of the apiFunction. Custom handling of api functions |
| 303 // is implemented by adding a "handleRequest" function to the object. | 304 // is implemented by adding a "handleRequest" function to the object. |
| 304 var apiFunctions = {}; | 305 var apiFunctions = {}; |
| 305 | 306 |
| 306 // Read api definitions and setup api functions in the chrome namespace. | 307 // Read api definitions and setup api functions in the chrome namespace. |
| 307 // TODO(rafaelw): Consider defining a json schema for an api definition | 308 // TODO(rafaelw): Consider defining a json schema for an api definition |
| 308 // and validating either here, in a unit_test or both. | 309 // and validating either here, in a unit_test or both. |
| 309 // TODO(rafaelw): Handle synchronous functions. | 310 // TODO(rafaelw): Handle synchronous functions. |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 716 |
| 716 if (!chrome.experimental) | 717 if (!chrome.experimental) |
| 717 chrome.experimental = {}; | 718 chrome.experimental = {}; |
| 718 | 719 |
| 719 if (!chrome.experimental.accessibility) | 720 if (!chrome.experimental.accessibility) |
| 720 chrome.experimental.accessibility = {}; | 721 chrome.experimental.accessibility = {}; |
| 721 | 722 |
| 722 if (!chrome.experimental.tts) | 723 if (!chrome.experimental.tts) |
| 723 chrome.experimental.tts = {}; | 724 chrome.experimental.tts = {}; |
| 724 })(); | 725 })(); |
| OLD | NEW |