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