OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/suspicious_extension_bubble_controller.h" | 5 #include "chrome/browser/extensions/suspicious_extension_bubble_controller.h" |
6 | 6 |
7 #include "base/bind.h" | |
8 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
9 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/extensions/extension_message_bubble.h" | 10 #include "chrome/browser/extensions/extension_message_bubble.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_finder.h" | |
16 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
17 #include "content/public/browser/user_metrics.h" | |
18 #include "extensions/browser/extension_prefs.h" | 15 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
| 17 #include "extensions/common/extension.h" |
20 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
21 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
22 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
23 | 21 |
| 22 using extensions::ExtensionMessageBubbleController; |
| 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = | 26 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = |
27 LAZY_INSTANCE_INITIALIZER; | 27 LAZY_INSTANCE_INITIALIZER; |
28 | 28 |
29 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
30 // SuspiciousExtensionBubbleDelegate | 30 // SuspiciousExtensionBubbleDelegate |
31 | 31 |
| 32 class SuspiciousExtensionBubbleDelegate |
| 33 : public ExtensionMessageBubbleController::Delegate { |
| 34 public: |
| 35 explicit SuspiciousExtensionBubbleDelegate(Profile* profile); |
| 36 virtual ~SuspiciousExtensionBubbleDelegate(); |
| 37 |
| 38 // ExtensionMessageBubbleController::Delegate methods. |
| 39 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
| 40 virtual void AcknowledgeExtension( |
| 41 const std::string& extension_id, |
| 42 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; |
| 43 virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE; |
| 44 virtual base::string16 GetTitle() const OVERRIDE; |
| 45 virtual base::string16 GetMessageBody() const OVERRIDE; |
| 46 virtual base::string16 GetOverflowText( |
| 47 const base::string16& overflow_count) const OVERRIDE; |
| 48 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
| 49 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
| 50 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
| 51 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
| 52 virtual bool ShouldShowExtensionList() const OVERRIDE; |
| 53 virtual void LogExtensionCount(size_t count) OVERRIDE; |
| 54 virtual void LogAction( |
| 55 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; |
| 56 |
| 57 private: |
| 58 // Our profile. Weak, not owned by us. |
| 59 Profile* profile_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleDelegate); |
| 62 }; |
| 63 |
32 SuspiciousExtensionBubbleDelegate::SuspiciousExtensionBubbleDelegate( | 64 SuspiciousExtensionBubbleDelegate::SuspiciousExtensionBubbleDelegate( |
33 Profile* profile) | 65 Profile* profile) |
34 : profile_(profile) {} | 66 : profile_(profile) {} |
35 | 67 |
36 SuspiciousExtensionBubbleDelegate::~SuspiciousExtensionBubbleDelegate() { | 68 SuspiciousExtensionBubbleDelegate::~SuspiciousExtensionBubbleDelegate() { |
37 } | 69 } |
38 | 70 |
39 bool SuspiciousExtensionBubbleDelegate::ShouldIncludeExtension( | 71 bool SuspiciousExtensionBubbleDelegate::ShouldIncludeExtension( |
40 const std::string& extension_id) { | 72 const std::string& extension_id) { |
41 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 73 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return !g_shown_for_profiles.Get().count(profile_->GetOriginalProfile()) && | 173 return !g_shown_for_profiles.Get().count(profile_->GetOriginalProfile()) && |
142 !GetExtensionList().empty(); | 174 !GetExtensionList().empty(); |
143 } | 175 } |
144 | 176 |
145 void SuspiciousExtensionBubbleController::Show(ExtensionMessageBubble* bubble) { | 177 void SuspiciousExtensionBubbleController::Show(ExtensionMessageBubble* bubble) { |
146 g_shown_for_profiles.Get().insert(profile_->GetOriginalProfile()); | 178 g_shown_for_profiles.Get().insert(profile_->GetOriginalProfile()); |
147 ExtensionMessageBubbleController::Show(bubble); | 179 ExtensionMessageBubbleController::Show(bubble); |
148 } | 180 } |
149 | 181 |
150 } // namespace extensions | 182 } // namespace extensions |
OLD | NEW |