diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 05:59:23 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 05:59:23 +0000 |
commit | 9b46b6c0059f6968bee08c87020548a7e0a7d720 (patch) | |
tree | 01a3cc1e43fe9c42c4df25a18ebf68fd940222e8 /chrome/browser/profile_resetter | |
parent | 02f97168c182dc3297f76995cc0460b3cc8ab9e1 (diff) | |
download | chromium_src-9b46b6c0059f6968bee08c87020548a7e0a7d720.zip chromium_src-9b46b6c0059f6968bee08c87020548a7e0a7d720.tar.gz chromium_src-9b46b6c0059f6968bee08c87020548a7e0a7d720.tar.bz2 |
Add a new Profile Settings Reset Bubble and Global Error to make it available from the Chrome menu.
BUG=264861
Review URL: https://codereview.chromium.org/24301005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile_resetter')
3 files changed, 136 insertions, 0 deletions
diff --git a/chrome/browser/profile_resetter/profile_reset_callback.h b/chrome/browser/profile_resetter/profile_reset_callback.h new file mode 100644 index 0000000..b0aa19a --- /dev/null +++ b/chrome/browser/profile_resetter/profile_reset_callback.h @@ -0,0 +1,17 @@ +// 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 new file mode 100644 index 0000000..e4c1ce4 --- /dev/null +++ b/chrome/browser/profile_resetter/profile_reset_global_error.cc @@ -0,0 +1,73 @@ +// 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/profile_resetter/profile_reset_global_error.h" + +#include "base/logging.h" +#include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/ui/show_profile_reset_bubble.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" + +ProfileResetGlobalError::ProfileResetGlobalError() { +} + +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, + l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); +} + +void ProfileResetGlobalError::ExecuteMenuItem(Browser* browser) { + ShowProfileResetBubble(browser, reset_callback_); +} + +// 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(); +} + +std::vector<string16> ProfileResetGlobalError::GetBubbleViewMessages() { + NOTREACHED(); + return std::vector<string16>(); +} + +string16 ProfileResetGlobalError::GetBubbleViewAcceptButtonLabel() { + NOTREACHED(); + return string16(); +} + +string16 ProfileResetGlobalError::GetBubbleViewCancelButtonLabel() { + NOTREACHED(); + return string16(); +} + +void ProfileResetGlobalError::OnBubbleViewDidClose(Browser* browser) { + NOTREACHED(); +} + +void ProfileResetGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { + NOTREACHED(); +} + +void ProfileResetGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { + NOTREACHED(); +} diff --git a/chrome/browser/profile_resetter/profile_reset_global_error.h b/chrome/browser/profile_resetter/profile_reset_global_error.h new file mode 100644 index 0000000..cf9dfaa --- /dev/null +++ b/chrome/browser/profile_resetter/profile_reset_global_error.h @@ -0,0 +1,46 @@ +// 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_GLOBAL_ERROR_H_ +#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 "chrome/browser/ui/global_error/global_error.h" + +// Shows preferences reset errors on the wrench menu and exposes a menu item to +// launch a bubble view. +class ProfileResetGlobalError : public GlobalError { + public: + ProfileResetGlobalError(); + virtual ~ProfileResetGlobalError(); + + // GlobalError overrides. + 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; + } + + private: + ProfileResetCallback reset_callback_; + + DISALLOW_COPY_AND_ASSIGN(ProfileResetGlobalError); +}; + +#endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ |