| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 var parentMenuItemId = arguments[0].parentMenuItemId; | 300 var parentMenuItemId = arguments[0].parentMenuItemId; |
| 301 var parentOnclick = chromeHidden.contextMenuHandlers[parentMenuItemId]; | 301 var parentOnclick = chromeHidden.contextMenuHandlers[parentMenuItemId]; |
| 302 if (parentOnclick) { | 302 if (parentOnclick) { |
| 303 parentOnclick.apply(parentOnclick, arguments); | 303 parentOnclick.apply(parentOnclick, arguments); |
| 304 } | 304 } |
| 305 }); | 305 }); |
| 306 } | 306 } |
| 307 | 307 |
| 308 function setupOmniboxEvents(extensionId) { |
| 309 chrome.experimental.omnibox.onInputEntered = |
| 310 new chrome.Event("experimental.omnibox.onInputEntered/" + extensionId); |
| 311 |
| 312 chrome.experimental.omnibox.onInputChanged = |
| 313 new chrome.Event("experimental.omnibox.onInputChanged/" + extensionId); |
| 314 chrome.experimental.omnibox.onInputChanged.dispatch = |
| 315 function(text, requestId) { |
| 316 var suggestCallback = function(suggestions) { |
| 317 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); |
| 318 } |
| 319 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); |
| 320 }; |
| 321 } |
| 322 |
| 308 chromeHidden.onLoad.addListener(function (extensionId) { | 323 chromeHidden.onLoad.addListener(function (extensionId) { |
| 309 chrome.initExtension(extensionId, false); | 324 chrome.initExtension(extensionId, false); |
| 310 | 325 |
| 311 // |apiFunctions| is a hash of name -> object that stores the | 326 // |apiFunctions| is a hash of name -> object that stores the |
| 312 // name & definition of the apiFunction. Custom handling of api functions | 327 // name & definition of the apiFunction. Custom handling of api functions |
| 313 // is implemented by adding a "handleRequest" function to the object. | 328 // is implemented by adding a "handleRequest" function to the object. |
| 314 var apiFunctions = {}; | 329 var apiFunctions = {}; |
| 315 | 330 |
| 316 // Read api definitions and setup api functions in the chrome namespace. | 331 // Read api definitions and setup api functions in the chrome namespace. |
| 317 // TODO(rafaelw): Consider defining a json schema for an api definition | 332 // TODO(rafaelw): Consider defining a json schema for an api definition |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 644 |
| 630 if (chrome.test) { | 645 if (chrome.test) { |
| 631 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; | 646 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; |
| 632 } | 647 } |
| 633 | 648 |
| 634 setupBrowserActionEvent(extensionId); | 649 setupBrowserActionEvent(extensionId); |
| 635 setupPageActionEvents(extensionId); | 650 setupPageActionEvents(extensionId); |
| 636 setupToolstripEvents(GetRenderViewId()); | 651 setupToolstripEvents(GetRenderViewId()); |
| 637 setupPopupEvents(GetRenderViewId()); | 652 setupPopupEvents(GetRenderViewId()); |
| 638 setupHiddenContextMenuEvent(extensionId); | 653 setupHiddenContextMenuEvent(extensionId); |
| 654 setupOmniboxEvents(extensionId); |
| 639 }); | 655 }); |
| 640 | 656 |
| 641 if (!chrome.experimental) | 657 if (!chrome.experimental) |
| 642 chrome.experimental = {}; | 658 chrome.experimental = {}; |
| 643 | 659 |
| 644 if (!chrome.experimental.accessibility) | 660 if (!chrome.experimental.accessibility) |
| 645 chrome.experimental.accessibility = {}; | 661 chrome.experimental.accessibility = {}; |
| 646 })(); | 662 })(); |
| OLD | NEW |