summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/cocoa/global_error_bubble_controller.h4
-rw-r--r--chrome/browser/ui/cocoa/global_error_bubble_controller.mm6
-rw-r--r--chrome/browser/ui/global_error/global_error.cc35
-rw-r--r--chrome/browser/ui/global_error/global_error.h27
-rw-r--r--chrome/browser/ui/global_error/global_error_bubble_view_base.h6
-rw-r--r--chrome/browser/ui/global_error/global_error_service_browsertest.cc2
-rw-r--r--chrome/browser/ui/global_error/global_error_service_unittest.cc28
-rw-r--r--chrome/browser/ui/gtk/global_error_bubble.cc11
-rw-r--r--chrome/browser/ui/gtk/global_error_bubble.h6
-rw-r--r--chrome/browser/ui/profile_reset_bubble.h23
-rw-r--r--chrome/browser/ui/profile_reset_bubble_stub.cc21
-rw-r--r--chrome/browser/ui/show_profile_reset_bubble.h17
-rw-r--r--chrome/browser/ui/show_profile_reset_bubble_stub.cc15
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc28
-rw-r--r--chrome/browser/ui/views/global_error_bubble_view.cc6
-rw-r--r--chrome/browser/ui/views/global_error_bubble_view.h13
-rw-r--r--chrome/browser/ui/views/profile_reset_bubble_view.cc81
-rw-r--r--chrome/browser/ui/views/profile_reset_bubble_view.h44
18 files changed, 172 insertions, 201 deletions
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_;