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

Side by Side Diff: extensions/renderer/resources/runtime_custom_bindings.js

Issue 2105033003: tabId support to chrome.extensions.getViews() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor followup to patch 5 Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Custom binding for the runtime API. 5 // Custom binding for the runtime API.
6 6
7 var binding = require('binding').Binding.create('runtime'); 7 var binding = require('binding').Binding.create('runtime');
8 8
9 var messaging = require('messaging'); 9 var messaging = require('messaging');
10 var runtimeNatives = requireNative('runtime'); 10 var runtimeNatives = requireNative('runtime');
(...skipping 13 matching lines...) Expand all
24 var backgroundPage = WINDOW; 24 var backgroundPage = WINDOW;
25 var backgroundRequire = require; 25 var backgroundRequire = require;
26 var contextType = process.GetContextType(); 26 var contextType = process.GetContextType();
27 27
28 if (contextType == 'BLESSED_EXTENSION' || 28 if (contextType == 'BLESSED_EXTENSION' ||
29 contextType == 'UNBLESSED_EXTENSION') { 29 contextType == 'UNBLESSED_EXTENSION') {
30 var manifest = runtimeNatives.GetManifest(); 30 var manifest = runtimeNatives.GetManifest();
31 if (manifest.app && manifest.app.background) { 31 if (manifest.app && manifest.app.background) {
32 // Get the background page if one exists. Otherwise, default to the current 32 // Get the background page if one exists. Otherwise, default to the current
33 // window. 33 // window.
34 backgroundPage = runtimeNatives.GetExtensionViews(-1, 'BACKGROUND')[0]; 34 backgroundPage = runtimeNatives.GetExtensionViews(-1, -1, 'BACKGROUND')[0];
35 if (backgroundPage) { 35 if (backgroundPage) {
36 var GetModuleSystem = requireNative('v8_context').GetModuleSystem; 36 var GetModuleSystem = requireNative('v8_context').GetModuleSystem;
37 backgroundRequire = GetModuleSystem(backgroundPage).require; 37 backgroundRequire = GetModuleSystem(backgroundPage).require;
38 } else { 38 } else {
39 backgroundPage = WINDOW; 39 backgroundPage = WINDOW;
40 } 40 }
41 } 41 }
42 } 42 }
43 43
44 // For packaged apps, all windows use the bindFileEntryCallback from the 44 // For packaged apps, all windows use the bindFileEntryCallback from the
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 function(nativeAppName) { 170 function(nativeAppName) {
171 var portId = runtimeNatives.OpenChannelToNativeApp(nativeAppName); 171 var portId = runtimeNatives.OpenChannelToNativeApp(nativeAppName);
172 if (portId >= 0) 172 if (portId >= 0)
173 return messaging.createPort(portId, ''); 173 return messaging.createPort(portId, '');
174 throw new Error('Error connecting to native app: ' + nativeAppName); 174 throw new Error('Error connecting to native app: ' + nativeAppName);
175 }); 175 });
176 176
177 apiFunctions.setCustomCallback('getBackgroundPage', 177 apiFunctions.setCustomCallback('getBackgroundPage',
178 function(name, request, callback, response) { 178 function(name, request, callback, response) {
179 if (callback) { 179 if (callback) {
180 var bg = runtimeNatives.GetExtensionViews(-1, 'BACKGROUND')[0] || null; 180 var bg =
181 runtimeNatives.GetExtensionViews(-1, -1, 'BACKGROUND')[0] || null;
181 callback(bg); 182 callback(bg);
182 } 183 }
183 }); 184 });
184 185
185 bindDirectoryEntryCallback('getPackageDirectoryEntry', apiFunctions); 186 bindDirectoryEntryCallback('getPackageDirectoryEntry', apiFunctions);
186 }); 187 });
187 188
188 exports.$set('bindDirectoryEntryCallback', bindDirectoryEntryCallback); 189 exports.$set('bindDirectoryEntryCallback', bindDirectoryEntryCallback);
189 exports.$set('binding', binding.generate()); 190 exports.$set('binding', binding.generate());
OLDNEW
« no previous file with comments | « extensions/renderer/resources/extension_custom_bindings.js ('k') | extensions/renderer/runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698