diff options
author | engedy@chromium.org <engedy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 17:20:06 +0000 |
---|---|---|
committer | engedy@chromium.org <engedy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 17:20:06 +0000 |
commit | 4deac0de619aa03721e3cadd0622de98c693360e (patch) | |
tree | a400f23dd3e61d6a695f5a83df81e0d38b3b6069 | |
parent | 3ed84729d876d6bc22b2da8ffc8a2cd609a5004a (diff) | |
download | chromium_src-4deac0de619aa03721e3cadd0622de98c693360e.zip chromium_src-4deac0de619aa03721e3cadd0622de98c693360e.tar.gz chromium_src-4deac0de619aa03721e3cadd0622de98c693360e.tar.bz2 |
Refactored GlobalError to allow having custom bubble UI or no bubble at all.
BUG=298036
Review URL: https://codereview.chromium.org/27173002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232419 0039d316-1c4b-4281-b951-d872f2087c98
30 files changed, 266 insertions, 327 deletions
diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc index 738daf2..6a509cd 100644 --- a/chrome/browser/extensions/extension_disabled_ui.cc +++ b/chrome/browser/extensions/extension_disabled_ui.cc @@ -135,7 +135,7 @@ void ExtensionDisabledDialogDelegate::InstallUIAbort(bool user_initiated) { // ExtensionDisabledGlobalError ----------------------------------------------- -class ExtensionDisabledGlobalError : public GlobalError, +class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, public content::NotificationObserver, public ExtensionUninstallDialog::Delegate { public: @@ -150,7 +150,6 @@ class ExtensionDisabledGlobalError : public GlobalError, virtual int MenuItemCommandID() OVERRIDE; virtual string16 MenuItemLabel() OVERRIDE; virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; - virtual bool HasBubbleView() OVERRIDE; virtual gfx::Image GetBubbleViewIcon() OVERRIDE; virtual string16 GetBubbleViewTitle() OVERRIDE; virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; @@ -244,10 +243,6 @@ void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) { ShowBubbleView(browser); } -bool ExtensionDisabledGlobalError::HasBubbleView() { - return true; -} - gfx::Image ExtensionDisabledGlobalError::GetBubbleViewIcon() { return icon_; } diff --git a/chrome/browser/extensions/extension_error_ui_default.cc b/chrome/browser/extensions/extension_error_ui_default.cc index a5b7067..dce30ec 100644 --- a/chrome/browser/extensions/extension_error_ui_default.cc +++ b/chrome/browser/extensions/extension_error_ui_default.cc @@ -70,10 +70,6 @@ void ExtensionErrorUIDefault::ExtensionGlobalError::ExecuteMenuItem( NOTREACHED(); } -bool ExtensionErrorUIDefault::ExtensionGlobalError::HasBubbleView() { - return true; -} - string16 ExtensionErrorUIDefault::ExtensionGlobalError::GetBubbleViewTitle() { return error_ui_->GetBubbleViewTitle(); } diff --git a/chrome/browser/extensions/extension_error_ui_default.h b/chrome/browser/extensions/extension_error_ui_default.h index 75808aa..6861d56 100644 --- a/chrome/browser/extensions/extension_error_ui_default.h +++ b/chrome/browser/extensions/extension_error_ui_default.h @@ -25,7 +25,7 @@ class ExtensionErrorUIDefault : public ExtensionErrorUI { virtual void Close() OVERRIDE; private: - class ExtensionGlobalError : public GlobalError { + class ExtensionGlobalError : public GlobalErrorWithStandardBubble { public: explicit ExtensionGlobalError(ExtensionErrorUIDefault* error_ui); @@ -35,7 +35,6 @@ class ExtensionErrorUIDefault : public ExtensionErrorUI { virtual int MenuItemCommandID() OVERRIDE; virtual string16 MenuItemLabel() OVERRIDE; virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; - virtual bool HasBubbleView() OVERRIDE; virtual string16 GetBubbleViewTitle() OVERRIDE; virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; diff --git a/chrome/browser/extensions/extension_warning_badge_service.cc b/chrome/browser/extensions/extension_warning_badge_service.cc index 59edff7..3ef80c4 100644 --- a/chrome/browser/extensions/extension_warning_badge_service.cc +++ b/chrome/browser/extensions/extension_warning_badge_service.cc @@ -32,13 +32,9 @@ class ErrorBadge : public GlobalError { virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; virtual bool HasBubbleView() OVERRIDE; - virtual string16 GetBubbleViewTitle() OVERRIDE; - virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; - virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; - virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; - virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; - virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; - virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; + virtual bool HasShownBubbleView() OVERRIDE; + virtual void ShowBubbleView(Browser* browser) OVERRIDE; + virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; static int GetMenuItemCommandID(); @@ -73,35 +69,14 @@ void ErrorBadge::ExecuteMenuItem(Browser* browser) { chrome::ExecuteCommand(browser, IDC_MANAGE_EXTENSIONS); } -bool ErrorBadge::HasBubbleView() { - return false; -} - -string16 ErrorBadge::GetBubbleViewTitle() { - return string16(); -} +bool ErrorBadge::HasBubbleView() { return false; } -std::vector<string16> ErrorBadge::GetBubbleViewMessages() { - return std::vector<string16>(); -} - -string16 ErrorBadge::GetBubbleViewAcceptButtonLabel() { - return string16(); -} +bool ErrorBadge::HasShownBubbleView() { return false; } -string16 ErrorBadge::GetBubbleViewCancelButtonLabel() { - return string16(); -} - -void ErrorBadge::OnBubbleViewDidClose(Browser* browser) { -} - -void ErrorBadge::BubbleViewAcceptButtonPressed(Browser* browser) { - NOTREACHED(); -} +void ErrorBadge::ShowBubbleView(Browser* browser) { NOTREACHED(); } -void ErrorBadge::BubbleViewCancelButtonPressed(Browser* browser) { - NOTREACHED(); +GlobalErrorBubbleViewBase* ErrorBadge::GetBubbleView() { + return NULL; } // static @@ -168,4 +143,4 @@ void ExtensionWarningBadgeService::ShowBadge(bool show) { } } -} // extensions +} // namespace extensions diff --git a/chrome/browser/extensions/external_install_ui.cc b/chrome/browser/extensions/external_install_ui.cc index d277194..75c6974 100644 --- a/chrome/browser/extensions/external_install_ui.cc +++ b/chrome/browser/extensions/external_install_ui.cc @@ -90,7 +90,7 @@ class ExternalInstallDialogDelegate // Only shows a menu item, no bubble. Clicking the menu item shows // an external install dialog. -class ExternalInstallMenuAlert : public GlobalError, +class ExternalInstallMenuAlert : public GlobalErrorWithStandardBubble, public content::NotificationObserver { public: ExternalInstallMenuAlert(ExtensionService* service, @@ -355,7 +355,7 @@ bool ExternalInstallGlobalError::HasBubbleView() { gfx::Image ExternalInstallGlobalError::GetBubbleViewIcon() { if (prompt_->icon().IsEmpty()) - return GlobalError::GetBubbleViewIcon(); + return GlobalErrorWithStandardBubble::GetBubbleViewIcon(); // Scale icon to a reasonable size. return gfx::Image(gfx::ImageSkiaOperations::CreateResizedImage( *prompt_->icon().ToImageSkia(), diff --git a/chrome/browser/profile_resetter/profile_reset_callback.h b/chrome/browser/profile_resetter/profile_reset_callback.h deleted file mode 100644 index b0aa19a..0000000 --- a/chrome/browser/profile_resetter/profile_reset_callback.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_CALLBACK_H_ -#define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_CALLBACK_H_ - -#include "base/callback_forward.h" - -// A callback invoked by the settings reset bubble when the user chooses to -// reset her preferences. The bool provided in the first argument is true when -// the user has consented to provide feedback to Google. Implementations are -// responsible for running the closure provided in the second argument when the -// reset has completed. -typedef base::Callback<void(bool, const base::Closure&)> ProfileResetCallback; - -#endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_CALLBACK_H_ diff --git a/chrome/browser/profile_resetter/profile_reset_global_error.cc b/chrome/browser/profile_resetter/profile_reset_global_error.cc index e4c1ce4..03c78c7 100644 --- a/chrome/browser/profile_resetter/profile_reset_global_error.cc +++ b/chrome/browser/profile_resetter/profile_reset_global_error.cc @@ -4,70 +4,79 @@ #include "chrome/browser/profile_resetter/profile_reset_global_error.h" -#include "base/logging.h" +#include "base/metrics/histogram.h" #include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/ui/show_profile_reset_bubble.h" +#include "chrome/browser/ui/profile_reset_bubble.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" -ProfileResetGlobalError::ProfileResetGlobalError() { -} +namespace { -ProfileResetGlobalError::~ProfileResetGlobalError() { -} +// The maximum number of ignored bubbles we track in the NumNoThanksPerReset +// histogram. +const int kMaxIgnored = 50; -bool ProfileResetGlobalError::HasMenuItem() { - return true; -} +// The number of buckets we want the NumNoThanksPerReset histogram to use. +const int kNumIgnoredBuckets = 5; + +} // namespace + + +// ProfileResetGlobalError --------------------------------------------------- + +ProfileResetGlobalError::ProfileResetGlobalError(Profile* profile) + : profile_(profile), num_times_bubble_view_shown_(0), bubble_view_(NULL) {} + +ProfileResetGlobalError::~ProfileResetGlobalError() {} + +bool ProfileResetGlobalError::HasMenuItem() { return true; } int ProfileResetGlobalError::MenuItemCommandID() { return IDC_SHOW_SETTINGS_RESET_BUBBLE; } string16 ProfileResetGlobalError::MenuItemLabel() { - return l10n_util::GetStringFUTF16(IDS_RESET_SETTINGS_MENU_ITEM, + return l10n_util::GetStringFUTF16( + IDS_RESET_SETTINGS_MENU_ITEM, l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); } void ProfileResetGlobalError::ExecuteMenuItem(Browser* browser) { - ShowProfileResetBubble(browser, reset_callback_); + ShowBubbleView(browser); } -// We don't use the GlobalErrorBubbleViewBase since it is not flexible enough -// for our needs. -bool ProfileResetGlobalError::HasBubbleView() { - return false; -} - -string16 ProfileResetGlobalError::GetBubbleViewTitle() { - NOTREACHED(); - return string16(); -} +bool ProfileResetGlobalError::HasBubbleView() { return true; } -std::vector<string16> ProfileResetGlobalError::GetBubbleViewMessages() { - NOTREACHED(); - return std::vector<string16>(); +bool ProfileResetGlobalError::HasShownBubbleView() { + return num_times_bubble_view_shown_ > 0; } -string16 ProfileResetGlobalError::GetBubbleViewAcceptButtonLabel() { - NOTREACHED(); - return string16(); +void ProfileResetGlobalError::ShowBubbleView(Browser* browser) { + if (bubble_view_) + return; + ++num_times_bubble_view_shown_; + bubble_view_ = ShowProfileResetBubble(AsWeakPtr(), browser); } -string16 ProfileResetGlobalError::GetBubbleViewCancelButtonLabel() { - NOTREACHED(); - return string16(); +void ProfileResetGlobalError::OnBubbleViewDidClose() { + bubble_view_ = NULL; } -void ProfileResetGlobalError::OnBubbleViewDidClose(Browser* browser) { - NOTREACHED(); +void ProfileResetGlobalError::OnBubbleViewResetButtonPressed( + bool send_feedback) { + // TODO(engedy): Integrate with the AutomaticProfileResetter. + UMA_HISTOGRAM_CUSTOM_COUNTS("SettingsResetBubble.NumNoThanksPerReset", + num_times_bubble_view_shown_ - 1, + 0, + kMaxIgnored, + kNumIgnoredBuckets); } -void ProfileResetGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { - NOTREACHED(); +void ProfileResetGlobalError::OnBubbleViewNoThanksButtonPressed() { + // TODO(engedy): Integrate with the AutomaticProfileResetter. } -void ProfileResetGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { - NOTREACHED(); +GlobalErrorBubbleViewBase* ProfileResetGlobalError::GetBubbleView() { + return bubble_view_; } diff --git a/chrome/browser/profile_resetter/profile_reset_global_error.h b/chrome/browser/profile_resetter/profile_reset_global_error.h index cf9dfaa..8b35696 100644 --- a/chrome/browser/profile_resetter/profile_reset_global_error.h +++ b/chrome/browser/profile_resetter/profile_reset_global_error.h @@ -6,39 +6,51 @@ #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ #include "base/basictypes.h" -#include "base/callback.h" -#include "chrome/browser/profile_resetter/profile_reset_callback.h" +#include "base/memory/weak_ptr.h" #include "chrome/browser/ui/global_error/global_error.h" +class GlobalErrorBubbleViewBase; +class Profile; + // Shows preferences reset errors on the wrench menu and exposes a menu item to // launch a bubble view. -class ProfileResetGlobalError : public GlobalError { +class ProfileResetGlobalError + : public GlobalError, + public base::SupportsWeakPtr<ProfileResetGlobalError> { public: - ProfileResetGlobalError(); + explicit ProfileResetGlobalError(Profile* profile); virtual ~ProfileResetGlobalError(); - // GlobalError overrides. + // Called by the bubble view when it is closed. + void OnBubbleViewDidClose(); + + // Called when the user clicks on the 'Reset' button. The user can choose to + // send feedback containing the old settings that are now being reset, this is + // indicated by |send_feedback|. + void OnBubbleViewResetButtonPressed(bool send_feedback); + + // Called when the user clicks the 'No, thanks' button. + void OnBubbleViewNoThanksButtonPressed(); + + // GlobalError: virtual bool HasMenuItem() OVERRIDE; virtual int MenuItemCommandID() OVERRIDE; virtual string16 MenuItemLabel() OVERRIDE; virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; virtual bool HasBubbleView() OVERRIDE; - virtual string16 GetBubbleViewTitle() OVERRIDE; - virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; - virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; - virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; - virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; - virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; - virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; - - // Sets a callback to be given to the bubble to be called when the user - // chooses to reset the settings. - void set_reset_callback(const ProfileResetCallback& reset_callback) { - reset_callback_ = reset_callback; - } + virtual bool HasShownBubbleView() OVERRIDE; + virtual void ShowBubbleView(Browser* browser) OVERRIDE; + virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; private: - ProfileResetCallback reset_callback_; + Profile* profile_; + + // The number of times we have shown the bubble so far. This can be >1 if the + // user dismissed the bubble, then selected the menu item to show it again. + int num_times_bubble_view_shown_; + + // The reset bubble, if we're currently showing one. + GlobalErrorBubbleViewBase* bubble_view_; DISALLOW_COPY_AND_ASSIGN(ProfileResetGlobalError); }; diff --git a/chrome/browser/signin/signin_global_error.h b/chrome/browser/signin/signin_global_error.h index d8852a7..459fe27 100644 --- a/chrome/browser/signin/signin_global_error.h +++ b/chrome/browser/signin/signin_global_error.h @@ -18,7 +18,7 @@ class Profile; // register an AuthStatusProvider to report their current authentication state, // and should invoke AuthStatusChanged() when their authentication state may // have changed. -class SigninGlobalError : public GlobalError { +class SigninGlobalError : public GlobalErrorWithStandardBubble { public: class AuthStatusProvider { public: diff --git a/chrome/browser/sync/sync_global_error.h b/chrome/browser/sync/sync_global_error.h index 8a114cc..9e82f44 100644 --- a/chrome/browser/sync/sync_global_error.h +++ b/chrome/browser/sync/sync_global_error.h @@ -15,7 +15,7 @@ class SigninManagerBase; // Shows sync errors on the wrench menu using a bubble view and a // menu item. -class SyncGlobalError : public GlobalError, +class SyncGlobalError : public GlobalErrorWithStandardBubble, public ProfileSyncServiceObserver { public: SyncGlobalError(ProfileSyncService* service, SigninManagerBase* signin); diff --git a/chrome/browser/ui/cocoa/global_error_bubble_controller.h b/chrome/browser/ui/cocoa/global_error_bubble_controller.h index b2106e6..5d80a35 100644 --- a/chrome/browser/ui/cocoa/global_error_bubble_controller.h +++ b/chrome/browser/ui/cocoa/global_error_bubble_controller.h @@ -12,7 +12,7 @@ #import "chrome/browser/ui/cocoa/base_bubble_controller.h" class Browser; -class GlobalError; +class GlobalErrorWithStandardBubble; @class GTMUILocalizerAndLayoutTweaker; @class GTMWidthBasedTweaker; class Profile; @@ -25,7 +25,7 @@ class Bridge; // about a global error. @interface GlobalErrorBubbleController : BaseBubbleController { @private - base::WeakPtr<GlobalError> error_; + base::WeakPtr<GlobalErrorWithStandardBubble> error_; scoped_ptr<GlobalErrorBubbleControllerInternal::Bridge> bridge_; Browser* browser_; diff --git a/chrome/browser/ui/cocoa/global_error_bubble_controller.mm b/chrome/browser/ui/cocoa/global_error_bubble_controller.mm index 4ccb41a..d053972 100644 --- a/chrome/browser/ui/cocoa/global_error_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/global_error_bubble_controller.mm @@ -55,7 +55,7 @@ class Bridge : public GlobalErrorBubbleViewBase { @implementation GlobalErrorBubbleController + (GlobalErrorBubbleViewBase*)showForBrowser:(Browser*)browser - error:(const base::WeakPtr<GlobalError>&)error { + error:(const base::WeakPtr<GlobalErrorWithStandardBubble>&)error { NSWindow* parentWindow = browser->window()->GetNativeWindow(); BrowserWindowController* bwc = [BrowserWindowController browserWindowControllerForWindow:parentWindow]; @@ -161,8 +161,8 @@ class Bridge : public GlobalErrorBubbleViewBase { @end -GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( +GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( Browser* browser, - const base::WeakPtr<GlobalError>& error) { + const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { return [GlobalErrorBubbleController showForBrowser:browser error:error]; } diff --git a/chrome/browser/ui/global_error/global_error.cc b/chrome/browser/ui/global_error/global_error.cc index d6fdd6d..db05206 100644 --- a/chrome/browser/ui/global_error/global_error.cc +++ b/chrome/browser/ui/global_error/global_error.cc @@ -10,17 +10,13 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -GlobalError::GlobalError() - : has_shown_bubble_view_(false), - bubble_view_(NULL) { -} +// GlobalError --------------------------------------------------------------- -GlobalError::~GlobalError() { -} +GlobalError::GlobalError() {} -GlobalError::Severity GlobalError::GetSeverity() { - return SEVERITY_MEDIUM; -} +GlobalError::~GlobalError() {} + +GlobalError::Severity GlobalError::GetSeverity() { return SEVERITY_MEDIUM; } int GlobalError::MenuItemIconResourceID() { // If you change this make sure to also change the bubble icon and the wrench @@ -28,33 +24,42 @@ int GlobalError::MenuItemIconResourceID() { return IDR_INPUT_ALERT_MENU; } -bool GlobalError::HasShownBubbleView() { +// GlobalErrorWithStandardBubble --------------------------------------------- + +GlobalErrorWithStandardBubble::GlobalErrorWithStandardBubble() + : has_shown_bubble_view_(false), bubble_view_(NULL) {} + +GlobalErrorWithStandardBubble::~GlobalErrorWithStandardBubble() {} + +bool GlobalErrorWithStandardBubble::HasBubbleView() { return true; } + +bool GlobalErrorWithStandardBubble::HasShownBubbleView() { return has_shown_bubble_view_; } -void GlobalError::ShowBubbleView(Browser* browser) { +void GlobalErrorWithStandardBubble::ShowBubbleView(Browser* browser) { has_shown_bubble_view_ = true; #if defined(OS_ANDROID) // http://crbug.com/136506 NOTIMPLEMENTED() << "Chrome for Android doesn't support global errors"; #else bubble_view_ = - GlobalErrorBubbleViewBase::ShowBubbleView(browser, AsWeakPtr()); + GlobalErrorBubbleViewBase::ShowStandardBubbleView(browser, AsWeakPtr()); #endif } -GlobalErrorBubbleViewBase* GlobalError::GetBubbleView() { +GlobalErrorBubbleViewBase* GlobalErrorWithStandardBubble::GetBubbleView() { return bubble_view_; } -gfx::Image GlobalError::GetBubbleViewIcon() { +gfx::Image GlobalErrorWithStandardBubble::GetBubbleViewIcon() { // If you change this make sure to also change the menu icon and the wrench // icon color. return ResourceBundle::GetSharedInstance().GetNativeImageNamed( IDR_INPUT_ALERT); } -void GlobalError::BubbleViewDidClose(Browser* browser) { +void GlobalErrorWithStandardBubble::BubbleViewDidClose(Browser* browser) { DCHECK(browser); bubble_view_ = NULL; OnBubbleViewDidClose(browser); diff --git a/chrome/browser/ui/global_error/global_error.h b/chrome/browser/ui/global_error/global_error.h index 199e1a1..cacd1ff 100644 --- a/chrome/browser/ui/global_error/global_error.h +++ b/chrome/browser/ui/global_error/global_error.h @@ -19,7 +19,7 @@ class Image; } // This object describes a single global error. -class GlobalError : public base::SupportsWeakPtr<GlobalError> { +class GlobalError { public: enum Severity { SEVERITY_LOW, @@ -49,11 +49,23 @@ class GlobalError : public base::SupportsWeakPtr<GlobalError> { // Returns true if a bubble view should be shown. virtual bool HasBubbleView() = 0; // Returns true if the bubble view has been shown. - virtual bool HasShownBubbleView(); + virtual bool HasShownBubbleView() = 0; // Called to show the bubble view. - void ShowBubbleView(Browser* browser); + virtual void ShowBubbleView(Browser* browser) = 0; // Returns the bubble view. - virtual GlobalErrorBubbleViewBase* GetBubbleView(); + virtual GlobalErrorBubbleViewBase* GetBubbleView() = 0; +}; + +// This object describes a single global error that already comes with support +// for showing a standard Bubble UI. Derived classes just need to supply the +// content to be displayed in the bubble. +class GlobalErrorWithStandardBubble + : public GlobalError, + public base::SupportsWeakPtr<GlobalErrorWithStandardBubble> { + public: + GlobalErrorWithStandardBubble(); + virtual ~GlobalErrorWithStandardBubble(); + // Returns an icon to use for the bubble view. virtual gfx::Image GetBubbleViewIcon(); // Returns the title for the bubble view. @@ -80,12 +92,17 @@ class GlobalError : public base::SupportsWeakPtr<GlobalError> { // Browser that the bubble view was shown on. virtual void BubbleViewCancelButtonPressed(Browser* browser) = 0; + // GlobalError overrides: + virtual bool HasBubbleView() OVERRIDE; + virtual bool HasShownBubbleView() OVERRIDE; + virtual void ShowBubbleView(Browser* browser) OVERRIDE; + virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; private: bool has_shown_bubble_view_; GlobalErrorBubbleViewBase* bubble_view_; - DISALLOW_COPY_AND_ASSIGN(GlobalError); + DISALLOW_COPY_AND_ASSIGN(GlobalErrorWithStandardBubble); }; #endif // CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_ diff --git a/chrome/browser/ui/global_error/global_error_bubble_view_base.h b/chrome/browser/ui/global_error/global_error_bubble_view_base.h index 0b0132c..224364d 100644 --- a/chrome/browser/ui/global_error/global_error_bubble_view_base.h +++ b/chrome/browser/ui/global_error/global_error_bubble_view_base.h @@ -9,13 +9,13 @@ #include "base/memory/weak_ptr.h" class Browser; -class GlobalError; +class GlobalErrorWithStandardBubble; class GlobalErrorBubbleViewBase { public: - static GlobalErrorBubbleViewBase* ShowBubbleView( + static GlobalErrorBubbleViewBase* ShowStandardBubbleView( Browser* browser, - const base::WeakPtr<GlobalError>& error); + const base::WeakPtr<GlobalErrorWithStandardBubble>& error); virtual ~GlobalErrorBubbleViewBase() {} diff --git a/chrome/browser/ui/global_error/global_error_service_browsertest.cc b/chrome/browser/ui/global_error/global_error_service_browsertest.cc index 49d2230..2da6440 100644 --- a/chrome/browser/ui/global_error/global_error_service_browsertest.cc +++ b/chrome/browser/ui/global_error/global_error_service_browsertest.cc @@ -15,7 +15,7 @@ namespace { // An error that has a bubble view. -class BubbleViewError : public GlobalError { +class BubbleViewError : public GlobalErrorWithStandardBubble { public: BubbleViewError() : bubble_view_close_count_(0) { } diff --git a/chrome/browser/ui/global_error/global_error_service_unittest.cc b/chrome/browser/ui/global_error/global_error_service_unittest.cc index 35ab8c8..9010229 100644 --- a/chrome/browser/ui/global_error/global_error_service_unittest.cc +++ b/chrome/browser/ui/global_error/global_error_service_unittest.cc @@ -31,31 +31,9 @@ class BaseError : public GlobalError { virtual void ExecuteMenuItem(Browser* browser) OVERRIDE { ADD_FAILURE(); } virtual bool HasBubbleView() OVERRIDE { return false; } - virtual string16 GetBubbleViewTitle() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE { - ADD_FAILURE(); - return std::vector<string16>(); - } - virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } - virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } - virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } + virtual bool HasShownBubbleView() OVERRIDE { return false; } + virtual void ShowBubbleView(Browser* browser) OVERRIDE { ADD_FAILURE(); } + virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE { return NULL; } private: // This tracks the number BaseError objects that are currently instantiated. diff --git a/chrome/browser/ui/gtk/global_error_bubble.cc b/chrome/browser/ui/gtk/global_error_bubble.cc index 562e9b3..224b69d 100644 --- a/chrome/browser/ui/gtk/global_error_bubble.cc +++ b/chrome/browser/ui/gtk/global_error_bubble.cc @@ -30,9 +30,10 @@ const int kMinMessageLabelWidth = 250; } // namespace -GlobalErrorBubble::GlobalErrorBubble(Browser* browser, - const base::WeakPtr<GlobalError>& error, - GtkWidget* anchor) +GlobalErrorBubble::GlobalErrorBubble( + Browser* browser, + const base::WeakPtr<GlobalErrorWithStandardBubble>& error, + GtkWidget* anchor) : browser_(browser), bubble_(NULL), error_(error), @@ -153,9 +154,9 @@ void GlobalErrorBubble::CloseBubbleView() { bubble_->Close(); } -GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( +GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( Browser* browser, - const base::WeakPtr<GlobalError>& error) { + const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { BrowserWindowGtk* browser_window = BrowserWindowGtk::GetBrowserWindowForNativeWindow( browser->window()->GetNativeWindow()); diff --git a/chrome/browser/ui/gtk/global_error_bubble.h b/chrome/browser/ui/gtk/global_error_bubble.h index 1802ff0..3cb5b0b 100644 --- a/chrome/browser/ui/gtk/global_error_bubble.h +++ b/chrome/browser/ui/gtk/global_error_bubble.h @@ -16,14 +16,14 @@ typedef struct _GtkWidget GtkWidget; -class GlobalError; +class GlobalErrorWithStandardBubble; class Profile; class GlobalErrorBubble : public BubbleDelegateGtk, public GlobalErrorBubbleViewBase { public: GlobalErrorBubble(Browser* browser, - const base::WeakPtr<GlobalError>& error, + const base::WeakPtr<GlobalErrorWithStandardBubble>& error, GtkWidget* anchor); virtual ~GlobalErrorBubble(); @@ -40,7 +40,7 @@ class GlobalErrorBubble : public BubbleDelegateGtk, Browser* browser_; BubbleGtk* bubble_; - base::WeakPtr<GlobalError> error_; + base::WeakPtr<GlobalErrorWithStandardBubble> error_; std::vector<GtkWidget*> message_labels_; int message_width_; diff --git a/chrome/browser/ui/profile_reset_bubble.h b/chrome/browser/ui/profile_reset_bubble.h new file mode 100644 index 0000000..ad0bb2e --- /dev/null +++ b/chrome/browser/ui/profile_reset_bubble.h @@ -0,0 +1,23 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_PROFILE_RESET_BUBBLE_H_ +#define CHROME_BROWSER_UI_PROFILE_RESET_BUBBLE_H_ + +#include "base/memory/weak_ptr.h" + +class Browser; +class GlobalErrorBubbleViewBase; +class ProfileResetGlobalError; + +// Returns whether or not the profile reset bubble is supported on this +// platform. +bool IsProfileResetBubbleSupported(); + +// Shows the profile reset bubble on the platforms that support it. +GlobalErrorBubbleViewBase* ShowProfileResetBubble( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + Browser* browser); + +#endif // CHROME_BROWSER_UI_PROFILE_RESET_BUBBLE_H_ diff --git a/chrome/browser/ui/profile_reset_bubble_stub.cc b/chrome/browser/ui/profile_reset_bubble_stub.cc new file mode 100644 index 0000000..d009660 --- /dev/null +++ b/chrome/browser/ui/profile_reset_bubble_stub.cc @@ -0,0 +1,21 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Definitions for chrome/browser/ui/profile_reset_bubble.h, for platforms where +// the profile reset bubble is not implemented yet. + +#include "chrome/browser/ui/profile_reset_bubble.h" + +#include "base/logging.h" + +bool IsProfileResetBubbleSupported() { + return false; +} + +GlobalErrorBubbleViewBase* ShowProfileResetBubble( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + Browser* browser) { + NOTREACHED(); + return NULL; +} diff --git a/chrome/browser/ui/show_profile_reset_bubble.h b/chrome/browser/ui/show_profile_reset_bubble.h deleted file mode 100644 index de69662..0000000 --- a/chrome/browser/ui/show_profile_reset_bubble.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_SHOW_PROFILE_RESET_BUBBLE_H_ -#define CHROME_BROWSER_UI_SHOW_PROFILE_RESET_BUBBLE_H_ - -#include "chrome/browser/profile_resetter/profile_reset_callback.h" - -class Browser; - -// Shows the prefs reset bubble on the platforms that support it. The callback -// is run when the user chooses to reset preferences. -void ShowProfileResetBubble(Browser* browser, - const ProfileResetCallback& reset_callback); - -#endif // CHROME_BROWSER_UI_SHOW_PROFILE_RESET_BUBBLE_H_ diff --git a/chrome/browser/ui/show_profile_reset_bubble_stub.cc b/chrome/browser/ui/show_profile_reset_bubble_stub.cc deleted file mode 100644 index f98667c..0000000 --- a/chrome/browser/ui/show_profile_reset_bubble_stub.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/show_profile_reset_bubble.h" - -#include "base/logging.h" - -// This is for the code in ProfileResetGlobalError to compile on platforms where -// the profile reset bubble is not implemented yet. -void ShowProfileResetBubble( - Browser* browser, - const ProfileResetCallback& reset_callback) { - NOTREACHED(); -} diff --git a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc index e0ff981..3860ea8 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc @@ -39,31 +39,9 @@ class MenuError : public GlobalError { virtual void ExecuteMenuItem(Browser* browser) OVERRIDE { execute_count_++; } virtual bool HasBubbleView() OVERRIDE { return false; } - virtual string16 GetBubbleViewTitle() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE { - ADD_FAILURE(); - return std::vector<string16>(); - } - virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE { - ADD_FAILURE(); - return string16(); - } - virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } - virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } - virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE { - ADD_FAILURE(); - } + virtual bool HasShownBubbleView() OVERRIDE { return false; } + virtual void ShowBubbleView(Browser* browser) OVERRIDE { ADD_FAILURE(); } + virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE { return NULL; } private: int command_id_; diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc index a024408..74bda99 100644 --- a/chrome/browser/ui/views/global_error_bubble_view.cc +++ b/chrome/browser/ui/views/global_error_bubble_view.cc @@ -40,9 +40,9 @@ const int kBubblePadding = 6; // GlobalErrorBubbleViewBase --------------------------------------------------- // static -GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowBubbleView( +GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( Browser* browser, - const base::WeakPtr<GlobalError>& error) { + const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); views::View* wrench_button = browser_view->toolbar()->app_menu(); GlobalErrorBubbleView* bubble_view = @@ -61,7 +61,7 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( views::View* anchor_view, views::BubbleBorder::Arrow arrow, Browser* browser, - const base::WeakPtr<GlobalError>& error) + const base::WeakPtr<GlobalErrorWithStandardBubble>& error) : BubbleDelegateView(anchor_view, arrow), browser_(browser), error_(error) { diff --git a/chrome/browser/ui/views/global_error_bubble_view.h b/chrome/browser/ui/views/global_error_bubble_view.h index bfcedaa..c527151 100644 --- a/chrome/browser/ui/views/global_error_bubble_view.h +++ b/chrome/browser/ui/views/global_error_bubble_view.h @@ -11,16 +11,17 @@ #include "ui/views/controls/button/button.h" class Browser; -class GlobalError; +class GlobalErrorWithStandardBubble; class GlobalErrorBubbleView : public views::ButtonListener, public views::BubbleDelegateView, public GlobalErrorBubbleViewBase { public: - GlobalErrorBubbleView(views::View* anchor_view, - views::BubbleBorder::Arrow arrow, - Browser* browser, - const base::WeakPtr<GlobalError>& error); + GlobalErrorBubbleView( + views::View* anchor_view, + views::BubbleBorder::Arrow arrow, + Browser* browser, + const base::WeakPtr<GlobalErrorWithStandardBubble>& error); virtual ~GlobalErrorBubbleView(); // views::ButtonListener implementation. @@ -35,7 +36,7 @@ class GlobalErrorBubbleView : public views::ButtonListener, private: Browser* browser_; - base::WeakPtr<GlobalError> error_; + base::WeakPtr<GlobalErrorWithStandardBubble> error_; DISALLOW_COPY_AND_ASSIGN(GlobalErrorBubbleView); }; diff --git a/chrome/browser/ui/views/profile_reset_bubble_view.cc b/chrome/browser/ui/views/profile_reset_bubble_view.cc index 4484dfd..da150e8 100644 --- a/chrome/browser/ui/views/profile_reset_bubble_view.cc +++ b/chrome/browser/ui/views/profile_reset_bubble_view.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/views/profile_reset_bubble_view.h" #include "base/memory/scoped_ptr.h" -#include "base/metrics/histogram.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/google/google_util.h" @@ -13,6 +12,7 @@ #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h" #include "chrome/browser/ui/global_error/global_error_service.h" #include "chrome/browser/ui/global_error/global_error_service_factory.h" +#include "chrome/browser/ui/profile_reset_bubble.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/toolbar_view.h" #include "chrome/common/url_constants.h" @@ -72,13 +72,6 @@ const int kInterFeedbackValuePadding = 4; // height. const int kButtonPadding = views::kRelatedButtonHSpacing - 2; -// The maximum number of ignored bubbles we track in the NumNoThanksPerReset -// histogram. -const int kMaxIgnored = 50; - -// The number of buckets we want the NumNoThanksPerReset histogram to use. -const int kNumIgnoredBuckets = 5; - // The color of the background of the sub panel to report current settings. const SkColor kLightGrayBackgroundColor = 0xFFF5F5F5; @@ -154,50 +147,39 @@ class FeedbackView : public views::View { // ProfileResetBubbleView --------------------------------------------------- // static -ProfileResetBubbleView* ProfileResetBubbleView::reset_bubble_ = NULL; -int ProfileResetBubbleView::num_ignored_bubbles_ = 0; - -// static -void ProfileResetBubbleView::ShowBubble( - views::View* anchor_view, - content::PageNavigator* navigator, - Profile* profile, - const ProfileResetCallback& reset_callback) { - if (IsShowing()) - return; - reset_bubble_ = new ProfileResetBubbleView( - anchor_view, navigator, profile, reset_callback); - views::BubbleDelegateView::CreateBubble(reset_bubble_); - reset_bubble_->StartFade(true); +ProfileResetBubbleView* ProfileResetBubbleView::ShowBubble( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + Browser* browser) { + views::View* anchor_view = + BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(); + ProfileResetBubbleView* reset_bubble = new ProfileResetBubbleView( + global_error, anchor_view, browser, browser->profile()); + views::BubbleDelegateView::CreateBubble(reset_bubble); + reset_bubble->StartFade(true); content::RecordAction(content::UserMetricsAction("SettingsResetBubble.Show")); + return reset_bubble; } -ProfileResetBubbleView::~ProfileResetBubbleView() { - if (!chose_to_reset_ && num_ignored_bubbles_ < kMaxIgnored) - ++num_ignored_bubbles_; -} +ProfileResetBubbleView::~ProfileResetBubbleView() {} views::View* ProfileResetBubbleView::GetInitiallyFocusedView() { return controls_.reset_button; } void ProfileResetBubbleView::WindowClosing() { - // Reset |reset_bubble_| here, not in destructor, because destruction is - // asynchronous and ShowBubble may be called before full destruction and - // would attempt to show a bubble that is closing. - DCHECK_EQ(reset_bubble_, this); - reset_bubble_ = NULL; + if (global_error_) + global_error_->OnBubbleViewDidClose(); } ProfileResetBubbleView::ProfileResetBubbleView( + const base::WeakPtr<ProfileResetGlobalError>& global_error, views::View* anchor_view, content::PageNavigator* navigator, - Profile* profile, - const ProfileResetCallback& reset_callback) + Profile* profile) : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), navigator_(navigator), profile_(profile), - reset_callback_(reset_callback), + global_error_(global_error), resetting_(false), chose_to_reset_(false), show_help_pane_(false), @@ -395,9 +377,6 @@ void ProfileResetBubbleView::ButtonPressed(views::Button* sender, const ui::Event& event) { if (sender == controls_.reset_button) { DCHECK(!resetting_); - UMA_HISTOGRAM_CUSTOM_COUNTS("SettingsResetBubble.NumNoThanksPerReset", - num_ignored_bubbles_, 0, kMaxIgnored, - kNumIgnoredBuckets); content::RecordAction(content::UserMetricsAction( "SettingsResetBubble.Reset")); @@ -410,14 +389,17 @@ void ProfileResetBubbleView::ButtonPressed(views::Button* sender, controls_.no_thanks_button->SetEnabled(false); SchedulePaint(); - reset_callback_.Run( - controls_.report_settings_checkbox->checked(), - base::Bind(&ProfileResetBubbleView::OnResetProfileSettingsDone, - weak_factory_.GetWeakPtr())); + if (global_error_) { + global_error_->OnBubbleViewResetButtonPressed( + controls_.report_settings_checkbox->checked()); + } } else if (sender == controls_.no_thanks_button) { DCHECK(!resetting_); content::RecordAction(content::UserMetricsAction( "SettingsResetBubble.NoThanks")); + + if (global_error_) + global_error_->OnBubbleViewNoThanksButtonPressed(); StartFade(false); return; } else if (sender == controls_.help_button) { @@ -436,14 +418,17 @@ void ProfileResetBubbleView::LinkClicked(views::Link* source, int flags) { NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); } -void ProfileResetBubbleView::OnResetProfileSettingsDone() { +void ProfileResetBubbleView::CloseBubbleView() { resetting_ = false; StartFade(false); } -void ShowProfileResetBubble(Browser* browser, - const ProfileResetCallback& reset_callback) { - ProfileResetBubbleView::ShowBubble( - BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(), - browser, browser->profile(), reset_callback); +bool IsProfileResetBubbleSupported() { + return true; +} + +GlobalErrorBubbleViewBase* ShowProfileResetBubble( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + Browser* browser) { + return ProfileResetBubbleView::ShowBubble(global_error, browser); } diff --git a/chrome/browser/ui/views/profile_reset_bubble_view.h b/chrome/browser/ui/views/profile_reset_bubble_view.h index 61878a8..8924112 100644 --- a/chrome/browser/ui/views/profile_reset_bubble_view.h +++ b/chrome/browser/ui/views/profile_reset_bubble_view.h @@ -8,7 +8,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/profile_resetter/profile_reset_callback.h" +#include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" #include "ui/gfx/image/image_skia.h" #include "ui/views/bubble/bubble_delegate.h" #include "ui/views/controls/button/button.h" @@ -25,19 +25,21 @@ class LabelButton; class Link; } +class Browser; class Profile; +class ProfileResetGlobalError; // ProfileResetBubbleView warns the user that a settings reset might be needed. // It is intended to be used as the content of a bubble anchored off of the // Chrome toolbar. class ProfileResetBubbleView : public views::BubbleDelegateView, - public views::ButtonListener, - public views::LinkListener { + public views::ButtonListener, + public views::LinkListener, + public GlobalErrorBubbleViewBase { public: - static void ShowBubble(views::View* anchor_view, - content::PageNavigator* navigator, - Profile* profile, - const ProfileResetCallback& reset_callback); + static ProfileResetBubbleView* ShowBubble( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + Browser* browser); // views::BubbleDelegateView methods. virtual views::View* GetInitiallyFocusedView() OVERRIDE; @@ -46,16 +48,18 @@ class ProfileResetBubbleView : public views::BubbleDelegateView, // views::WidgetDelegate method. virtual void WindowClosing() OVERRIDE; + // GlobalErrorBubbleViewBase: + virtual void CloseBubbleView() OVERRIDE; + private: - ProfileResetBubbleView(views::View* anchor_view, - content::PageNavigator* navigator, - Profile* profile, - const ProfileResetCallback& reset_callback); + ProfileResetBubbleView( + const base::WeakPtr<ProfileResetGlobalError>& global_error, + views::View* anchor_view, + content::PageNavigator* navigator, + Profile* profile); virtual ~ProfileResetBubbleView(); - static bool IsShowing() { return reset_bubble_ != NULL; } - // Reset all child views members and remove children from view hierarchy. void ResetAllChildren(); @@ -70,16 +74,6 @@ class ProfileResetBubbleView : public views::BubbleDelegateView, // views::LinkListener method. virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; - // Callback from the profile resetter, once it's done. - void OnResetProfileSettingsDone(); - - // The reset bubble, if we're showing one. - static ProfileResetBubbleView* reset_bubble_; - - // The numer of times the user ignored the bubble before finally choosing to - // reset. - static int num_ignored_bubbles_; - struct Controls { Controls() { Reset(); @@ -114,8 +108,8 @@ class ProfileResetBubbleView : public views::BubbleDelegateView, // feedback. Profile* profile_; - // Callback to the code that takes care of the profile reset. - ProfileResetCallback reset_callback_; + // The GlobalError this Bubble belongs to. + base::WeakPtr<ProfileResetGlobalError> global_error_; // Remembers if we are currently resetting or not. bool resetting_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5b166d40..69a3dae 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1734,7 +1734,6 @@ 'browser/profile_resetter/brandcoded_default_settings.cc', 'browser/profile_resetter/brandcode_config_fetcher.h', 'browser/profile_resetter/brandcode_config_fetcher.cc', - 'browser/profile_resetter/profile_reset_callback.h', 'browser/profile_resetter/profile_reset_global_error.h', 'browser/profile_resetter/profile_reset_global_error.cc', 'browser/profile_resetter/profile_resetter.h', diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 57a475d..db4ee28 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1488,8 +1488,8 @@ 'browser/ui/search_engines/template_url_fetcher_ui_callbacks.h', 'browser/ui/search_engines/template_url_table_model.cc', 'browser/ui/search_engines/template_url_table_model.h', - 'browser/ui/show_profile_reset_bubble.h', - 'browser/ui/show_profile_reset_bubble_stub.cc', + 'browser/ui/profile_reset_bubble.h', + 'browser/ui/profile_reset_bubble_stub.cc', 'browser/ui/simple_message_box.h', 'browser/ui/singleton_tabs.cc', 'browser/ui/singleton_tabs.h', @@ -2680,7 +2680,7 @@ }], ['toolkit_views == 1', { 'sources!': [ - 'browser/ui/show_profile_reset_bubble_stub.cc', + 'browser/ui/profile_reset_bubble_stub.cc', ], }], ['OS=="linux"', { |