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

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

Issue 155707: Changed the extension.connect() API not to broadcast to all tabs. Added a (Closed)
Patch Set: review comments Created 11 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
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/testing_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The chrome Authors. All rights reserved. 1 // Copyright (c) 2009 The chrome 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 // ----------------------------------------------------------------------------- 5 // -----------------------------------------------------------------------------
6 // NOTE: If you change this file you need to touch renderer_resources.grd to 6 // NOTE: If you change this file you need to touch renderer_resources.grd to
7 // have your change take effect. 7 // have your change take effect.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 9
10 // This script contains privileged chrome extension related javascript APIs. 10 // This script contains privileged chrome extension related javascript APIs.
11 // It is loaded by pages whose URL has the chrome-extension protocol. 11 // It is loaded by pages whose URL has the chrome-extension protocol.
12 12
13 var chrome = chrome || {}; 13 var chrome = chrome || {};
14 (function() { 14 (function() {
15 native function StartRequest(); 15 native function StartRequest();
16 native function GetCurrentPageActions(); 16 native function GetCurrentPageActions();
17 native function GetViews(); 17 native function GetViews();
18 native function GetChromeHidden(); 18 native function GetChromeHidden();
19 native function GetNextRequestId(); 19 native function GetNextRequestId();
20 native function OpenChannelToTab();
20 21
21 if (!chrome) 22 if (!chrome)
22 chrome = {}; 23 chrome = {};
23 24
24 var chromeHidden = GetChromeHidden(); 25 var chromeHidden = GetChromeHidden();
25 26
26 // Validate arguments. 27 // Validate arguments.
27 function validate(args, schemas) { 28 function validate(args, schemas) {
28 if (args.length > schemas.length) 29 if (args.length > schemas.length)
29 throw new Error("Too many arguments."); 30 throw new Error("Too many arguments.");
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 chrome.tabs.detectLanguage = function(tabId, callback) { 298 chrome.tabs.detectLanguage = function(tabId, callback) {
298 validate(arguments, arguments.callee.params); 299 validate(arguments, arguments.callee.params);
299 sendRequest("tabs.detectLanguage", tabId, callback); 300 sendRequest("tabs.detectLanguage", tabId, callback);
300 }; 301 };
301 302
302 chrome.tabs.detectLanguage.params = [ 303 chrome.tabs.detectLanguage.params = [
303 chrome.types.optPInt, 304 chrome.types.optPInt,
304 chrome.types.optFun 305 chrome.types.optFun
305 ]; 306 ];
306 307
308 chrome.tabs.connect = function(tabId, opt_name) {
309 validate(arguments, arguments.callee.params);
310 var portId = OpenChannelToTab(tabId, chrome.extension.id_, opt_name || "");
311 return chromeHidden.Port.createPort(portId, opt_name);
312 };
313
314 chrome.tabs.connect.params = [
315 chrome.types.pInt,
316 chrome.types.optStr
317 ];
318
307 // Sends ({Tab}). 319 // Sends ({Tab}).
308 // Will *NOT* be followed by tab-attached - it is implied. 320 // Will *NOT* be followed by tab-attached - it is implied.
309 // *MAY* be followed by tab-selection-changed. 321 // *MAY* be followed by tab-selection-changed.
310 chrome.tabs.onCreated = new chrome.Event("tabs.onCreated"); 322 chrome.tabs.onCreated = new chrome.Event("tabs.onCreated");
311 323
312 // Sends (tabId, {ChangedProps}). 324 // Sends (tabId, {ChangedProps}).
313 chrome.tabs.onUpdated = new chrome.Event("tabs.onUpdated"); 325 chrome.tabs.onUpdated = new chrome.Event("tabs.onUpdated");
314 326
315 // Sends (tabId, {windowId, fromIndex, toIndex}). 327 // Sends (tabId, {windowId, fromIndex, toIndex}).
316 // Tabs can only "move" within a window. 328 // Tabs can only "move" within a window.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 536
525 //---------------------------------------------------------------------------- 537 //----------------------------------------------------------------------------
526 538
527 // Self. 539 // Self.
528 chrome.self = chrome.self || {}; 540 chrome.self = chrome.self || {};
529 541
530 chromeHidden.onLoad.addListener(function (extensionId) { 542 chromeHidden.onLoad.addListener(function (extensionId) {
531 chrome.extension = new chrome.Extension(extensionId); 543 chrome.extension = new chrome.Extension(extensionId);
532 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0. 544 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0.
533 // http://code.google.com/p/chromium/issues/detail?id=16356 545 // http://code.google.com/p/chromium/issues/detail?id=16356
534 chrome.self.onConnect = new chrome.Event("channel-connect:" + extensionId); 546 chrome.self.onConnect = chrome.extension.onConnect;
535 547
536 setupPageActionEvents(extensionId); 548 setupPageActionEvents(extensionId);
537 }); 549 });
538 550
539 chrome.self.getViews = function() { 551 chrome.self.getViews = function() {
540 return GetViews(); 552 return GetViews();
541 } 553 }
542 })(); 554 })();
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698