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

Side by Side Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 7727004: Initialize content scripts the same way extension scripts are. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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
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 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
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
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 })();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/event_bindings.js ('k') | chrome/renderer/resources/renderer_extension_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698