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

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

Issue 10446005: Revert half of the changes from 137638 that are probably causing breakages in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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"
11 #include "chrome/browser/extensions/extension_tab_helper.h"
12 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
13 #include "chrome/common/extensions/extension_set.h" 12 #include "chrome/common/extensions/extension_set.h"
14 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 16
18 namespace extensions { 17 namespace extensions {
19 18
20 PageActionController::PageActionController(TabContentsWrapper* tab_contents, 19 PageActionController::PageActionController(TabContentsWrapper* tab_contents)
21 ExtensionTabHelper* tab_helper) 20 : tab_contents_(tab_contents) {}
22 : tab_contents_(tab_contents),
23 tab_helper_(tab_helper) {
24 tab_helper->AddObserver(this);
25 }
26 21
27 PageActionController::~PageActionController() { 22 PageActionController::~PageActionController() {}
28 tab_helper_->RemoveObserver(this);
29 }
30 23
31 scoped_ptr<std::vector<ExtensionAction*> > 24 scoped_ptr<std::vector<ExtensionAction*> >
32 PageActionController::GetCurrentActions() { 25 PageActionController::GetCurrentActions() {
33 int tab_id = ExtensionTabUtil::GetTabId(tab_contents_->web_contents());
34 const ExtensionSet* extensions = GetExtensionService()->extensions(); 26 const ExtensionSet* extensions = GetExtensionService()->extensions();
35 scoped_ptr<std::vector<ExtensionAction*> > current_actions( 27 scoped_ptr<std::vector<ExtensionAction*> > current_actions(
36 new std::vector<ExtensionAction*>()); 28 new std::vector<ExtensionAction*>());
37 for (ExtensionSet::const_iterator i = extensions->begin(); 29 for (ExtensionSet::const_iterator i = extensions->begin();
38 i != extensions->end(); ++i) { 30 i != extensions->end(); ++i) {
39 ExtensionAction* action = (*i)->page_action(); 31 ExtensionAction* action = (*i)->page_action();
40 if (action && action->GetIsVisible(tab_id)) 32 if (action)
41 current_actions->push_back(action); 33 current_actions->push_back(action);
42 } 34 }
43 return current_actions.Pass(); 35 return current_actions.Pass();
44 } 36 }
45 37
46 ActionBoxController::Action PageActionController::OnClicked( 38 ActionBoxController::Action PageActionController::OnClicked(
47 const std::string& extension_id, int mouse_button) { 39 const std::string& extension_id, int mouse_button) {
48 const Extension* extension = 40 const Extension* extension =
49 GetExtensionService()->extensions()->GetByID(extension_id); 41 GetExtensionService()->extensions()->GetByID(extension_id);
50 CHECK(extension); 42 CHECK(extension);
(...skipping 17 matching lines...) Expand all
68 return ACTION_NONE; 60 return ACTION_NONE;
69 61
70 case 3: // right 62 case 3: // right
71 return extension->ShowConfigureContextMenus() ? 63 return extension->ShowConfigureContextMenus() ?
72 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE; 64 ACTION_SHOW_CONTEXT_MENU : ACTION_NONE;
73 } 65 }
74 66
75 return ACTION_NONE; 67 return ACTION_NONE;
76 } 68 }
77 69
78 void PageActionController::OnPageActionStateChanged() {
79 content::NotificationService::current()->Notify(
80 chrome::NOTIFICATION_EXTENSION_ACTION_BOX_UPDATED,
81 content::Source<Profile>(tab_contents_->profile()),
82 content::Details<TabContentsWrapper>(tab_contents_));
83
84 // TODO(kalman): remove this, and all occurrences of
85 // NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, when views and
86 // cocoa have been updated to not use it.
87 //
88 // Only tests care about them, and they only ever use AllSources, so it can
89 // safely be a bogus value.
90 ExtensionAction bogus_action("");
91 content::NotificationService::current()->Notify(
92 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
93 content::Source<ExtensionAction>(&bogus_action),
94 content::Details<content::WebContents>(tab_contents_->web_contents()));
95 }
96
97 ExtensionService* PageActionController::GetExtensionService() { 70 ExtensionService* PageActionController::GetExtensionService() {
98 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); 71 return ExtensionSystem::Get(tab_contents_->profile())->extension_service();
99 } 72 }
100 73
101 } // namespace extensions 74 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698