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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 web_contents_->GetBrowserContext(), | 57 web_contents_->GetBrowserContext(), |
58 *page_action, | 58 *page_action, |
59 tab_id, | 59 tab_id, |
60 web_contents_->GetLastCommittedURL().spec(), | 60 web_contents_->GetLastCommittedURL().spec(), |
61 1 /* Button indication. We only ever pass left-click. */); | 61 1 /* Button indication. We only ever pass left-click. */); |
62 | 62 |
63 return ExtensionAction::ACTION_NONE; | 63 return ExtensionAction::ACTION_NONE; |
64 } | 64 } |
65 | 65 |
66 void PageActionController::OnNavigated() { | 66 void PageActionController::OnNavigated() { |
67 const ExtensionSet& extensions = | 67 // Clearing extension action values is handled in TabHelper, so nothing to |
68 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) | 68 // do here. |
69 ->enabled_extensions(); | |
70 int tab_id = SessionTabHelper::IdForTab(web_contents_); | |
71 size_t num_current_actions = 0u; | |
72 for (ExtensionSet::const_iterator iter = extensions.begin(); | |
73 iter != extensions.end(); | |
74 ++iter) { | |
75 ExtensionAction* action = GetActionForExtension(*iter); | |
76 if (action) { | |
77 action->ClearAllValuesForTab(tab_id); | |
78 ++num_current_actions; | |
79 } | |
80 } | |
81 | |
82 Profile* profile = GetProfile(); | |
83 // Report the number of page actions for this profile, if we haven't already. | |
84 // TODO(rdevlin.cronin): This is wrong. Instead, it should record the number | |
85 // of page actions displayed per page. | |
86 if (!g_reported_for_profiles.Get().count(profile)) { | |
Devlin
2014/08/21 14:05:43
From Other Comment:
"We wanted to know how common
Finnur
2014/08/21 14:19:18
If that means killing this one and leaving the oth
| |
87 UMA_HISTOGRAM_COUNTS_100("PageActionController.ExtensionsWithPageActions", | |
88 num_current_actions); | |
89 g_reported_for_profiles.Get().insert(profile); | |
90 } | |
91 | |
92 LocationBarController::NotifyChange(web_contents_); | |
93 } | 69 } |
94 | 70 |
95 void PageActionController::OnExtensionActionUpdated( | 71 void PageActionController::OnExtensionActionUpdated( |
96 ExtensionAction* extension_action, | 72 ExtensionAction* extension_action, |
97 content::WebContents* web_contents, | 73 content::WebContents* web_contents, |
98 content::BrowserContext* browser_context) { | 74 content::BrowserContext* browser_context) { |
99 if (web_contents == web_contents_ && | 75 if (web_contents == web_contents_ && |
100 extension_action->action_type() == ActionInfo::TYPE_PAGE) | 76 extension_action->action_type() == ActionInfo::TYPE_PAGE) |
101 LocationBarController::NotifyChange(web_contents_); | 77 LocationBarController::NotifyChange(web_contents_); |
102 } | 78 } |
103 | 79 |
104 Profile* PageActionController::GetProfile() { | 80 Profile* PageActionController::GetProfile() { |
105 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 81 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
106 } | 82 } |
107 | 83 |
108 } // namespace extensions | 84 } // namespace extensions |
OLD | NEW |