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

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

Issue 385061: experimental.popup support for tab-content-viewed extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 // 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 OpenChannelToTab(); 16 native function OpenChannelToTab();
17 native function GetRenderViewId(); 17 native function GetRenderViewId();
18 native function GetL10nMessage(); 18 native function GetL10nMessage();
19 native function GetPopupAnchorView(); 19 native function GetPopupParentWindow();
20 native function GetPopupView(); 20 native function GetPopupView();
21 native function SetExtensionActionIcon(); 21 native function SetExtensionActionIcon();
22 22
23 if (!chrome) 23 if (!chrome)
24 chrome = {}; 24 chrome = {};
25 25
26 var chromeHidden = GetChromeHidden(); 26 var chromeHidden = GetChromeHidden();
27 27
28 // Validate arguments. 28 // Validate arguments.
29 chromeHidden.validationTypes = []; 29 chromeHidden.validationTypes = [];
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return { 219 return {
220 top: curtop, 220 top: curtop,
221 left: curleft 221 left: curleft
222 }; 222 };
223 } 223 }
224 224
225 // Returns the coordiates of the rectangle encompassing the domElement, 225 // Returns the coordiates of the rectangle encompassing the domElement,
226 // in browser coordinates relative to the frame hosting the element. 226 // in browser coordinates relative to the frame hosting the element.
227 function getAbsoluteRect(domElement) { 227 function getAbsoluteRect(domElement) {
228 var rect = findAbsolutePosition(domElement); 228 var rect = findAbsolutePosition(domElement);
229 rect.width = domElement.width || 0; 229 rect.width = domElement.offsetWidth || 0;
230 rect.height = domElement.height || 0; 230 rect.height = domElement.offsetHeight || 0;
231 return rect; 231 return rect;
232 } 232 }
233 233
234 // --- Setup additional api's not currently handled in common/extensions/api 234 // --- Setup additional api's not currently handled in common/extensions/api
235 235
236 // Page action events send (pageActionId, {tabId, tabUrl}). 236 // Page action events send (pageActionId, {tabId, tabUrl}).
237 function setupPageActionEvents(extensionId) { 237 function setupPageActionEvents(extensionId) {
238 var pageActions = GetCurrentPageActions(extensionId); 238 var pageActions = GetCurrentPageActions(extensionId);
239 239
240 var oldStyleEventName = "pageActions/" + extensionId; 240 var oldStyleEventName = "pageActions/" + extensionId;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (module[functionDef.name]) 310 if (module[functionDef.name])
311 return; 311 return;
312 312
313 var apiFunction = {}; 313 var apiFunction = {};
314 apiFunction.definition = functionDef; 314 apiFunction.definition = functionDef;
315 apiFunction.name = apiDef.namespace + "." + functionDef.name;; 315 apiFunction.name = apiDef.namespace + "." + functionDef.name;;
316 apiFunctions[apiFunction.name] = apiFunction; 316 apiFunctions[apiFunction.name] = apiFunction;
317 317
318 module[functionDef.name] = bind(apiFunction, function() { 318 module[functionDef.name] = bind(apiFunction, function() {
319 chromeHidden.validate(arguments, this.definition.parameters); 319 chromeHidden.validate(arguments, this.definition.parameters);
320 320
321 var retval; 321 var retval;
322 if (this.handleRequest) 322 if (this.handleRequest) {
323 retval = this.handleRequest.apply(this, arguments); 323 retval = this.handleRequest.apply(this, arguments);
324 else 324 } else {
325 retval = sendRequest(this.name, arguments, 325 retval = sendRequest(this.name, arguments,
326 this.definition.parameters); 326 this.definition.parameters);
327 }
327 328
328 // Validate return value if defined - only in debug. 329 // Validate return value if defined - only in debug.
329 if (chromeHidden.validateCallbacks && 330 if (chromeHidden.validateCallbacks &&
330 chromeHidden.validate && 331 chromeHidden.validate &&
331 this.definition.returns) { 332 this.definition.returns) {
332 chromeHidden.validate([retval], [this.definition.returns]); 333 chromeHidden.validate([retval], [this.definition.returns]);
333 } 334 }
334 return retval; 335 return retval;
335 }); 336 });
336 }); 337 });
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 return tabIdProxy; 413 return tabIdProxy;
413 } 414 }
414 415
415 apiFunctions["i18n.getMessage"].handleRequest = 416 apiFunctions["i18n.getMessage"].handleRequest =
416 function(message_name, placeholders) { 417 function(message_name, placeholders) {
417 return GetL10nMessage(message_name, placeholders); 418 return GetL10nMessage(message_name, placeholders);
418 } 419 }
419 420
420 apiFunctions["experimental.popup.show"].handleRequest = 421 apiFunctions["experimental.popup.show"].handleRequest =
421 function(url, showDetails, callback) { 422 function(url, showDetails, callback) {
422 var internalArgs = [url, getAbsoluteRect(showDetails.relativeTo), 423 // Second argument is a transform from HTMLElement to Rect.
423 callback]; 424 var internalSchema = [
424 return sendRequest(this.name, internalArgs, this.definition.parameters); 425 this.definition.parameters[0],
426 {
427 type: "object",
428 name: "domAnchor",
429 properties: {
430 top: { type: "integer", minimum: 0 },
431 left: { type: "integer", minimum: 0 },
432 width: { type: "integer", minimum: 0 },
433 height: { type: "integer", minimum: 0 }
434 }
435 },
436 this.definition.parameters[2]
437 ];
438 return sendRequest(this.name,
439 [url,
440 getAbsoluteRect(showDetails.relativeTo),
441 callback],
442 internalSchema);
425 } 443 }
426 444
427 apiFunctions["experimental.extension.getPopupView"].handleRequest = 445 apiFunctions["experimental.extension.getPopupView"].handleRequest =
428 function() { 446 function() {
429 return GetPopupView(); 447 return GetPopupView();
430 } 448 }
431 449
432 apiFunctions["experimental.popup.getAnchorWindow"].handleRequest = 450 apiFunctions["experimental.popup.getParentWindow"].handleRequest =
433 function() { 451 function() {
434 return GetPopupAnchorView(); 452 return GetPopupParentWindow();
435 } 453 }
436 454
437 var canvas; 455 var canvas;
438 function setIconCommon(details, name, parameters) { 456 function setIconCommon(details, name, parameters) {
439 var EXTENSION_ACTION_ICON_SIZE = 19; 457 var EXTENSION_ACTION_ICON_SIZE = 19;
440 458
441 if ("iconIndex" in details) { 459 if ("iconIndex" in details) {
442 sendRequest(name, [details], parameters); 460 sendRequest(name, [details], parameters);
443 } else if ("imageData" in details) { 461 } else if ("imageData" in details) {
444 // Verify that this at least looks like an ImageData element. 462 // Verify that this at least looks like an ImageData element.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 AUTO_SUBFRAME: 3, 535 AUTO_SUBFRAME: 3,
518 MANUAL_SUBFRAME: 4, 536 MANUAL_SUBFRAME: 4,
519 GENERATED: 5, 537 GENERATED: 5,
520 START_PAGE: 6, 538 START_PAGE: 6,
521 FORM_SUBMIT: 7, 539 FORM_SUBMIT: 7,
522 RELOAD: 8, 540 RELOAD: 8,
523 KEYWORD: 9, 541 KEYWORD: 9,
524 KEYWORD_GENERATED: 10 542 KEYWORD_GENERATED: 10
525 }; 543 };
526 })(); 544 })();
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_process_bindings.cc ('k') | chrome/test/data/extensions/api_test/popup_api/toolband.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698