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/extension_toolbar_model.h" |
10 #include "chrome/browser/extensions/settings_api_helpers.h" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void PerformAction(const ExtensionIdList& list) override; | 47 void PerformAction(const ExtensionIdList& list) override; |
48 void OnClose() override; | 48 void OnClose() override; |
49 base::string16 GetTitle() const override; | 49 base::string16 GetTitle() const override; |
50 base::string16 GetMessageBody(bool anchored_to_browser_action) const override; | 50 base::string16 GetMessageBody(bool anchored_to_browser_action) const override; |
51 base::string16 GetOverflowText( | 51 base::string16 GetOverflowText( |
52 const base::string16& overflow_count) const override; | 52 const base::string16& overflow_count) const override; |
53 GURL GetLearnMoreUrl() const override; | 53 GURL GetLearnMoreUrl() const override; |
54 base::string16 GetActionButtonLabel() const override; | 54 base::string16 GetActionButtonLabel() const override; |
55 base::string16 GetDismissButtonLabel() const override; | 55 base::string16 GetDismissButtonLabel() const override; |
56 bool ShouldShowExtensionList() const override; | 56 bool ShouldShowExtensionList() const override; |
| 57 bool ShouldHighlightExtensions() const override; |
57 void LogExtensionCount(size_t count) override; | 58 void LogExtensionCount(size_t count) override; |
58 void LogAction( | 59 void LogAction( |
59 ExtensionMessageBubbleController::BubbleAction action) override; | 60 ExtensionMessageBubbleController::BubbleAction action) override; |
60 | 61 |
61 private: | 62 private: |
62 // Our extension service. Weak, not owned by us. | 63 // Our extension service. Weak, not owned by us. |
63 ExtensionService* service_; | 64 ExtensionService* service_; |
64 | 65 |
65 // A weak pointer to the profile we are associated with. Not owned by us. | 66 // A weak pointer to the profile we are associated with. Not owned by us. |
66 Profile* profile_; | 67 Profile* profile_; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 | 239 |
239 base::string16 SettingsApiBubbleDelegate::GetDismissButtonLabel() const { | 240 base::string16 SettingsApiBubbleDelegate::GetDismissButtonLabel() const { |
240 return l10n_util::GetStringUTF16(IDS_EXTENSION_CONTROLLED_KEEP_CHANGES); | 241 return l10n_util::GetStringUTF16(IDS_EXTENSION_CONTROLLED_KEEP_CHANGES); |
241 } | 242 } |
242 | 243 |
243 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { | 244 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { |
244 return false; | 245 return false; |
245 } | 246 } |
246 | 247 |
| 248 bool SettingsApiBubbleDelegate::ShouldHighlightExtensions() const { |
| 249 return type_ == BUBBLE_TYPE_STARTUP_PAGES; |
| 250 } |
| 251 |
247 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { | 252 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { |
248 } | 253 } |
249 | 254 |
250 void SettingsApiBubbleDelegate::LogAction( | 255 void SettingsApiBubbleDelegate::LogAction( |
251 ExtensionMessageBubbleController::BubbleAction action) { | 256 ExtensionMessageBubbleController::BubbleAction action) { |
252 switch (type_) { | 257 switch (type_) { |
253 case BUBBLE_TYPE_HOME_PAGE: | 258 case BUBBLE_TYPE_HOME_PAGE: |
254 UMA_HISTOGRAM_ENUMERATION( | 259 UMA_HISTOGRAM_ENUMERATION( |
255 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", | 260 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", |
256 action, | 261 action, |
(...skipping 26 matching lines...) Expand all Loading... |
283 new SettingsApiBubbleDelegate( | 288 new SettingsApiBubbleDelegate( |
284 ExtensionSystem::Get(profile)->extension_service(), | 289 ExtensionSystem::Get(profile)->extension_service(), |
285 profile, | 290 profile, |
286 type), | 291 type), |
287 profile), | 292 profile), |
288 profile_(profile), | 293 profile_(profile), |
289 type_(type) {} | 294 type_(type) {} |
290 | 295 |
291 SettingsApiBubbleController::~SettingsApiBubbleController() {} | 296 SettingsApiBubbleController::~SettingsApiBubbleController() {} |
292 | 297 |
293 bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) { | 298 bool SettingsApiBubbleController::ShouldShow() { |
294 if (delegate()->HasBubbleInfoBeenAcknowledged(extension_id)) | 299 const Extension* extension = nullptr; |
| 300 switch (type_) { |
| 301 case BUBBLE_TYPE_HOME_PAGE: |
| 302 extension = GetExtensionOverridingHomepage(profile_); |
| 303 break; |
| 304 case BUBBLE_TYPE_SEARCH_ENGINE: |
| 305 extension = GetExtensionOverridingSearchEngine(profile_); |
| 306 break; |
| 307 case BUBBLE_TYPE_STARTUP_PAGES: |
| 308 extension = GetExtensionOverridingStartupPages(profile_); |
| 309 break; |
| 310 } |
| 311 |
| 312 if (!extension) |
295 return false; | 313 return false; |
296 | 314 |
297 if (!delegate()->ShouldIncludeExtension(extension_id)) | 315 if (delegate()->HasBubbleInfoBeenAcknowledged(extension->id())) |
| 316 return false; |
| 317 |
| 318 if (!delegate()->ShouldIncludeExtension(extension->id())) |
298 return false; | 319 return false; |
299 | 320 |
300 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing | 321 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing |
301 // the startup pages, so there's no point in showing the bubble now. | 322 // the startup pages, so there's no point in showing the bubble now. |
302 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) | 323 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) |
303 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; | 324 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; |
304 | 325 |
305 return true; | 326 return true; |
306 } | 327 } |
307 | 328 |
308 bool SettingsApiBubbleController::CloseOnDeactivate() { | 329 bool SettingsApiBubbleController::CloseOnDeactivate() { |
309 // Startup bubbles tend to get lost in the focus storm that happens on | 330 // Startup bubbles tend to get lost in the focus storm that happens on |
310 // startup. Other types should dismiss on focus loss. | 331 // startup. Other types should dismiss on focus loss. |
311 return type_ != BUBBLE_TYPE_STARTUP_PAGES; | 332 return type_ != BUBBLE_TYPE_STARTUP_PAGES; |
312 } | 333 } |
313 | 334 |
314 } // namespace extensions | 335 } // namespace extensions |
OLD | NEW |