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

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: Latest master for CQ Created 7 years, 11 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
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/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/api/extension_action/action_info.h"
24 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
25 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 29
30 namespace events = extensions::event_names; 30 namespace events = extensions::event_names;
31 namespace tab_keys = extensions::tabs_constants; 31 namespace tab_keys = extensions::tabs_constants;
32 namespace page_action_keys = extension_page_actions_api_constants; 32 namespace page_action_keys = extension_page_actions_api_constants;
33 33
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 578 }
579 ExtensionActionExecuted(profile, script_badge, web_contents); 579 ExtensionActionExecuted(profile, script_badge, web_contents);
580 } 580 }
581 581
582 void BrowserEventRouter::ExtensionActionExecuted( 582 void BrowserEventRouter::ExtensionActionExecuted(
583 Profile* profile, 583 Profile* profile,
584 const ExtensionAction& extension_action, 584 const ExtensionAction& extension_action,
585 WebContents* web_contents) { 585 WebContents* web_contents) {
586 const char* event_name = NULL; 586 const char* event_name = NULL;
587 switch (extension_action.action_type()) { 587 switch (extension_action.action_type()) {
588 case Extension::ActionInfo::TYPE_BROWSER: 588 case ActionInfo::TYPE_BROWSER:
589 event_name = "browserAction.onClicked"; 589 event_name = "browserAction.onClicked";
590 break; 590 break;
591 case Extension::ActionInfo::TYPE_PAGE: 591 case ActionInfo::TYPE_PAGE:
592 event_name = "pageAction.onClicked"; 592 event_name = "pageAction.onClicked";
593 break; 593 break;
594 case Extension::ActionInfo::TYPE_SCRIPT_BADGE: 594 case ActionInfo::TYPE_SCRIPT_BADGE:
595 event_name = "scriptBadge.onClicked"; 595 event_name = "scriptBadge.onClicked";
596 break; 596 break;
597 case Extension::ActionInfo::TYPE_SYSTEM_INDICATOR: 597 case ActionInfo::TYPE_SYSTEM_INDICATOR:
598 // The System Indicator handles its own clicks. 598 // The System Indicator handles its own clicks.
599 break; 599 break;
600 } 600 }
601 601
602 if (event_name) { 602 if (event_name) {
603 scoped_ptr<ListValue> args(new ListValue()); 603 scoped_ptr<ListValue> args(new ListValue());
604 DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue( 604 DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(
605 web_contents); 605 web_contents);
606 args->Append(tab_value); 606 args->Append(tab_value);
607 607
608 DispatchEventToExtension(profile, 608 DispatchEventToExtension(profile,
609 extension_action.extension_id(), 609 extension_action.extension_id(),
610 event_name, 610 event_name,
611 args.Pass(), 611 args.Pass(),
612 EventRouter::USER_GESTURE_ENABLED); 612 EventRouter::USER_GESTURE_ENABLED);
613 } 613 }
614 } 614 }
615 615
616 } // namespace extensions 616 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/extension_action/script_badge_api.cc ('k') | chrome/browser/extensions/extension_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698