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

Side by Side Diff: chrome/renderer/resources/extensions/miscellaneous_bindings.js

Issue 10698163: Make miscellaneous_bindings.js not depend on onLoad(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 unprivileged javascript APIs related to chrome 5 // This script contains unprivileged javascript APIs related to chrome
6 // extensions. It is loaded by any extension-related context, such as content 6 // extensions. It is loaded by any extension-related context, such as content
7 // scripts or background pages. 7 // scripts or background pages.
8 // See user_script_slave.cc for script that is loaded by content scripts only. 8 // See user_script_slave.cc for script that is loaded by content scripts only.
9 9
10 require('json_schema'); 10 require('json_schema');
11 require('event_bindings'); 11 require('event_bindings');
12 var lastError = require('lastError'); 12 var lastError = require('lastError');
13 var miscNatives = requireNative('miscellaneous_bindings'); 13 var miscNatives = requireNative('miscellaneous_bindings');
14 var CloseChannel = miscNatives.CloseChannel; 14 var CloseChannel = miscNatives.CloseChannel;
15 var PortAddRef = miscNatives.PortAddRef; 15 var PortAddRef = miscNatives.PortAddRef;
16 var PortRelease = miscNatives.PortRelease; 16 var PortRelease = miscNatives.PortRelease;
17 var PostMessage = miscNatives.PostMessage; 17 var PostMessage = miscNatives.PostMessage;
18 var BindToGC = miscNatives.BindToGC; 18 var BindToGC = miscNatives.BindToGC;
19 19
20 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 20 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
21 var manifestVersion; 21
22 var extensionId; 22 var processNatives = requireNative('process');
23 var manifestVersion = processNatives.GetManifestVersion();
24 var extensionId = processNatives.GetExtensionId();
25
26 chrome.extension = chrome.extension || {};
27
28 if (manifestVersion < 2) {
29 chrome.self = chrome.extension;
30 chrome.extension.inIncognitoTab = inIncognitoContext;
not at google - send to devlin 2012/07/12 05:47:41 A more appropriate place for this stuff would be i
koz (OOO until 15th September) 2012/07/12 06:06:12 Done.
31 }
32
33 chrome.extension.inIncognitoContext = inIncognitoContext;
23 34
24 // The reserved channel name for the sendRequest/sendMessage APIs. 35 // The reserved channel name for the sendRequest/sendMessage APIs.
25 // Note: sendRequest is deprecated. 36 // Note: sendRequest is deprecated.
26 chromeHidden.kRequestChannel = "chrome.extension.sendRequest"; 37 chromeHidden.kRequestChannel = "chrome.extension.sendRequest";
27 chromeHidden.kMessageChannel = "chrome.extension.sendMessage"; 38 chromeHidden.kMessageChannel = "chrome.extension.sendMessage";
28 39
29 // Map of port IDs to port object. 40 // Map of port IDs to port object.
30 var ports = {}; 41 var ports = {};
31 42
32 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these 43 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 }); 292 });
282 port.onMessage.addListener(function(response) { 293 port.onMessage.addListener(function(response) {
283 try { 294 try {
284 responseCallback(response); 295 responseCallback(response);
285 } finally { 296 } finally {
286 port.disconnect(); 297 port.disconnect();
287 port = null; 298 port = null;
288 } 299 }
289 }); 300 });
290 } 301 }
291
292 // This function is called on context initialization for both content scripts
293 // and extension contexts.
294 chromeHidden.onLoad.addListener(function(tempExtensionId,
295 isExtensionProcess,
296 inIncognitoContext,
297 tempManifestVersion) {
298 extensionId = tempExtensionId;
299 manifestVersion = tempManifestVersion;
300
301 chrome.extension = chrome.extension || {};
302
303 if (manifestVersion < 2) {
304 chrome.self = chrome.extension;
305 chrome.extension.inIncognitoTab = inIncognitoContext;
306 }
307
308 chrome.extension.inIncognitoContext = inIncognitoContext;
309 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698