Chromium Code Reviews| 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(); | |
| 22 native function IsIncognitoProcess(); | |
| 23 native function GetUniqueSubEventName(eventName); | 21 native function GetUniqueSubEventName(eventName); |
| 24 native function GetLocalFileSystem(name, path); | 22 native function GetLocalFileSystem(name, path); |
| 25 native function DecodeJPEG(jpeg_image); | 23 native function DecodeJPEG(jpeg_image); |
| 26 native function Print(); | 24 native function Print(); |
| 27 | 25 |
| 28 var chromeHidden = GetChromeHidden(); | 26 var chromeHidden = GetChromeHidden(); |
| 29 | 27 |
| 30 // These bindings are for the extension process only. Since a chrome-extension | |
| 31 // URL can be loaded in an iframe of a regular renderer, we check here to | |
| 32 // ensure we don't expose the APIs in that case. | |
| 33 if (!IsExtensionProcess()) { | |
| 34 chromeHidden.onLoad.addListener(function (extensionId) { | |
| 35 if (!extensionId) { | |
| 36 return; | |
| 37 } | |
| 38 chrome.initExtension(extensionId, false); | |
| 39 }); | |
| 40 return; | |
| 41 } | |
| 42 | |
| 43 if (!chrome) | 28 if (!chrome) |
| 44 chrome = {}; | 29 chrome = {}; |
| 45 | 30 |
| 46 function forEach(dict, f) { | 31 function forEach(dict, f) { |
| 47 for (key in dict) { | 32 for (key in dict) { |
| 48 if (dict.hasOwnProperty(key)) | 33 if (dict.hasOwnProperty(key)) |
| 49 f(key, dict[key]); | 34 f(key, dict[key]); |
| 50 } | 35 } |
| 51 } | 36 } |
| 52 | 37 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 ]; | 568 ]; |
| 584 | 569 |
| 585 for (var i = 0; i < platforms.length; i++) { | 570 for (var i = 0; i < platforms.length; i++) { |
| 586 if (platforms[i][0].test(navigator.appVersion)) { | 571 if (platforms[i][0].test(navigator.appVersion)) { |
| 587 return platforms[i][1]; | 572 return platforms[i][1]; |
| 588 } | 573 } |
| 589 } | 574 } |
| 590 return "unknown"; | 575 return "unknown"; |
| 591 } | 576 } |
| 592 | 577 |
| 593 chromeHidden.onLoad.addListener(function (extensionId) { | 578 chromeHidden.onLoad.addListener(function(extensionId, isExtensionProcess, |
| 594 if (!extensionId) { | 579 isIncognitoProcess) { |
| 580 if (!isExtensionProcess) | |
|
Matt Perry
2011/08/24 22:11:34
not all the extension-specific code is in this lis
| |
| 595 return; | 581 return; |
| 596 } | |
| 597 chrome.initExtension(extensionId, false, IsIncognitoProcess()); | |
| 598 | 582 |
| 599 // Setup the ChromeSetting class so we can use it to construct | 583 // Setup the ChromeSetting class so we can use it to construct |
| 600 // ChromeSetting objects from the API definition. | 584 // ChromeSetting objects from the API definition. |
| 601 setupChromeSetting(); | 585 setupChromeSetting(); |
| 602 | 586 |
| 603 // Setup the ContentSetting class so we can use it to construct | 587 // Setup the ContentSetting class so we can use it to construct |
| 604 // ContentSetting objects from the API definition. | 588 // ContentSetting objects from the API definition. |
| 605 setupContentSetting(); | 589 setupContentSetting(); |
| 606 | 590 |
| 607 // |apiFunctions| is a hash of name -> object that stores the | 591 // |apiFunctions| is a hash of name -> object that stores the |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1049 | 1033 |
| 1050 if (!chrome.tts) | 1034 if (!chrome.tts) |
| 1051 chrome.tts = {}; | 1035 chrome.tts = {}; |
| 1052 | 1036 |
| 1053 if (!chrome.ttsEngine) | 1037 if (!chrome.ttsEngine) |
| 1054 chrome.ttsEngine = {}; | 1038 chrome.ttsEngine = {}; |
| 1055 | 1039 |
| 1056 if (!chrome.experimental.downloads) | 1040 if (!chrome.experimental.downloads) |
| 1057 chrome.experimental.downloads = {}; | 1041 chrome.experimental.downloads = {}; |
| 1058 })(); | 1042 })(); |
| OLD | NEW |