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

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

Issue 10911300: Move ExtensionAction from common/ to browser/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: proof of concept Created 8 years, 3 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/extensions/browser_event_router.h" 7 #include "chrome/browser/extensions/browser_event_router.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/tab_helper.h" 10 #include "chrome/browser/extensions/tab_helper.h"
(...skipping 17 matching lines...) Expand all
28 28
29 std::vector<ExtensionAction*> PageActionController::GetCurrentActions() const { 29 std::vector<ExtensionAction*> PageActionController::GetCurrentActions() const {
30 ExtensionService* service = GetExtensionService(); 30 ExtensionService* service = GetExtensionService();
31 if (!service) 31 if (!service)
32 return std::vector<ExtensionAction*>(); 32 return std::vector<ExtensionAction*>();
33 33
34 std::vector<ExtensionAction*> current_actions; 34 std::vector<ExtensionAction*> current_actions;
35 35
36 for (ExtensionSet::const_iterator i = service->extensions()->begin(); 36 for (ExtensionSet::const_iterator i = service->extensions()->begin();
37 i != service->extensions()->end(); ++i) { 37 i != service->extensions()->end(); ++i) {
38 ExtensionAction* action = (*i)->page_action(); 38 ExtensionAction* action = service->GetPageAction(**i);
39 if (action) 39 if (action)
40 current_actions.push_back(action); 40 current_actions.push_back(action);
41 } 41 }
42 return current_actions; 42 return current_actions;
43 } 43 }
44 44
45 LocationBarController::Action PageActionController::OnClicked( 45 LocationBarController::Action PageActionController::OnClicked(
46 const std::string& extension_id, int mouse_button) { 46 const std::string& extension_id, int mouse_button) {
47 ExtensionService* service = GetExtensionService(); 47 ExtensionService* service = GetExtensionService();
48 if (!service) 48 if (!service)
49 return ACTION_NONE; 49 return ACTION_NONE;
50 50
51 const Extension* extension = service->extensions()->GetByID(extension_id); 51 const Extension* extension = service->extensions()->GetByID(extension_id);
52 CHECK(extension); 52 CHECK(extension);
53 ExtensionAction* page_action = extension->page_action(); 53 ExtensionAction* page_action = service->GetPageAction(*extension);
54 CHECK(page_action); 54 CHECK(page_action);
55 int tab_id = ExtensionTabUtil::GetTabId(web_contents()); 55 int tab_id = ExtensionTabUtil::GetTabId(web_contents());
56 56
57 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); 57 TabContents* tab_contents = TabContents::FromWebContents(web_contents());
58 tab_contents->extension_tab_helper()->active_tab_permission_manager()-> 58 tab_contents->extension_tab_helper()->active_tab_permission_manager()->
59 GrantIfRequested(extension); 59 GrantIfRequested(extension);
60 60
61 switch (mouse_button) { 61 switch (mouse_button) {
62 case 1: // left 62 case 1: // left
63 case 2: // middle 63 case 2: // middle
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 NotifyChange(); 106 NotifyChange();
107 } 107 }
108 108
109 ExtensionService* PageActionController::GetExtensionService() const { 109 ExtensionService* PageActionController::GetExtensionService() const {
110 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); 110 TabContents* tab_contents = TabContents::FromWebContents(web_contents());
111 return ExtensionSystem::Get(tab_contents->profile())->extension_service(); 111 return ExtensionSystem::Get(tab_contents->profile())->extension_service();
112 } 112 }
113 113
114 } // namespace extensions 114 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698