OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/extensions/suspicious_extension_bubble_controller_deleg ate.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/metrics/histogram.h" | |
9 #include "base/strings/utf_string_conversions.h" | |
10 #include "chrome/browser/extensions/extension_message_bubble.h" | |
11 #include "chrome/browser/extensions/extension_prefs.h" | |
12 #include "chrome/browser/extensions/extension_service.h" | |
13 #include "chrome/browser/ui/browser.h" | |
14 #include "chrome/browser/ui/browser_finder.h" | |
15 #include "chrome/common/url_constants.h" | |
16 #include "content/public/browser/user_metrics.h" | |
17 #include "grit/chromium_strings.h" | |
18 #include "grit/generated_resources.h" | |
19 #include "ui/base/l10n/l10n_util.h" | |
20 | |
21 namespace { | |
22 | |
23 static base::LazyInstance<extensions::ProfileKeyedAPIFactory< | |
24 extensions::SuspiciousExtensionBubbleControllerDelegate> > | |
25 g_factory = LAZY_INSTANCE_INITIALIZER; | |
26 | |
27 } // namespace | |
28 | |
29 namespace extensions { | |
30 | |
31 //////////////////////////////////////////////////////////////////////////////// | |
32 // SuspiciousExtensionBubbleControllerDelegate | |
33 | |
34 SuspiciousExtensionBubbleControllerDelegate:: | |
35 SuspiciousExtensionBubbleControllerDelegate( | |
36 Profile* profile) | |
37 : controller_(new ExtensionMessageBubbleController(this, profile)), | |
38 service_(extensions::ExtensionSystem::Get(profile)->extension_service()), | |
39 profile_(profile) { | |
40 } | |
41 | |
42 SuspiciousExtensionBubbleControllerDelegate:: | |
43 ~SuspiciousExtensionBubbleControllerDelegate() { | |
44 } | |
45 | |
46 // static | |
47 ProfileKeyedAPIFactory<SuspiciousExtensionBubbleControllerDelegate>* | |
48 SuspiciousExtensionBubbleControllerDelegate::GetFactoryInstance() { | |
49 return &g_factory.Get(); | |
50 } | |
51 | |
52 // static | |
53 SuspiciousExtensionBubbleControllerDelegate* | |
54 SuspiciousExtensionBubbleControllerDelegate::Get(Profile* profile) { | |
55 return ProfileKeyedAPIFactory< | |
56 SuspiciousExtensionBubbleControllerDelegate>::GetForProfile(profile); | |
57 } | |
58 | |
59 void SuspiciousExtensionBubbleControllerDelegate::Show( | |
60 ExtensionMessageBubble* bubble) { | |
61 controller_->Show(bubble); | |
not at google - send to devlin
2013/12/10 01:21:39
see comment in extension_message_bubble_view.cc, t
Finnur
2013/12/11 23:12:18
These functions are now gone.
| |
62 } | |
63 | |
64 bool SuspiciousExtensionBubbleControllerDelegate::ShowingBubble() const { | |
65 return controller_->showing_bubble(); | |
66 } | |
67 | |
68 bool SuspiciousExtensionBubbleControllerDelegate::HasExtensionList() const { | |
69 return controller_->HasExtensionList(); | |
70 } | |
71 | |
72 std::vector<string16> | |
73 SuspiciousExtensionBubbleControllerDelegate::GetExtensionList() const { | |
74 return controller_->GetExtensionList(); | |
75 } | |
76 | |
77 const ExtensionIdList& | |
78 SuspiciousExtensionBubbleControllerDelegate::GetExtensionIdList() const { | |
79 return controller_->extension_id_list(); | |
80 } | |
81 | |
82 | |
83 bool SuspiciousExtensionBubbleControllerDelegate::ShouldIncludeExtension( | |
84 const std::string& extension_id) { | |
85 ExtensionPrefs* prefs = service_->extension_prefs(); | |
86 if (!prefs->IsExtensionDisabled(extension_id)) | |
87 return false; | |
88 | |
89 int disble_reasons = prefs->GetDisableReasons(extension_id); | |
90 if (disble_reasons & Extension::DISABLE_NOT_VERIFIED) | |
91 return !prefs->HasWipeoutBeenAcknowledged(extension_id); | |
92 | |
93 return false; | |
94 } | |
95 | |
96 void SuspiciousExtensionBubbleControllerDelegate::AcknowledgeExtension( | |
97 const std::string& extension_id, | |
98 ExtensionMessageBubbleController::BubbleAction user_action) { | |
99 ExtensionPrefs* prefs = service_->extension_prefs(); | |
100 prefs->SetWipeoutAcknowledged(extension_id, true); | |
101 } | |
102 | |
103 void SuspiciousExtensionBubbleControllerDelegate::PerformAction( | |
104 const ExtensionIdList& list) { | |
105 // This bubble solicits no action from the user. Or as Nimoy would have it: | |
106 // "Well, my work here is done". | |
107 } | |
108 | |
109 string16 SuspiciousExtensionBubbleControllerDelegate::GetTitle() const { | |
110 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_TITLE); | |
111 } | |
112 | |
113 string16 SuspiciousExtensionBubbleControllerDelegate::GetMessageBody() const { | |
114 return l10n_util::GetStringFUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BODY, | |
115 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); | |
116 } | |
117 | |
118 string16 SuspiciousExtensionBubbleControllerDelegate::GetOverflowText( | |
119 const string16& overflow_count) const { | |
120 return l10n_util::GetStringFUTF16( | |
121 IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE, | |
122 overflow_count); | |
123 } | |
124 | |
125 string16 | |
126 SuspiciousExtensionBubbleControllerDelegate::GetLearnMoreLabel() const { | |
127 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | |
128 } | |
129 | |
130 GURL SuspiciousExtensionBubbleControllerDelegate::GetLearnMoreUrl() const { | |
131 return GURL(chrome::kRemoveNonCWSExtensionURL); | |
132 } | |
133 | |
134 string16 | |
135 SuspiciousExtensionBubbleControllerDelegate::GetActionButtonLabel() const { | |
136 return string16(); | |
137 } | |
138 | |
139 string16 | |
140 SuspiciousExtensionBubbleControllerDelegate::GetDismissButtonLabel() const { | |
141 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BUTTON); | |
142 } | |
143 | |
144 bool | |
145 SuspiciousExtensionBubbleControllerDelegate::ShouldShowExtensionList() const { | |
146 return true; | |
147 } | |
148 | |
149 void SuspiciousExtensionBubbleControllerDelegate::LogExtensionCount( | |
150 size_t count) { | |
151 UMA_HISTOGRAM_COUNTS_100( | |
152 "ExtensionWipeoutBubble.ExtensionWipeoutCount", count); | |
153 } | |
154 | |
155 void SuspiciousExtensionBubbleControllerDelegate::LogAction( | |
156 ExtensionMessageBubbleController::BubbleAction action) { | |
157 UMA_HISTOGRAM_ENUMERATION( | |
158 "ExtensionWipeoutBubble.UserSelection", | |
159 action, ExtensionMessageBubbleController::ACTION_BOUNDARY); | |
160 } | |
161 | |
162 template <> | |
163 void ProfileKeyedAPIFactory< | |
164 SuspiciousExtensionBubbleControllerDelegate>::DeclareFactoryDependencies() { | |
165 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); | |
166 } | |
167 | |
168 } // namespace extensions | |
OLD | NEW |