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

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

Issue 2807033: Add support for omnibox.onInputStarted and onInputCancelled. (Closed)
Patch Set: fix Stop Created 10 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/common/notification_type.h ('k') | no next file » | 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) 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Page action events send (pageActionId, {tabId, tabUrl}). 239 // Page action events send (pageActionId, {tabId, tabUrl}).
240 function setupPageActionEvents(extensionId) { 240 function setupPageActionEvents(extensionId) {
241 var pageActions = GetCurrentPageActions(extensionId); 241 var pageActions = GetCurrentPageActions(extensionId);
242 242
243 var oldStyleEventName = "pageActions/" + extensionId; 243 var oldStyleEventName = "pageActions/" + extensionId;
244 // TODO(EXTENSIONS_DEPRECATED): only one page action 244 // TODO(EXTENSIONS_DEPRECATED): only one page action
245 for (var i = 0; i < pageActions.length; ++i) { 245 for (var i = 0; i < pageActions.length; ++i) {
246 // Setup events for each extension_id/page_action_id string we find. 246 // Setup events for each extension_id/page_action_id string we find.
247 chrome.pageActions[pageActions[i]] = new chrome.Event(oldStyleEventName); 247 chrome.pageActions[pageActions[i]] = new chrome.Event(oldStyleEventName);
248 } 248 }
249
250 // Note this is singular.
251 var eventName = "pageAction/" + extensionId;
252 chrome.pageAction = chrome.pageAction || {};
253 chrome.pageAction.onClicked = new chrome.Event(eventName);
254 }
255
256 // Browser action events send {windowpId}.
257 function setupBrowserActionEvent(extensionId) {
258 var eventName = "browserAction/" + extensionId;
259 chrome.browserAction = chrome.browserAction || {};
260 chrome.browserAction.onClicked = new chrome.Event(eventName);
261 } 249 }
262 250
263 function setupToolstripEvents(renderViewId) { 251 function setupToolstripEvents(renderViewId) {
264 chrome.toolstrip = chrome.toolstrip || {}; 252 chrome.toolstrip = chrome.toolstrip || {};
265 chrome.toolstrip.onExpanded = 253 chrome.toolstrip.onExpanded =
266 new chrome.Event("toolstrip.onExpanded." + renderViewId); 254 new chrome.Event("toolstrip.onExpanded." + renderViewId);
267 chrome.toolstrip.onCollapsed = 255 chrome.toolstrip.onCollapsed =
268 new chrome.Event("toolstrip.onCollapsed." + renderViewId); 256 new chrome.Event("toolstrip.onCollapsed." + renderViewId);
269 } 257 }
270 258
(...skipping 16 matching lines...) Expand all
287 275
288 var parentMenuItemId = arguments[0].parentMenuItemId; 276 var parentMenuItemId = arguments[0].parentMenuItemId;
289 var parentOnclick = chromeHidden.contextMenuHandlers[parentMenuItemId]; 277 var parentOnclick = chromeHidden.contextMenuHandlers[parentMenuItemId];
290 if (parentOnclick) { 278 if (parentOnclick) {
291 parentOnclick.apply(parentOnclick, arguments); 279 parentOnclick.apply(parentOnclick, arguments);
292 } 280 }
293 }); 281 });
294 } 282 }
295 283
296 function setupOmniboxEvents(extensionId) { 284 function setupOmniboxEvents(extensionId) {
297 chrome.experimental.omnibox.onInputEntered =
298 new chrome.Event("experimental.omnibox.onInputEntered/" + extensionId);
299
300 chrome.experimental.omnibox.onInputChanged =
301 new chrome.Event("experimental.omnibox.onInputChanged/" + extensionId);
302 chrome.experimental.omnibox.onInputChanged.dispatch = 285 chrome.experimental.omnibox.onInputChanged.dispatch =
303 function(text, requestId) { 286 function(text, requestId) {
304 var suggestCallback = function(suggestions) { 287 var suggestCallback = function(suggestions) {
305 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions); 288 chrome.experimental.omnibox.sendSuggestions(requestId, suggestions);
306 } 289 }
307 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); 290 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]);
308 }; 291 };
309 } 292 }
310 293
311 chromeHidden.onLoad.addListener(function (extensionId) { 294 chromeHidden.onLoad.addListener(function (extensionId) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 370
388 // Setup Events 371 // Setup Events
389 if (apiDef.events) { 372 if (apiDef.events) {
390 apiDef.events.forEach(function(eventDef) { 373 apiDef.events.forEach(function(eventDef) {
391 // Module events may have been defined earlier by hand. Don't clobber 374 // Module events may have been defined earlier by hand. Don't clobber
392 // them. 375 // them.
393 if (module[eventDef.name]) 376 if (module[eventDef.name])
394 return; 377 return;
395 378
396 var eventName = apiDef.namespace + "." + eventDef.name; 379 var eventName = apiDef.namespace + "." + eventDef.name;
380 if (eventDef.perExtensionEvent)
381 eventName = eventName + "/" + extensionId;
397 module[eventDef.name] = new chrome.Event(eventName, 382 module[eventDef.name] = new chrome.Event(eventName,
398 eventDef.parameters); 383 eventDef.parameters);
399 }); 384 });
400 } 385 }
401 386
402 387
403 // Parse any values defined for properties. 388 // Parse any values defined for properties.
404 if (apiDef.properties) { 389 if (apiDef.properties) {
405 for (var prop in apiDef.properties) { 390 for (var prop in apiDef.properties) {
406 if (!apiDef.properties.hasOwnProperty(prop)) 391 if (!apiDef.properties.hasOwnProperty(prop))
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 649 }
665 apiFunctions["experimental.omnibox.styleDim"].handleRequest = 650 apiFunctions["experimental.omnibox.styleDim"].handleRequest =
666 function(offset) { 651 function(offset) {
667 return {type: "dim", offset: offset}; 652 return {type: "dim", offset: offset};
668 } 653 }
669 654
670 if (chrome.test) { 655 if (chrome.test) {
671 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; 656 chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
672 } 657 }
673 658
674 setupBrowserActionEvent(extensionId);
675 setupPageActionEvents(extensionId); 659 setupPageActionEvents(extensionId);
676 setupToolstripEvents(GetRenderViewId()); 660 setupToolstripEvents(GetRenderViewId());
677 setupPopupEvents(GetRenderViewId()); 661 setupPopupEvents(GetRenderViewId());
678 setupHiddenContextMenuEvent(extensionId); 662 setupHiddenContextMenuEvent(extensionId);
679 setupOmniboxEvents(extensionId); 663 setupOmniboxEvents(extensionId);
680 }); 664 });
681 665
682 if (!chrome.experimental) 666 if (!chrome.experimental)
683 chrome.experimental = {}; 667 chrome.experimental = {};
684 668
685 if (!chrome.experimental.accessibility) 669 if (!chrome.experimental.accessibility)
686 chrome.experimental.accessibility = {}; 670 chrome.experimental.accessibility = {};
687 })(); 671 })();
OLDNEW
« no previous file with comments | « chrome/common/notification_type.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698