Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1513)

Side by Side Diff: chrome/browser/ui/views/extensions/disabled_extensions_view.cc

Issue 11232060: Make sure sideload wipeout doesn't interfere with the tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/extensions/disabled_extensions_view.h" 5 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/singleton_tabs.h" 14 #include "chrome/browser/ui/singleton_tabs.h"
15 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/common/extensions/feature_switch.h" 16 #include "chrome/common/extensions/feature_switch.h"
17 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
16 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
17 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
18 #include "grit/locale_settings.h" 21 #include "grit/locale_settings.h"
19 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
20 #include "ui/base/accessibility/accessible_view_state.h" 23 #include "ui/base/accessibility/accessible_view_state.h"
21 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/views/controls/button/text_button.h" 26 #include "ui/views/controls/button/text_button.h"
24 #include "ui/views/controls/label.h" 27 #include "ui/views/controls/label.h"
(...skipping 11 matching lines...) Expand all
36 const int kColumnPadding = 4; 39 const int kColumnPadding = 4;
37 const int kExtensionListPadding = 20; 40 const int kExtensionListPadding = 20;
38 const int kImagePadding = 7; 41 const int kImagePadding = 7;
39 const int kLeftColumnPadding = 3; 42 const int kLeftColumnPadding = 3;
40 const int kInsetBottomRight = 13; 43 const int kInsetBottomRight = 13;
41 const int kInsetTopLeft = 14; 44 const int kInsetTopLeft = 14;
42 const int kHeadlineMessagePadding = 4; 45 const int kHeadlineMessagePadding = 4;
43 const int kHeadlineRowPadding = 10; 46 const int kHeadlineRowPadding = 10;
44 const int kMessageBubblePadding = 11; 47 const int kMessageBubblePadding = 11;
45 48
49 // How often to show the disabled extension (sideload wipeout) bubble.
50 const int kShowSideloadWipeoutBubbleMax = 3;
51
46 // How many extensions to show in the bubble (max). 52 // How many extensions to show in the bubble (max).
47 const int kMaxExtensionsToShow = 7; 53 const int kMaxExtensionsToShow = 7;
48 54
49 } // namespace 55 } // namespace
50 56
51 //////////////////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////////////////
52 // DisabledExtensionsView 58 // DisabledExtensionsView
53 59
54 // static 60 // static
55 bool DisabledExtensionsView::MaybeShow(Browser* browser, 61 void DisabledExtensionsView::MaybeShow(Browser* browser,
56 views::View* anchor_view) { 62 views::View* anchor_view) {
57 #if !defined(OS_WIN) 63 #if !defined(OS_WIN)
Aaron Boodman 2012/10/23 15:20:20 Shouldn't be necessary anymore, right?
58 // We are targeting registry-installed extensions, which is Windows-specific, 64 // We are targeting registry-installed extensions, which are Windows-specific,
59 // and extensions marked internal and not from the web store, which are mostly 65 // and extensions marked internal and not from the web store, which are mostly
60 // problematic on Windows. 66 // problematic on Windows.
61 return false; 67 return;
62 #endif 68 #endif
63 69
64 if (!extensions::FeatureSwitch::sideload_wipeout()->IsEnabled()) 70 if (!extensions::FeatureSwitch::sideload_wipeout()->IsEnabled())
65 return false; 71 return;
66 72
67 static bool done_showing_ui = false; 73 static bool done_showing_ui = false;
68 if (done_showing_ui) 74 if (done_showing_ui)
69 return false; // Only show the bubble once per launch. 75 return; // Only show the bubble once per launch.
76
77 // A pref that counts how often the bubble has been shown.
78 IntegerPrefMember sideload_wipeout_bubble_shown;
79
80 sideload_wipeout_bubble_shown.Init(
81 prefs::kExtensionsSideloadWipeoutBubbleShown,
82 browser->profile()->GetPrefs(), NULL);
83 int bubble_shown_count = sideload_wipeout_bubble_shown.GetValue();
84 if (bubble_shown_count >= kShowSideloadWipeoutBubbleMax)
85 return;
86 sideload_wipeout_bubble_shown.SetValue(++bubble_shown_count);
70 87
71 // Fetch all disabled extensions. 88 // Fetch all disabled extensions.
72 ExtensionService* extension_service = 89 ExtensionService* extension_service =
73 extensions::ExtensionSystem::Get( 90 extensions::ExtensionSystem::Get(
74 browser->profile())->extension_service(); 91 browser->profile())->extension_service();
75 scoped_ptr<const ExtensionSet> wiped_out( 92 scoped_ptr<const ExtensionSet> wiped_out(
76 extension_service->GetWipedOutExtensions()); 93 extension_service->GetWipedOutExtensions());
77 if (wiped_out->size()) { 94 if (wiped_out->size()) {
78 DisabledExtensionsView* bubble_delegate = 95 DisabledExtensionsView* bubble_delegate =
79 new DisabledExtensionsView( 96 new DisabledExtensionsView(
80 anchor_view, browser, wiped_out.release()); 97 anchor_view, browser, wiped_out.release());
81 views::BubbleDelegateView::CreateBubble(bubble_delegate); 98 views::BubbleDelegateView::CreateBubble(bubble_delegate);
82 bubble_delegate->StartFade(true); 99 bubble_delegate->StartFade(true);
83 100
84 done_showing_ui = true; 101 done_showing_ui = true;
85 return true;
86 } 102 }
87
88 return false;
89 } 103 }
90 104
91 DisabledExtensionsView::DisabledExtensionsView( 105 DisabledExtensionsView::DisabledExtensionsView(
92 views::View* anchor_view, 106 views::View* anchor_view,
93 Browser* browser, 107 Browser* browser,
94 const ExtensionSet* wiped_out) 108 const ExtensionSet* wiped_out)
95 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 109 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
96 browser_(browser), 110 browser_(browser),
97 wiped_out_(wiped_out), 111 wiped_out_(wiped_out),
98 headline_(NULL), 112 headline_(NULL),
(...skipping 17 matching lines...) Expand all
116 UserMetricsAction("DisabledExtension_SettingsButton")); 130 UserMetricsAction("DisabledExtension_SettingsButton"));
117 browser_->OpenURL( 131 browser_->OpenURL(
118 content::OpenURLParams(GURL(chrome::kChromeUIExtensionsURL), 132 content::OpenURLParams(GURL(chrome::kChromeUIExtensionsURL),
119 content::Referrer(), 133 content::Referrer(),
120 NEW_FOREGROUND_TAB, 134 NEW_FOREGROUND_TAB,
121 content::PAGE_TRANSITION_LINK, 135 content::PAGE_TRANSITION_LINK,
122 false)); 136 false));
123 137
124 } else if (sender == dismiss_button_) { 138 } else if (sender == dismiss_button_) {
125 content::RecordAction(UserMetricsAction("DisabledExtension_Dismiss")); 139 content::RecordAction(UserMetricsAction("DisabledExtension_Dismiss"));
126 // No action required. Close will happen below. 140 IntegerPrefMember sideload_wipeout_bubble_shown;
Aaron Boodman 2012/10/23 15:23:38 I think that it's only supposed to be shown once,
Finnur 2012/10/23 15:43:10 That makes sense for the buttons, but I'm not as s
Peter Ludwig 2012/10/23 16:11:01 It's fine for the bubble to dismiss (and to never
Finnur 2012/10/23 16:55:44 Sounds good.
141 sideload_wipeout_bubble_shown.Init(
142 prefs::kExtensionsSideloadWipeoutBubbleShown,
143 browser_->profile()->GetPrefs(), NULL);
144 sideload_wipeout_bubble_shown.SetValue(kShowSideloadWipeoutBubbleMax);
127 } else { 145 } else {
128 NOTREACHED(); 146 NOTREACHED();
129 } 147 }
130 148
131 GetWidget()->Close(); 149 GetWidget()->Close();
132 } 150 }
133 151
134 void DisabledExtensionsView::LinkClicked( 152 void DisabledExtensionsView::LinkClicked(
135 views::Link* source, int event_flags) { 153 views::Link* source, int event_flags) {
136 content::RecordAction(UserMetricsAction("DisabledExtension_LearnMore")); 154 content::RecordAction(UserMetricsAction("DisabledExtension_LearnMore"));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 layout->AddView(settings_button_); 302 layout->AddView(settings_button_);
285 dismiss_button_ = new views::NativeTextButton(this, 303 dismiss_button_ = new views::NativeTextButton(this,
286 l10n_util::GetStringUTF16(IDS_OPTIONS_SIDELOAD_WIPEOUT_DISMISS)); 304 l10n_util::GetStringUTF16(IDS_OPTIONS_SIDELOAD_WIPEOUT_DISMISS));
287 dismiss_button_->SetFont( 305 dismiss_button_->SetFont(
288 dismiss_button_->font().DeriveFont(0, gfx::Font::BOLD)); 306 dismiss_button_->font().DeriveFont(0, gfx::Font::BOLD));
289 layout->AddView(dismiss_button_); 307 layout->AddView(dismiss_button_);
290 308
291 content::RecordAction( 309 content::RecordAction(
292 UserMetricsAction("DisabledExtensionNotificationShown")); 310 UserMetricsAction("DisabledExtensionNotificationShown"));
293 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698