OLD | NEW |
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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 PageActionController::~PageActionController() { | 32 PageActionController::~PageActionController() { |
33 } | 33 } |
34 | 34 |
35 ExtensionAction* PageActionController::GetActionForExtension( | 35 ExtensionAction* PageActionController::GetActionForExtension( |
36 const Extension* extension) { | 36 const Extension* extension) { |
37 return ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension); | 37 return ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension); |
38 } | 38 } |
39 | 39 |
40 LocationBarController::Action PageActionController::OnClicked( | 40 ExtensionAction::ShowAction PageActionController::OnClicked( |
41 const Extension* extension) { | 41 const Extension* extension) { |
42 ExtensionAction* page_action = | 42 ExtensionAction* page_action = |
43 ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension); | 43 ExtensionActionManager::Get(GetProfile())->GetPageAction(*extension); |
44 CHECK(page_action); | 44 CHECK(page_action); |
45 | 45 |
46 int tab_id = SessionID::IdForTab(web_contents_); | 46 int tab_id = SessionID::IdForTab(web_contents_); |
47 TabHelper::FromWebContents(web_contents_)-> | 47 TabHelper::FromWebContents(web_contents_)-> |
48 active_tab_permission_granter()->GrantIfRequested(extension); | 48 active_tab_permission_granter()->GrantIfRequested(extension); |
49 | 49 |
50 if (page_action->HasPopup(tab_id)) | 50 if (page_action->HasPopup(tab_id)) |
51 return LocationBarController::ACTION_SHOW_POPUP; | 51 return ExtensionAction::ACTION_SHOW_POPUP; |
52 | 52 |
53 ExtensionActionAPI::PageActionExecuted( | 53 ExtensionActionAPI::PageActionExecuted( |
54 web_contents_->GetBrowserContext(), | 54 web_contents_->GetBrowserContext(), |
55 *page_action, | 55 *page_action, |
56 tab_id, | 56 tab_id, |
57 web_contents_->GetLastCommittedURL().spec(), | 57 web_contents_->GetLastCommittedURL().spec(), |
58 1 /* Button indication. We only ever pass left-click. */); | 58 1 /* Button indication. We only ever pass left-click. */); |
59 | 59 |
60 return LocationBarController::ACTION_NONE; | 60 return ExtensionAction::ACTION_NONE; |
61 } | 61 } |
62 | 62 |
63 void PageActionController::OnNavigated() { | 63 void PageActionController::OnNavigated() { |
64 const ExtensionSet& extensions = | 64 const ExtensionSet& extensions = |
65 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) | 65 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) |
66 ->enabled_extensions(); | 66 ->enabled_extensions(); |
67 int tab_id = SessionID::IdForTab(web_contents_); | 67 int tab_id = SessionID::IdForTab(web_contents_); |
68 size_t num_current_actions = 0u; | 68 size_t num_current_actions = 0u; |
69 for (ExtensionSet::const_iterator iter = extensions.begin(); | 69 for (ExtensionSet::const_iterator iter = extensions.begin(); |
70 iter != extensions.end(); | 70 iter != extensions.end(); |
(...skipping 16 matching lines...) Expand all Loading... |
87 } | 87 } |
88 | 88 |
89 LocationBarController::NotifyChange(web_contents_); | 89 LocationBarController::NotifyChange(web_contents_); |
90 } | 90 } |
91 | 91 |
92 Profile* PageActionController::GetProfile() { | 92 Profile* PageActionController::GetProfile() { |
93 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 93 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
94 } | 94 } |
95 | 95 |
96 } // namespace extensions | 96 } // namespace extensions |
OLD | NEW |