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

Side by Side Diff: chrome/browser/extensions/browser_event_router.cc

Issue 11588004: Move ScriptBadge, ActionInfo out of Extension; preparation for BrowserAction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/browser_event_router.h" 5 #include "chrome/browser/extensions/browser_event_router.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" 12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h"
13 #include "chrome/browser/extensions/event_names.h" 13 #include "chrome/browser/extensions/event_names.h"
14 #include "chrome/browser/extensions/extension_action.h" 14 #include "chrome/browser/extensions/extension_action.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/extension_tab_util.h" 17 #include "chrome/browser/extensions/extension_tab_util.h"
18 #include "chrome/browser/extensions/window_controller.h" 18 #include "chrome/browser/extensions/window_controller.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_list.h" 21 #include "chrome/browser/ui/browser_list.h"
22 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/api/extension_action/action_info.h"
25 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
26 #include "content/public/browser/navigation_controller.h" 26 #include "content/public/browser/navigation_controller.h"
27 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 30
31 namespace events = extensions::event_names; 31 namespace events = extensions::event_names;
32 namespace tab_keys = extensions::tabs_constants; 32 namespace tab_keys = extensions::tabs_constants;
33 namespace page_action_keys = extension_page_actions_api_constants; 33 namespace page_action_keys = extension_page_actions_api_constants;
34 34
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 const ExtensionAction& script_badge, 541 const ExtensionAction& script_badge,
542 int tab_id) { 542 int tab_id) {
543 WebContents* web_contents = NULL; 543 WebContents* web_contents = NULL;
544 if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(), 544 if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(),
545 NULL, NULL, &web_contents, NULL)) { 545 NULL, NULL, &web_contents, NULL)) {
546 return; 546 return;
547 } 547 }
548 ExtensionActionExecuted(profile, script_badge, web_contents); 548 ExtensionActionExecuted(profile, script_badge, web_contents);
549 } 549 }
550 550
551 void BrowserEventRouter::ExtensionActionExecuted( 551 void BrowserEventRouter::ExtensionActionExecuted(
Yoyo Zhou 2012/12/18 02:01:41 FYI, this should eventually get moved out of this
552 Profile* profile, 552 Profile* profile,
553 const ExtensionAction& extension_action, 553 const ExtensionAction& extension_action,
554 WebContents* web_contents) { 554 WebContents* web_contents) {
555 const char* event_name = NULL; 555 const char* event_name = NULL;
556 switch (extension_action.action_type()) { 556 switch (extension_action.action_type()) {
557 case Extension::ActionInfo::TYPE_BROWSER: 557 case ActionInfo::TYPE_BROWSER:
558 event_name = "browserAction.onClicked"; 558 event_name = "browserAction.onClicked";
559 break; 559 break;
560 case Extension::ActionInfo::TYPE_PAGE: 560 case ActionInfo::TYPE_PAGE:
561 event_name = "pageAction.onClicked"; 561 event_name = "pageAction.onClicked";
562 break; 562 break;
563 case Extension::ActionInfo::TYPE_SCRIPT_BADGE: 563 case ActionInfo::TYPE_SCRIPT_BADGE:
564 event_name = "scriptBadge.onClicked"; 564 event_name = "scriptBadge.onClicked";
565 break; 565 break;
566 case Extension::ActionInfo::TYPE_SYSTEM_INDICATOR: 566 case ActionInfo::TYPE_SYSTEM_INDICATOR:
567 // The System Indicator handles its own clicks. 567 // The System Indicator handles its own clicks.
568 break; 568 break;
569 } 569 }
570 570
571 if (event_name) { 571 if (event_name) {
572 scoped_ptr<ListValue> args(new ListValue()); 572 scoped_ptr<ListValue> args(new ListValue());
573 DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue( 573 DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(
574 web_contents, 574 web_contents,
575 ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS); 575 ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS);
576 args->Append(tab_value); 576 args->Append(tab_value);
577 577
578 DispatchEventToExtension(profile, 578 DispatchEventToExtension(profile,
579 extension_action.extension_id(), 579 extension_action.extension_id(),
580 event_name, 580 event_name,
581 args.Pass(), 581 args.Pass(),
582 EventRouter::USER_GESTURE_ENABLED); 582 EventRouter::USER_GESTURE_ENABLED);
583 } 583 }
584 } 584 }
585 585
586 } // namespace extensions 586 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698