Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/disabled_extensions_view.cc |
| =================================================================== |
| --- chrome/browser/ui/views/extensions/disabled_extensions_view.cc (revision 163351) |
| +++ chrome/browser/ui/views/extensions/disabled_extensions_view.cc (working copy) |
| @@ -9,9 +9,12 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/singleton_tabs.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/common/extensions/feature_switch.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "grit/generated_resources.h" |
| @@ -43,6 +46,9 @@ |
| const int kHeadlineRowPadding = 10; |
| const int kMessageBubblePadding = 11; |
| +// How often to show the disabled extension (sideload wipeout) bubble. |
| +const int kShowSideloadWipeoutBubbleMax = 3; |
| + |
| // How many extensions to show in the bubble (max). |
| const int kMaxExtensionsToShow = 7; |
| @@ -52,22 +58,26 @@ |
| // DisabledExtensionsView |
| // static |
| -bool DisabledExtensionsView::MaybeShow(Browser* browser, |
| +void DisabledExtensionsView::MaybeShow(Browser* browser, |
| views::View* anchor_view) { |
| -#if !defined(OS_WIN) |
| - // We are targeting registry-installed extensions, which is Windows-specific, |
| - // and extensions marked internal and not from the web store, which are mostly |
| - // problematic on Windows. |
| - return false; |
| -#endif |
| - |
| if (!extensions::FeatureSwitch::sideload_wipeout()->IsEnabled()) |
| - return false; |
| + return; |
| static bool done_showing_ui = false; |
| if (done_showing_ui) |
| - return false; // Only show the bubble once per launch. |
| + return; // Only show the bubble once per launch. |
| + // A pref that counts how often the bubble has been shown. |
| + IntegerPrefMember sideload_wipeout_bubble_shown; |
| + |
| + sideload_wipeout_bubble_shown.Init( |
|
Aaron Boodman
2012/10/23 16:18:06
Since this is used in multiple methods and is low-
Finnur
2012/10/23 16:55:45
This function is static and this (would be) member
|
| + prefs::kExtensionsSideloadWipeoutBubbleShown, |
| + browser->profile()->GetPrefs(), NULL); |
| + int bubble_shown_count = sideload_wipeout_bubble_shown.GetValue(); |
| + if (bubble_shown_count >= kShowSideloadWipeoutBubbleMax) |
| + return; |
| + sideload_wipeout_bubble_shown.SetValue(++bubble_shown_count); |
| + |
| // Fetch all disabled extensions. |
| ExtensionService* extension_service = |
| extensions::ExtensionSystem::Get( |
| @@ -82,10 +92,7 @@ |
| bubble_delegate->StartFade(true); |
| done_showing_ui = true; |
| - return true; |
| } |
| - |
| - return false; |
| } |
| DisabledExtensionsView::DisabledExtensionsView( |
| @@ -109,6 +116,14 @@ |
| DisabledExtensionsView::~DisabledExtensionsView() { |
| } |
| +void DisabledExtensionsView::DontShowBubbleAgain() { |
| + IntegerPrefMember sideload_wipeout_bubble_shown; |
| + sideload_wipeout_bubble_shown.Init( |
| + prefs::kExtensionsSideloadWipeoutBubbleShown, |
| + browser_->profile()->GetPrefs(), NULL); |
| + sideload_wipeout_bubble_shown.SetValue(kShowSideloadWipeoutBubbleMax); |
| +} |
| + |
| void DisabledExtensionsView::ButtonPressed(views::Button* sender, |
| const ui::Event& event) { |
| if (sender == settings_button_) { |
| @@ -123,11 +138,12 @@ |
| } else if (sender == dismiss_button_) { |
| content::RecordAction(UserMetricsAction("DisabledExtension_Dismiss")); |
| - // No action required. Close will happen below. |
| } else { |
| NOTREACHED(); |
| } |
| + DontShowBubbleAgain(); |
|
Aaron Boodman
2012/10/23 16:18:06
Per Peter's comment, this should go in LinkClicked
Finnur
2012/10/23 16:55:45
Done.
On 2012/10/23 16:18:06, Aaron Boodman wrote
|
| + |
| GetWidget()->Close(); |
| } |