base::Time multiplicative operator overloading
[chromium-blink-merge.git] / chrome / browser / safe_browsing / srt_global_error_win.cc
blob80757eea17d0df34573091fe5092d7391d8d71f4
1 // Copyright 2014 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/safe_browsing/srt_global_error_win.h"
7 #include "base/callback.h"
8 #include "base/metrics/histogram.h"
9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/global_error/global_error_service.h"
12 #include "grit/chromium_strings.h"
13 #include "grit/generated_resources.h"
14 #include "grit/google_chrome_strings.h"
15 #include "ui/base/l10n/l10n_util.h"
17 namespace {
18 // The download link of the Software Removal Tool.
19 // TODO(mad): Should we only have the bubble show up on official Chrome build?
20 const char kSRTDownloadURL[] = "https://www.google.com/chrome/srt/";
22 // Enum values for the SRTPrompt histogram. Don't change order, always add
23 // to the end, before SRT_PROMPT_MAX, of course.
24 enum SRTPromptHistogramValue {
25 SRT_PROMPT_SHOWN = 0,
26 SRT_PROMPT_ACCEPTED = 1,
27 SRT_PROMPT_DENIED = 2,
29 SRT_PROMPT_MAX,
32 void RecordSRTPromptHistogram(SRTPromptHistogramValue value) {
33 UMA_HISTOGRAM_ENUMERATION(
34 "SoftwareReporter.PromptUsage", value, SRT_PROMPT_MAX);
37 } // namespace
39 // SRTGlobalError ------------------------------------------------------------
41 SRTGlobalError::SRTGlobalError(GlobalErrorService* global_error_service)
42 : global_error_service_(global_error_service) {
43 DCHECK(global_error_service_);
46 SRTGlobalError::~SRTGlobalError() {
49 bool SRTGlobalError::HasMenuItem() {
50 return true;
53 int SRTGlobalError::MenuItemCommandID() {
54 return IDC_SHOW_SRT_BUBBLE;
57 base::string16 SRTGlobalError::MenuItemLabel() {
58 return l10n_util::GetStringUTF16(IDS_SRT_MENU_ITEM);
61 void SRTGlobalError::ExecuteMenuItem(Browser* browser) {
62 // The menu item should never get executed while the bubble is shown, unless
63 // we eventually change it to NOT close on deactivate.
64 DCHECK(ShouldCloseOnDeactivate());
65 DCHECK(GetBubbleView() == NULL);
66 ShowBubbleView(browser);
69 void SRTGlobalError::ShowBubbleView(Browser* browser) {
70 RecordSRTPromptHistogram(SRT_PROMPT_SHOWN);
71 GlobalErrorWithStandardBubble::ShowBubbleView(browser);
74 base::string16 SRTGlobalError::GetBubbleViewTitle() {
75 return l10n_util::GetStringUTF16(IDS_SRT_BUBBLE_TITLE);
78 std::vector<base::string16> SRTGlobalError::GetBubbleViewMessages() {
79 std::vector<base::string16> messages;
80 messages.push_back(l10n_util::GetStringUTF16(IDS_SRT_BUBBLE_TEXT));
81 return messages;
84 base::string16 SRTGlobalError::GetBubbleViewAcceptButtonLabel() {
85 return l10n_util::GetStringUTF16(IDS_SRT_BUBBLE_DOWNLOAD_BUTTON_TEXT);
88 base::string16 SRTGlobalError::GetBubbleViewCancelButtonLabel() {
89 return l10n_util::GetStringUTF16(IDS_NO_THANKS);
92 void SRTGlobalError::OnBubbleViewDidClose(Browser* browser) {
95 void SRTGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) {
96 RecordSRTPromptHistogram(SRT_PROMPT_ACCEPTED);
97 browser->OpenURL(content::OpenURLParams(GURL(kSRTDownloadURL),
98 content::Referrer(),
99 NEW_FOREGROUND_TAB,
100 ui::PAGE_TRANSITION_LINK,
101 false));
102 DismissGlobalError();
105 void SRTGlobalError::BubbleViewCancelButtonPressed(Browser* browser) {
106 RecordSRTPromptHistogram(SRT_PROMPT_DENIED);
107 DismissGlobalError();
110 bool SRTGlobalError::ShouldCloseOnDeactivate() const {
111 return false;
114 void SRTGlobalError::DismissGlobalError() {
115 global_error_service_->RemoveGlobalError(this);
116 delete this;