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

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

Issue 10332235: Make the page action space show extensions with active content scripts or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
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/page_action_controller.h" 5 #include "chrome/browser/extensions/page_action_controller.h"
6 6
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ActionBoxController::Action PageActionController::OnClicked( 46 ActionBoxController::Action PageActionController::OnClicked(
47 const std::string& extension_id, int mouse_button) { 47 const std::string& extension_id, int mouse_button) {
48 const Extension* extension = 48 const Extension* extension =
49 GetExtensionService()->extensions()->GetByID(extension_id); 49 GetExtensionService()->extensions()->GetByID(extension_id);
50 CHECK(extension); 50 CHECK(extension);
51 ExtensionAction* page_action = extension->page_action(); 51 ExtensionAction* page_action = extension->page_action();
52 CHECK(page_action); 52 CHECK(page_action);
53 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents()); 53 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents());
54 54
55 switch (mouse_button) { 55 switch (mouse_button) {
56 case 1: 56 case 1: // left
57 case 2: 57 case 2: // middle
Matt Perry 2012/05/18 19:31:31 2 spaces before comments
not at google - send to devlin 2012/05/18 22:51:27 Done.
58 if (page_action->HasPopup(tab_id)) 58 if (page_action->HasPopup(tab_id))
59 return ACTION_SHOW_POPUP; 59 return ACTION_SHOW_POPUP;
60 60
61 GetExtensionService()->browser_event_router()->PageActionExecuted( 61 GetExtensionService()->browser_event_router()->PageActionExecuted(
62 tab_contents_->profile(), 62 tab_contents_->profile(),
63 extension->id(), 63 extension->id(),
64 page_action->id(), 64 page_action->id(),
65 tab_id, 65 tab_id,
66 tab_contents_->web_contents()->GetURL().spec(), 66 tab_contents_->web_contents()->GetURL().spec(),
67 mouse_button); 67 mouse_button);
68 return ACTION_NONE; 68 return ACTION_NONE;
69 69
70 case 3: 70 case 3: // right
71 return extension->ShowConfigureContextMenus() ? 71 return extension->ShowConfigureContextMenus() ?
72 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; 72 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE;
73 } 73 }
74 74
75 return ACTION_NONE; 75 return ACTION_NONE;
76 } 76 }
77 77
78 void PageActionController::OnPageActionStateChanged() { 78 void PageActionController::OnPageActionStateChanged() {
79 content::NotificationService::current()->Notify( 79 content::NotificationService::current()->Notify(
80 chrome::NOTIFICATION_EXTENSION_ACTION_BOX_UPDATED, 80 chrome::NOTIFICATION_EXTENSION_ACTION_BOX_UPDATED,
(...skipping 11 matching lines...) Expand all
92 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 92 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
93 content::Source<ExtensionAction>(&bogus_action), 93 content::Source<ExtensionAction>(&bogus_action),
94 content::Details<content::WebContents>(tab_contents_->web_contents())); 94 content::Details<content::WebContents>(tab_contents_->web_contents()));
95 } 95 }
96 96
97 ExtensionService* PageActionController::GetExtensionService() { 97 ExtensionService* PageActionController::GetExtensionService() {
98 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); 98 return ExtensionSystem::Get(tab_contents_->profile())->extension_service();
99 } 99 }
100 100
101 } // namespace extensions 101 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698