1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/profile_resetter/profile_reset_global_error.h"
7 #include "base/metrics/histogram.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/profile_reset_bubble.h"
10 #include "grit/chromium_strings.h"
11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h"
16 // The maximum number of ignored bubbles we track in the NumNoThanksPerReset
18 const int kMaxIgnored = 50;
20 // The number of buckets we want the NumNoThanksPerReset histogram to use.
21 const int kNumIgnoredBuckets = 5;
26 // ProfileResetGlobalError ---------------------------------------------------
28 ProfileResetGlobalError::ProfileResetGlobalError(Profile* profile)
29 : profile_(profile), num_times_bubble_view_shown_(0), bubble_view_(NULL) {}
31 ProfileResetGlobalError::~ProfileResetGlobalError() {}
33 bool ProfileResetGlobalError::HasMenuItem() { return true; }
35 int ProfileResetGlobalError::MenuItemCommandID() {
36 return IDC_SHOW_SETTINGS_RESET_BUBBLE;
39 string16 ProfileResetGlobalError::MenuItemLabel() {
40 return l10n_util::GetStringFUTF16(
41 IDS_RESET_SETTINGS_MENU_ITEM,
42 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
45 void ProfileResetGlobalError::ExecuteMenuItem(Browser* browser) {
46 ShowBubbleView(browser);
49 bool ProfileResetGlobalError::HasBubbleView() { return true; }
51 bool ProfileResetGlobalError::HasShownBubbleView() {
52 return num_times_bubble_view_shown_ > 0;
55 void ProfileResetGlobalError::ShowBubbleView(Browser* browser) {
58 ++num_times_bubble_view_shown_;
59 bubble_view_ = ShowProfileResetBubble(AsWeakPtr(), browser);
62 void ProfileResetGlobalError::OnBubbleViewDidClose() {
66 void ProfileResetGlobalError::OnBubbleViewResetButtonPressed(
68 // TODO(engedy): Integrate with the AutomaticProfileResetter.
69 UMA_HISTOGRAM_CUSTOM_COUNTS("SettingsResetBubble.NumNoThanksPerReset",
70 num_times_bubble_view_shown_ - 1,
76 void ProfileResetGlobalError::OnBubbleViewNoThanksButtonPressed() {
77 // TODO(engedy): Integrate with the AutomaticProfileResetter.
80 GlobalErrorBubbleViewBase* ProfileResetGlobalError::GetBubbleView() {