| OLD | NEW |
| 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(); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 new chrome.Event("toolstrip.onCollapsed." + renderViewId); | 265 new chrome.Event("toolstrip.onCollapsed." + renderViewId); |
| 266 } | 266 } |
| 267 | 267 |
| 268 function setupPopupEvents(renderViewId) { | 268 function setupPopupEvents(renderViewId) { |
| 269 chrome.experimental.popup = chrome.experimental.popup || {}; | 269 chrome.experimental.popup = chrome.experimental.popup || {}; |
| 270 chrome.experimental.popup.onClosed = | 270 chrome.experimental.popup.onClosed = |
| 271 new chrome.Event("experimental.popup.onClosed." + renderViewId); | 271 new chrome.Event("experimental.popup.onClosed." + renderViewId); |
| 272 } | 272 } |
| 273 | 273 |
| 274 chromeHidden.onLoad.addListener(function (extensionId) { | 274 chromeHidden.onLoad.addListener(function (extensionId) { |
| 275 chrome.initExtension(extensionId); | 275 chrome.initExtension(extensionId, false); |
| 276 | 276 |
| 277 // |apiFunctions| is a hash of name -> object that stores the | 277 // |apiFunctions| is a hash of name -> object that stores the |
| 278 // name & definition of the apiFunction. Custom handling of api functions | 278 // name & definition of the apiFunction. Custom handling of api functions |
| 279 // is implemented by adding a "handleRequest" function to the object. | 279 // is implemented by adding a "handleRequest" function to the object. |
| 280 var apiFunctions = {}; | 280 var apiFunctions = {}; |
| 281 | 281 |
| 282 // Read api definitions and setup api functions in the chrome namespace. | 282 // Read api definitions and setup api functions in the chrome namespace. |
| 283 // TODO(rafaelw): Consider defining a json schema for an api definition | 283 // TODO(rafaelw): Consider defining a json schema for an api definition |
| 284 // and validating either here, in a unit_test or both. | 284 // and validating either here, in a unit_test or both. |
| 285 // TODO(rafaelw): Handle synchronous functions. | 285 // TODO(rafaelw): Handle synchronous functions. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } | 503 } |
| 504 | 504 |
| 505 apiFunctions["browserAction.setIcon"].handleRequest = function(details) { | 505 apiFunctions["browserAction.setIcon"].handleRequest = function(details) { |
| 506 setIconCommon(details, this.name, this.definition.parameters); | 506 setIconCommon(details, this.name, this.definition.parameters); |
| 507 }; | 507 }; |
| 508 | 508 |
| 509 apiFunctions["pageAction.setIcon"].handleRequest = function(details) { | 509 apiFunctions["pageAction.setIcon"].handleRequest = function(details) { |
| 510 setIconCommon(details, this.name, this.definition.parameters); | 510 setIconCommon(details, this.name, this.definition.parameters); |
| 511 }; | 511 }; |
| 512 | 512 |
| 513 if (chrome.test) { |
| 514 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; |
| 515 } |
| 516 |
| 513 setupBrowserActionEvent(extensionId); | 517 setupBrowserActionEvent(extensionId); |
| 514 setupPageActionEvents(extensionId); | 518 setupPageActionEvents(extensionId); |
| 515 setupToolstripEvents(GetRenderViewId()); | 519 setupToolstripEvents(GetRenderViewId()); |
| 516 setupPopupEvents(GetRenderViewId()); | 520 setupPopupEvents(GetRenderViewId()); |
| 517 }); | 521 }); |
| 518 | 522 |
| 519 if (!chrome.experimental) | 523 if (!chrome.experimental) |
| 520 chrome.experimental = {}; | 524 chrome.experimental = {}; |
| 521 | 525 |
| 522 if (!chrome.experimental.history) | 526 if (!chrome.experimental.history) |
| 523 chrome.experimental.history = {}; | 527 chrome.experimental.history = {}; |
| 524 | 528 |
| 525 chrome.experimental.history.transistionType = { | 529 chrome.experimental.history.transistionType = { |
| 526 LINK: 0, | 530 LINK: 0, |
| 527 TYPED: 1, | 531 TYPED: 1, |
| 528 AUTO_BOOKMARK: 2, | 532 AUTO_BOOKMARK: 2, |
| 529 AUTO_SUBFRAME: 3, | 533 AUTO_SUBFRAME: 3, |
| 530 MANUAL_SUBFRAME: 4, | 534 MANUAL_SUBFRAME: 4, |
| 531 GENERATED: 5, | 535 GENERATED: 5, |
| 532 START_PAGE: 6, | 536 START_PAGE: 6, |
| 533 FORM_SUBMIT: 7, | 537 FORM_SUBMIT: 7, |
| 534 RELOAD: 8, | 538 RELOAD: 8, |
| 535 KEYWORD: 9, | 539 KEYWORD: 9, |
| 536 KEYWORD_GENERATED: 10 | 540 KEYWORD_GENERATED: 10 |
| 537 }; | 541 }; |
| 538 })(); | 542 })(); |
| OLD | NEW |