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

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

Issue 155514: Implement extension specific events (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
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.
(...skipping 12 matching lines...) Expand all
23 native function GetTab(); 23 native function GetTab();
24 native function GetSelectedTab(); 24 native function GetSelectedTab();
25 native function GetAllTabsInWindow(); 25 native function GetAllTabsInWindow();
26 native function CreateTab(); 26 native function CreateTab();
27 native function UpdateTab(); 27 native function UpdateTab();
28 native function MoveTab(); 28 native function MoveTab();
29 native function RemoveTab(); 29 native function RemoveTab();
30 native function GetTabLanguage(); 30 native function GetTabLanguage();
31 native function EnablePageAction(); 31 native function EnablePageAction();
32 native function DisablePageAction(); 32 native function DisablePageAction();
33 native function GetCurrentPageActions();
33 native function GetBookmarks(); 34 native function GetBookmarks();
34 native function GetBookmarkChildren(); 35 native function GetBookmarkChildren();
35 native function GetBookmarkTree(); 36 native function GetBookmarkTree();
36 native function SearchBookmarks(); 37 native function SearchBookmarks();
37 native function RemoveBookmark(); 38 native function RemoveBookmark();
38 native function CreateBookmark(); 39 native function CreateBookmark();
39 native function MoveBookmark(); 40 native function MoveBookmark();
40 native function SetBookmarkTitle(); 41 native function SetBookmarkTitle();
41 native function GetChromeHidden(); 42 native function GetChromeHidden();
42 native function GetNextRequestId(); 43 native function GetNextRequestId();
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 { 391 {
391 type: "object", 392 type: "object",
392 properties: { 393 properties: {
393 tabId: chrome.types.pInt, 394 tabId: chrome.types.pInt,
394 url: chrome.types.str 395 url: chrome.types.str
395 }, 396 },
396 optional: false 397 optional: false
397 } 398 }
398 ]; 399 ];
399 400
400 // Sends ({pageActionId, tabId, tabUrl}). 401 // Page action events send (pageActionId, {tabId, tabUrl}).
401 chrome.pageActions.onExecute = 402 function setupEventListeners(extensionId) {
Aaron Boodman 2009/07/14 21:28:52 Rename this to something like setupPageActionEvent
402 new chrome.Event("page-action-executed"); 403 var pageActions = GetCurrentPageActions();
404 for (var i = 0; i < pageActions.length; ++i) {
405 var eventName = extensionId + "/" + pageActions[i];
Aaron Boodman 2009/07/14 21:28:52 Nit: there's no block scope in JavaScript so this
406 // Setup events for each extension_id/page_action_id string we find.
407 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName);
408 }
409 }
403 410
404 //---------------------------------------------------------------------------- 411 //----------------------------------------------------------------------------
405 // Bookmarks 412 // Bookmarks
406 chrome.bookmarks = {}; 413 chrome.bookmarks = {};
407 414
408 chrome.bookmarks.get = function(ids, callback) { 415 chrome.bookmarks.get = function(ids, callback) {
409 validate(arguments, arguments.callee.params); 416 validate(arguments, arguments.callee.params);
410 sendRequest(GetBookmarks, ids, callback); 417 sendRequest(GetBookmarks, ids, callback);
411 }; 418 };
412 419
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 //---------------------------------------------------------------------------- 548 //----------------------------------------------------------------------------
542 549
543 // Self. 550 // Self.
544 chrome.self = chrome.self || {}; 551 chrome.self = chrome.self || {};
545 552
546 chromeHidden.onLoad.addListener(function (extensionId) { 553 chromeHidden.onLoad.addListener(function (extensionId) {
547 chrome.extension = new chrome.Extension(extensionId); 554 chrome.extension = new chrome.Extension(extensionId);
548 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0. 555 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0.
549 // http://code.google.com/p/chromium/issues/detail?id=16356 556 // http://code.google.com/p/chromium/issues/detail?id=16356
550 chrome.self.onConnect = new chrome.Event("channel-connect:" + extensionId); 557 chrome.self.onConnect = new chrome.Event("channel-connect:" + extensionId);
558
559 setupEventListeners(extensionId);
551 }); 560 });
552 561
553 chrome.self.getViews = function() { 562 chrome.self.getViews = function() {
554 return GetViews(); 563 return GetViews();
555 } 564 }
556 })(); 565 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698