Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: chrome/browser/ui/views/external_protocol_dialog.cc

Issue 2076253002: Simplify the text in the external protocol confirmation dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS compile Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/external_protocol_dialog.h" 5 #include "chrome/browser/ui/views/external_protocol_dialog.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/external_protocol/external_protocol_handler.h" 11 #include "chrome/browser/external_protocol/external_protocol_handler.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 12 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/external_protocol_dialog_delegate.h" 13 #include "chrome/browser/ui/external_protocol_dialog_delegate.h"
15 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
16 #include "components/constrained_window/constrained_window_views.h" 15 #include "components/constrained_window/constrained_window_views.h"
17 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
18 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/text_elider.h" 18 #include "ui/gfx/text_elider.h"
20 #include "ui/views/controls/message_box_view.h" 19 #include "ui/views/controls/message_box_view.h"
21 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 55
57 ////////////////////////////////////////////////////////////////////////////// 56 //////////////////////////////////////////////////////////////////////////////
58 // ExternalProtocolDialog, views::DialogDelegate implementation: 57 // ExternalProtocolDialog, views::DialogDelegate implementation:
59 58
60 int ExternalProtocolDialog::GetDefaultDialogButton() const { 59 int ExternalProtocolDialog::GetDefaultDialogButton() const {
61 return ui::DIALOG_BUTTON_CANCEL; 60 return ui::DIALOG_BUTTON_CANCEL;
62 } 61 }
63 62
64 base::string16 ExternalProtocolDialog::GetDialogButtonLabel( 63 base::string16 ExternalProtocolDialog::GetDialogButtonLabel(
65 ui::DialogButton button) const { 64 ui::DialogButton button) const {
66 if (button == ui::DIALOG_BUTTON_OK) 65 return delegate_->GetDialogButtonLabel(button);
67 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT);
68 else
69 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT);
70 } 66 }
71 67
72 base::string16 ExternalProtocolDialog::GetWindowTitle() const { 68 base::string16 ExternalProtocolDialog::GetWindowTitle() const {
73 return delegate_->GetTitleText(); 69 return delegate_->GetTitleText();
74 } 70 }
75 71
76 void ExternalProtocolDialog::DeleteDelegate() { 72 void ExternalProtocolDialog::DeleteDelegate() {
77 delete this; 73 delete this;
78 } 74 }
79 75
80 bool ExternalProtocolDialog::Cancel() { 76 bool ExternalProtocolDialog::Cancel() {
81 // We also get called back here if the user closes the dialog or presses 77 // We also get called back here if the user closes the dialog or presses
82 // escape. In these cases it would be preferable to ignore the state of the 78 // escape. In these cases it would be preferable to ignore the state of the
83 // check box but MessageBox doesn't distinguish this from pressing the cancel 79 // check box but MessageBox doesn't distinguish this from pressing the cancel
84 // button. 80 // button.
85 delegate_->DoCancel(delegate_->url(), 81 delegate_->DoCancel(delegate_->url(),
86 message_box_view_->IsCheckBoxSelected()); 82 message_box_view_->IsCheckBoxSelected());
87 83
84 ExternalProtocolHandler::RecordMetrics(
85 message_box_view_->IsCheckBoxSelected());
86
88 // Returning true closes the dialog. 87 // Returning true closes the dialog.
89 return true; 88 return true;
90 } 89 }
91 90
92 bool ExternalProtocolDialog::Accept() { 91 bool ExternalProtocolDialog::Accept() {
93 // We record how long it takes the user to accept an external protocol. If 92 // We record how long it takes the user to accept an external protocol. If
94 // users start accepting these dialogs too quickly, we should worry about 93 // users start accepting these dialogs too quickly, we should worry about
95 // clickjacking. 94 // clickjacking.
96 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", 95 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url",
97 base::TimeTicks::Now() - creation_time_); 96 base::TimeTicks::Now() - creation_time_);
98 97
98 ExternalProtocolHandler::RecordMetrics(
99 message_box_view_->IsCheckBoxSelected());
100
99 delegate_->DoAccept(delegate_->url(), 101 delegate_->DoAccept(delegate_->url(),
100 message_box_view_->IsCheckBoxSelected()); 102 message_box_view_->IsCheckBoxSelected());
101 103
102 // Returning true closes the dialog. 104 // Returning true closes the dialog.
103 return true; 105 return true;
104 } 106 }
105 107
106 views::View* ExternalProtocolDialog::GetContentsView() { 108 views::View* ExternalProtocolDialog::GetContentsView() {
107 return message_box_view_; 109 return message_box_view_;
108 } 110 }
(...skipping 26 matching lines...) Expand all
135 message_box_view_ = new views::MessageBoxView(params); 137 message_box_view_ = new views::MessageBoxView(params);
136 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); 138 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText());
137 139
138 WebContents* web_contents = tab_util::GetWebContentsByID( 140 WebContents* web_contents = tab_util::GetWebContentsByID(
139 render_process_host_id_, routing_id_); 141 render_process_host_id_, routing_id_);
140 // Only launch the dialog if there is a web contents associated with the 142 // Only launch the dialog if there is a web contents associated with the
141 // request. 143 // request.
142 if (web_contents) 144 if (web_contents)
143 constrained_window::ShowWebModalDialogViews(this, web_contents); 145 constrained_window::ShowWebModalDialogViews(this, web_contents);
144 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698