OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/settings_api_bubble_controller.h" | 5 #include "chrome/browser/extensions/settings_api_bubble_controller.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_toolbar_model.h" |
9 #include "chrome/browser/extensions/settings_api_helpers.h" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 12 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
12 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.
h" | 13 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.
h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "extensions/browser/extension_prefs.h" | 15 #include "extensions/browser/extension_prefs.h" |
15 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
16 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 | 21 |
21 using extensions::ExtensionMessageBubbleController; | 22 namespace extensions { |
22 using extensions::SettingsApiBubbleController; | |
23 using extensions::SettingsOverrides; | |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
28 // SettingsApiBubbleDelegate | 27 // SettingsApiBubbleDelegate |
29 | 28 |
30 class SettingsApiBubbleDelegate | 29 class SettingsApiBubbleDelegate |
31 : public extensions::ExtensionMessageBubbleController::Delegate { | 30 : public ExtensionMessageBubbleController::Delegate { |
32 public: | 31 public: |
33 explicit SettingsApiBubbleDelegate(ExtensionService* service, | 32 explicit SettingsApiBubbleDelegate(ExtensionService* service, |
34 Profile* profile, | 33 Profile* profile, |
35 extensions::SettingsApiOverrideType type); | 34 SettingsApiOverrideType type); |
36 virtual ~SettingsApiBubbleDelegate(); | 35 virtual ~SettingsApiBubbleDelegate(); |
37 | 36 |
38 // ExtensionMessageBubbleController::Delegate methods. | 37 // ExtensionMessageBubbleController::Delegate methods. |
39 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; | 38 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
40 virtual void AcknowledgeExtension( | 39 virtual void AcknowledgeExtension( |
41 const std::string& extension_id, | 40 const std::string& extension_id, |
42 extensions::ExtensionMessageBubbleController::BubbleAction user_action) | 41 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; |
43 OVERRIDE; | 42 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; |
44 virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE; | 43 virtual void OnClose() OVERRIDE; |
45 virtual base::string16 GetTitle() const OVERRIDE; | 44 virtual base::string16 GetTitle() const OVERRIDE; |
46 virtual base::string16 GetMessageBody() const OVERRIDE; | 45 virtual base::string16 GetMessageBody( |
| 46 bool anchored_to_browser_action) const OVERRIDE; |
47 virtual base::string16 GetOverflowText( | 47 virtual base::string16 GetOverflowText( |
48 const base::string16& overflow_count) const OVERRIDE; | 48 const base::string16& overflow_count) const OVERRIDE; |
49 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; | 49 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
50 virtual GURL GetLearnMoreUrl() const OVERRIDE; | 50 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
51 virtual base::string16 GetActionButtonLabel() const OVERRIDE; | 51 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
52 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; | 52 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
53 virtual bool ShouldShowExtensionList() const OVERRIDE; | 53 virtual bool ShouldShowExtensionList() const OVERRIDE; |
54 virtual void LogExtensionCount(size_t count) OVERRIDE; | 54 virtual void LogExtensionCount(size_t count) OVERRIDE; |
55 virtual void LogAction( | 55 virtual void LogAction( |
56 extensions::ExtensionMessageBubbleController::BubbleAction action) | 56 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; |
57 OVERRIDE; | |
58 | 57 |
59 private: | 58 private: |
60 // Our extension service. Weak, not owned by us. | 59 // Our extension service. Weak, not owned by us. |
61 ExtensionService* service_; | 60 ExtensionService* service_; |
62 | 61 |
63 // A weak pointer to the profile we are associated with. Not owned by us. | 62 // A weak pointer to the profile we are associated with. Not owned by us. |
64 Profile* profile_; | 63 Profile* profile_; |
65 | 64 |
66 // The type of settings override this bubble will report on. This can be, for | 65 // The type of settings override this bubble will report on. This can be, for |
67 // example, a bubble to notify the user that the search engine has been | 66 // example, a bubble to notify the user that the search engine has been |
68 // changed by an extension (or homepage/startup pages/etc). | 67 // changed by an extension (or homepage/startup pages/etc). |
69 extensions::SettingsApiOverrideType type_; | 68 SettingsApiOverrideType type_; |
70 | 69 |
71 // The ID of the extension we are showing the bubble for. | 70 // The ID of the extension we are showing the bubble for. |
72 std::string extension_id_; | 71 std::string extension_id_; |
73 | 72 |
74 DISALLOW_COPY_AND_ASSIGN(SettingsApiBubbleDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(SettingsApiBubbleDelegate); |
75 }; | 74 }; |
76 | 75 |
77 SettingsApiBubbleDelegate::SettingsApiBubbleDelegate( | 76 SettingsApiBubbleDelegate::SettingsApiBubbleDelegate( |
78 ExtensionService* service, | 77 ExtensionService* service, |
79 Profile* profile, | 78 Profile* profile, |
80 extensions::SettingsApiOverrideType type) | 79 SettingsApiOverrideType type) |
81 : service_(service), profile_(profile), type_(type) {} | 80 : service_(service), profile_(profile), type_(type) {} |
82 | 81 |
83 SettingsApiBubbleDelegate::~SettingsApiBubbleDelegate() {} | 82 SettingsApiBubbleDelegate::~SettingsApiBubbleDelegate() {} |
84 | 83 |
85 bool SettingsApiBubbleDelegate::ShouldIncludeExtension( | 84 bool SettingsApiBubbleDelegate::ShouldIncludeExtension( |
86 const std::string& extension_id) { | 85 const std::string& extension_id) { |
87 using extensions::ExtensionRegistry; | |
88 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 86 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
89 const extensions::Extension* extension = | 87 const Extension* extension = |
90 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 88 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
91 if (!extension) | 89 if (!extension) |
92 return false; // The extension provided is no longer enabled. | 90 return false; // The extension provided is no longer enabled. |
93 | 91 |
94 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 92 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
95 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) | 93 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) |
96 return false; | 94 return false; |
97 | 95 |
98 const extensions::Extension* override = NULL; | 96 const Extension* override = NULL; |
99 switch (type_) { | 97 switch (type_) { |
100 case extensions::BUBBLE_TYPE_HOME_PAGE: | 98 case BUBBLE_TYPE_HOME_PAGE: |
101 override = extensions::OverridesHomepage(profile_, NULL); | 99 override = GetExtensionOverridingHomepage(profile_, NULL); |
102 break; | 100 break; |
103 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 101 case BUBBLE_TYPE_STARTUP_PAGES: |
104 override = extensions::OverridesStartupPages(profile_, NULL); | 102 override = GetExtensionOverridingStartupPages(profile_, NULL); |
105 break; | 103 break; |
106 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 104 case BUBBLE_TYPE_SEARCH_ENGINE: |
107 override = extensions::OverridesSearchEngine(profile_, NULL); | 105 override = GetExtensionOverridingSearchEngine(profile_, NULL); |
108 break; | 106 break; |
109 } | 107 } |
110 | 108 |
111 if (!override || override->id() != extension->id()) | 109 if (!override || override->id() != extension->id()) |
112 return false; | 110 return false; |
113 | 111 |
114 extension_id_ = extension_id; | 112 extension_id_ = extension_id; |
115 return true; | 113 return true; |
116 } | 114 } |
117 | 115 |
118 void SettingsApiBubbleDelegate::AcknowledgeExtension( | 116 void SettingsApiBubbleDelegate::AcknowledgeExtension( |
119 const std::string& extension_id, | 117 const std::string& extension_id, |
120 ExtensionMessageBubbleController::BubbleAction user_action) { | 118 ExtensionMessageBubbleController::BubbleAction user_action) { |
121 if (user_action != ExtensionMessageBubbleController::ACTION_EXECUTE) { | 119 if (user_action != ExtensionMessageBubbleController::ACTION_EXECUTE) { |
122 extensions::ExtensionPrefs* prefs = | 120 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
123 extensions::ExtensionPrefs::Get(profile_); | |
124 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id, true); | 121 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id, true); |
125 } | 122 } |
126 } | 123 } |
127 | 124 |
128 void SettingsApiBubbleDelegate::PerformAction( | 125 void SettingsApiBubbleDelegate::PerformAction(const ExtensionIdList& list) { |
129 const extensions::ExtensionIdList& list) { | |
130 for (size_t i = 0; i < list.size(); ++i) { | 126 for (size_t i = 0; i < list.size(); ++i) { |
131 service_->DisableExtension(list[i], | 127 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION); |
132 extensions::Extension::DISABLE_USER_ACTION); | |
133 } | 128 } |
134 } | 129 } |
135 | 130 |
| 131 void SettingsApiBubbleDelegate::OnClose() { |
| 132 ExtensionToolbarModel* toolbar_model = ExtensionToolbarModel::Get(profile_); |
| 133 if (toolbar_model) |
| 134 toolbar_model->StopHighlighting(); |
| 135 } |
| 136 |
136 base::string16 SettingsApiBubbleDelegate::GetTitle() const { | 137 base::string16 SettingsApiBubbleDelegate::GetTitle() const { |
137 switch (type_) { | 138 switch (type_) { |
138 case extensions::BUBBLE_TYPE_HOME_PAGE: | 139 case BUBBLE_TYPE_HOME_PAGE: |
139 return l10n_util::GetStringUTF16( | 140 return l10n_util::GetStringUTF16( |
140 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); | 141 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); |
141 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 142 case BUBBLE_TYPE_STARTUP_PAGES: |
142 return l10n_util::GetStringUTF16( | 143 return l10n_util::GetStringUTF16( |
143 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); | 144 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); |
144 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 145 case BUBBLE_TYPE_SEARCH_ENGINE: |
145 return l10n_util::GetStringUTF16( | 146 return l10n_util::GetStringUTF16( |
146 IDS_EXTENSIONS_SETTINGS_API_TITLE_SEARCH_ENGINE_BUBBLE); | 147 IDS_EXTENSIONS_SETTINGS_API_TITLE_SEARCH_ENGINE_BUBBLE); |
147 } | 148 } |
148 NOTREACHED(); | 149 NOTREACHED(); |
149 return base::string16(); | 150 return base::string16(); |
150 } | 151 } |
151 | 152 |
152 base::string16 SettingsApiBubbleDelegate::GetMessageBody() const { | 153 base::string16 SettingsApiBubbleDelegate::GetMessageBody( |
153 using extensions::ExtensionRegistry; | 154 bool anchored_to_browser_action) const { |
154 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 155 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
155 const extensions::Extension* extension = | 156 const Extension* extension = |
156 registry->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED); | 157 registry->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED); |
157 const SettingsOverrides* settings = | 158 const SettingsOverrides* settings = |
158 extension ? SettingsOverrides::Get(extension) : NULL; | 159 extension ? SettingsOverrides::Get(extension) : NULL; |
159 if (!extension || !settings) { | 160 if (!extension || !settings) { |
160 NOTREACHED(); | 161 NOTREACHED(); |
161 return base::string16(); | 162 return base::string16(); |
162 } | 163 } |
163 | 164 |
164 bool home_change = settings->homepage != NULL; | 165 bool home_change = settings->homepage != NULL; |
165 bool startup_change = !settings->startup_pages.empty(); | 166 bool startup_change = !settings->startup_pages.empty(); |
166 bool search_change = settings->search_engine != NULL; | 167 bool search_change = settings->search_engine != NULL; |
167 | 168 |
168 base::string16 body; | 169 base::string16 body; |
169 switch (type_) { | 170 switch (type_) { |
170 case extensions::BUBBLE_TYPE_HOME_PAGE: | 171 case BUBBLE_TYPE_HOME_PAGE: |
171 body = l10n_util::GetStringUTF16( | 172 body = l10n_util::GetStringUTF16( |
172 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_HOME_PAGE); | 173 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_HOME_PAGE); |
173 if (startup_change && search_change) { | 174 if (startup_change && search_change) { |
174 body += l10n_util::GetStringUTF16( | 175 body += l10n_util::GetStringUTF16( |
175 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_SEARCH); | 176 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_SEARCH); |
176 } else if (startup_change) { | 177 } else if (startup_change) { |
177 body += l10n_util::GetStringUTF16( | 178 body += l10n_util::GetStringUTF16( |
178 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); | 179 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); |
179 } else if (search_change) { | 180 } else if (search_change) { |
180 body += l10n_util::GetStringUTF16( | 181 body += l10n_util::GetStringUTF16( |
181 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); | 182 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); |
182 } | 183 } |
183 break; | 184 break; |
184 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 185 case BUBBLE_TYPE_STARTUP_PAGES: |
185 body = l10n_util::GetStringUTF16( | 186 body = l10n_util::GetStringUTF16( |
186 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_START_PAGES); | 187 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_START_PAGES); |
187 if (home_change && search_change) { | 188 if (home_change && search_change) { |
188 body += l10n_util::GetStringUTF16( | 189 body += l10n_util::GetStringUTF16( |
189 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_AND_SEARCH); | 190 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_AND_SEARCH); |
190 } else if (home_change) { | 191 } else if (home_change) { |
191 body += l10n_util::GetStringUTF16( | 192 body += l10n_util::GetStringUTF16( |
192 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_PAGE); | 193 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_PAGE); |
193 } else if (search_change) { | 194 } else if (search_change) { |
194 body += l10n_util::GetStringUTF16( | 195 body += l10n_util::GetStringUTF16( |
195 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); | 196 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); |
196 } | 197 } |
197 break; | 198 break; |
198 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 199 case BUBBLE_TYPE_SEARCH_ENGINE: |
199 body = l10n_util::GetStringUTF16( | 200 body = l10n_util::GetStringUTF16( |
200 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_SEARCH_ENGINE); | 201 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_SEARCH_ENGINE); |
201 if (startup_change && home_change) { | 202 if (startup_change && home_change) { |
202 body += l10n_util::GetStringUTF16( | 203 body += l10n_util::GetStringUTF16( |
203 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_HOME); | 204 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_HOME); |
204 } else if (startup_change) { | 205 } else if (startup_change) { |
205 body += l10n_util::GetStringUTF16( | 206 body += l10n_util::GetStringUTF16( |
206 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); | 207 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); |
207 } else if (home_change) { | 208 } else if (home_change) { |
208 body += l10n_util::GetStringUTF16( | 209 body += l10n_util::GetStringUTF16( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { | 243 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { |
243 return false; | 244 return false; |
244 } | 245 } |
245 | 246 |
246 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { | 247 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { |
247 } | 248 } |
248 | 249 |
249 void SettingsApiBubbleDelegate::LogAction( | 250 void SettingsApiBubbleDelegate::LogAction( |
250 ExtensionMessageBubbleController::BubbleAction action) { | 251 ExtensionMessageBubbleController::BubbleAction action) { |
251 switch (type_) { | 252 switch (type_) { |
252 case extensions::BUBBLE_TYPE_HOME_PAGE: | 253 case BUBBLE_TYPE_HOME_PAGE: |
253 UMA_HISTOGRAM_ENUMERATION( | 254 UMA_HISTOGRAM_ENUMERATION( |
254 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", | 255 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", |
255 action, | 256 action, |
256 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 257 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
257 break; | 258 break; |
258 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 259 case BUBBLE_TYPE_STARTUP_PAGES: |
259 UMA_HISTOGRAM_ENUMERATION( | 260 UMA_HISTOGRAM_ENUMERATION( |
260 "ExtensionOverrideBubble.SettingsApiUserSelectionStartupPage", | 261 "ExtensionOverrideBubble.SettingsApiUserSelectionStartupPage", |
261 action, | 262 action, |
262 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 263 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
263 break; | 264 break; |
264 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 265 case BUBBLE_TYPE_SEARCH_ENGINE: |
265 UMA_HISTOGRAM_ENUMERATION( | 266 UMA_HISTOGRAM_ENUMERATION( |
266 "ExtensionOverrideBubble.SettingsApiUserSelectionSearchEngine", | 267 "ExtensionOverrideBubble.SettingsApiUserSelectionSearchEngine", |
267 action, | 268 action, |
268 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 269 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
269 break; | 270 break; |
270 } | 271 } |
271 } | 272 } |
272 | 273 |
273 } // namespace | 274 } // namespace |
274 | 275 |
275 namespace extensions { | |
276 | |
277 //////////////////////////////////////////////////////////////////////////////// | 276 //////////////////////////////////////////////////////////////////////////////// |
278 // SettingsApiBubbleController | 277 // SettingsApiBubbleController |
279 | 278 |
280 SettingsApiBubbleController::SettingsApiBubbleController( | 279 SettingsApiBubbleController::SettingsApiBubbleController( |
281 Profile* profile, | 280 Profile* profile, |
282 SettingsApiOverrideType type) | 281 SettingsApiOverrideType type) |
283 : ExtensionMessageBubbleController( | 282 : ExtensionMessageBubbleController( |
284 new SettingsApiBubbleDelegate( | 283 new SettingsApiBubbleDelegate( |
285 ExtensionSystem::Get(profile)->extension_service(), | 284 ExtensionSystem::Get(profile)->extension_service(), |
286 profile, | 285 profile, |
287 type), | 286 type), |
288 profile), | 287 profile), |
289 profile_(profile), | 288 profile_(profile), |
290 type_(type) {} | 289 type_(type) {} |
291 | 290 |
292 SettingsApiBubbleController::~SettingsApiBubbleController() {} | 291 SettingsApiBubbleController::~SettingsApiBubbleController() {} |
293 | 292 |
294 bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) { | 293 bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) { |
295 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 294 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
296 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) | 295 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) |
297 return false; | 296 return false; |
298 | 297 |
299 if (!delegate()->ShouldIncludeExtension(extension_id)) | 298 if (!delegate()->ShouldIncludeExtension(extension_id)) |
300 return false; | 299 return false; |
301 | 300 |
302 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing | 301 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing |
303 // the startup pages, so there's no point in showing the bubble now. | 302 // the startup pages, so there's no point in showing the bubble now. |
304 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) | 303 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) |
305 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; | 304 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; |
306 | 305 |
307 return true; | 306 return true; |
308 } | 307 } |
309 | 308 |
310 bool SettingsApiBubbleController::CloseOnDeactivate() { | 309 bool SettingsApiBubbleController::CloseOnDeactivate() { |
311 // Startup bubbles tend to get lost in the focus storm that happens on | 310 // Startup bubbles tend to get lost in the focus storm that happens on |
312 // startup. Other types should dismiss on focus loss. | 311 // startup. Other types should dismiss on focus loss. |
313 return type_ != BUBBLE_TYPE_STARTUP_PAGES; | 312 return type_ != BUBBLE_TYPE_STARTUP_PAGES; |
314 } | 313 } |
315 | 314 |
316 } // namespace extensions | 315 } // namespace extensions |
OLD | NEW |