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