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" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = | 24 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = |
25 LAZY_INSTANCE_INITIALIZER; | 25 LAZY_INSTANCE_INITIALIZER; |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
28 // SuspiciousExtensionBubbleDelegate | 28 // SuspiciousExtensionBubbleDelegate |
29 | 29 |
30 SuspiciousExtensionBubbleDelegate::SuspiciousExtensionBubbleDelegate( | 30 SuspiciousExtensionBubbleDelegate::SuspiciousExtensionBubbleDelegate( |
31 ExtensionService* service) | 31 ExtensionService* service) |
James Cook
2014/02/07 00:53:02
optional: This looks like it could just take a Pro
Ken Rockot(use gerrit already)
2014/02/10 18:53:02
Done.
| |
32 : service_(service) { | 32 : service_(service) { |
33 } | 33 } |
34 | 34 |
35 SuspiciousExtensionBubbleDelegate::~SuspiciousExtensionBubbleDelegate() { | 35 SuspiciousExtensionBubbleDelegate::~SuspiciousExtensionBubbleDelegate() { |
36 } | 36 } |
37 | 37 |
38 bool SuspiciousExtensionBubbleDelegate::ShouldIncludeExtension( | 38 bool SuspiciousExtensionBubbleDelegate::ShouldIncludeExtension( |
39 const std::string& extension_id) { | 39 const std::string& extension_id) { |
40 extensions::ExtensionPrefs* prefs = service_->extension_prefs(); | 40 extensions::ExtensionPrefs* prefs = |
41 extensions::ExtensionPrefs::Get(service_->profile()); | |
41 if (!prefs->IsExtensionDisabled(extension_id)) | 42 if (!prefs->IsExtensionDisabled(extension_id)) |
42 return false; | 43 return false; |
43 | 44 |
44 int disble_reasons = prefs->GetDisableReasons(extension_id); | 45 int disble_reasons = prefs->GetDisableReasons(extension_id); |
45 if (disble_reasons & extensions::Extension::DISABLE_NOT_VERIFIED) | 46 if (disble_reasons & extensions::Extension::DISABLE_NOT_VERIFIED) |
46 return !prefs->HasWipeoutBeenAcknowledged(extension_id); | 47 return !prefs->HasWipeoutBeenAcknowledged(extension_id); |
47 | 48 |
48 return false; | 49 return false; |
49 } | 50 } |
50 | 51 |
51 void SuspiciousExtensionBubbleDelegate::AcknowledgeExtension( | 52 void SuspiciousExtensionBubbleDelegate::AcknowledgeExtension( |
52 const std::string& extension_id, | 53 const std::string& extension_id, |
53 ExtensionMessageBubbleController::BubbleAction user_action) { | 54 ExtensionMessageBubbleController::BubbleAction user_action) { |
54 extensions::ExtensionPrefs* prefs = service_->extension_prefs(); | 55 extensions::ExtensionPrefs* prefs = |
56 extensions::ExtensionPrefs::Get(service_->profile()); | |
55 prefs->SetWipeoutAcknowledged(extension_id, true); | 57 prefs->SetWipeoutAcknowledged(extension_id, true); |
56 } | 58 } |
57 | 59 |
58 void SuspiciousExtensionBubbleDelegate::PerformAction( | 60 void SuspiciousExtensionBubbleDelegate::PerformAction( |
59 const extensions::ExtensionIdList& list) { | 61 const extensions::ExtensionIdList& list) { |
60 // This bubble solicits no action from the user. Or as Nimoy would have it: | 62 // This bubble solicits no action from the user. Or as Nimoy would have it: |
61 // "Well, my work here is done". | 63 // "Well, my work here is done". |
62 } | 64 } |
63 | 65 |
64 base::string16 SuspiciousExtensionBubbleDelegate::GetTitle() const { | 66 base::string16 SuspiciousExtensionBubbleDelegate::GetTitle() const { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 return !g_shown_for_profiles.Get().count(profile_) && | 158 return !g_shown_for_profiles.Get().count(profile_) && |
157 !GetExtensionList().empty(); | 159 !GetExtensionList().empty(); |
158 } | 160 } |
159 | 161 |
160 void SuspiciousExtensionBubbleController::Show(ExtensionMessageBubble* bubble) { | 162 void SuspiciousExtensionBubbleController::Show(ExtensionMessageBubble* bubble) { |
161 g_shown_for_profiles.Get().insert(profile_); | 163 g_shown_for_profiles.Get().insert(profile_); |
162 ExtensionMessageBubbleController::Show(bubble); | 164 ExtensionMessageBubbleController::Show(bubble); |
163 } | 165 } |
164 | 166 |
165 } // namespace extensions | 167 } // namespace extensions |
OLD | NEW |