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

Side by Side Diff: chrome/browser/chromeos/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/chromeos/external_protocol_dialog.h" 5 #include "chrome/browser/chromeos/external_protocol_dialog.h"
6 6
7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/arc/arc_external_protocol_dialog.h" 8 #include "chrome/browser/chromeos/arc/arc_external_protocol_dialog.h"
11 #include "chrome/browser/external_protocol/external_protocol_handler.h" 9 #include "chrome/browser/external_protocol/external_protocol_handler.h"
12 #include "chrome/browser/tab_contents/tab_util.h" 10 #include "chrome/browser/tab_contents/tab_util.h"
13 #include "chrome/grit/chromium_strings.h" 11 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "components/strings/grit/components_strings.h"
15 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
16 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/text_elider.h" 16 #include "ui/gfx/text_elider.h"
18 #include "ui/views/controls/message_box_view.h" 17 #include "ui/views/controls/message_box_view.h"
19 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
20 #include "url/gurl.h" 19 #include "url/gurl.h"
21 20
22 using content::WebContents; 21 using content::WebContents;
23 22
24 namespace { 23 namespace {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 67
69 base::string16 ExternalProtocolDialog::GetWindowTitle() const { 68 base::string16 ExternalProtocolDialog::GetWindowTitle() const {
70 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_TITLE); 69 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_TITLE);
71 } 70 }
72 71
73 void ExternalProtocolDialog::DeleteDelegate() { 72 void ExternalProtocolDialog::DeleteDelegate() {
74 delete this; 73 delete this;
75 } 74 }
76 75
77 bool ExternalProtocolDialog::Accept() { 76 bool ExternalProtocolDialog::Accept() {
78 if (message_box_view_->IsCheckBoxSelected()) { 77 ExternalProtocolHandler::RecordMetrics(
79 ExternalProtocolHandler::SetBlockState( 78 message_box_view_->IsCheckBoxSelected());
80 scheme_, ExternalProtocolHandler::DONT_BLOCK); 79
81 }
82 // Returning true closes the dialog. 80 // Returning true closes the dialog.
83 return true; 81 return true;
84 } 82 }
85 83
86 views::View* ExternalProtocolDialog::GetContentsView() { 84 views::View* ExternalProtocolDialog::GetContentsView() {
87 return message_box_view_; 85 return message_box_view_;
88 } 86 }
89 87
90 const views::Widget* ExternalProtocolDialog::GetWidget() const { 88 const views::Widget* ExternalProtocolDialog::GetWidget() const {
91 return message_box_view_->GetWidget(); 89 return message_box_view_->GetWidget();
92 } 90 }
93 91
94 views::Widget* ExternalProtocolDialog::GetWidget() { 92 views::Widget* ExternalProtocolDialog::GetWidget() {
95 return message_box_view_->GetWidget(); 93 return message_box_view_->GetWidget();
96 } 94 }
97 95
98 /////////////////////////////////////////////////////////////////////////////// 96 ///////////////////////////////////////////////////////////////////////////////
99 // ExternalProtocolDialog, private: 97 // ExternalProtocolDialog, private:
100 98
101 ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents, 99 ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents,
102 const GURL& url) 100 const GURL& url)
103 : creation_time_(base::TimeTicks::Now()), 101 : creation_time_(base::TimeTicks::Now()),
104 scheme_(url.scheme()) { 102 scheme_(url.scheme()) {
105 const size_t kMaxUrlWithoutSchemeSize = 256; 103 views::MessageBoxView::InitParams params((base::string16()));
106 base::string16 elided_url_without_scheme;
107 gfx::ElideString(base::ASCIIToUTF16(url.possibly_invalid_spec()),
108 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
109
110 views::MessageBoxView::InitParams params(
111 l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_INFORMATION,
112 base::ASCIIToUTF16(url.scheme() + ":"),
113 elided_url_without_scheme) + base::ASCIIToUTF16("\n\n"));
114 params.message_width = kMessageWidth; 104 params.message_width = kMessageWidth;
115 message_box_view_ = new views::MessageBoxView(params); 105 message_box_view_ = new views::MessageBoxView(params);
116 message_box_view_->SetCheckBoxLabel(
117 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
118 106
119 gfx::NativeWindow parent_window; 107 gfx::NativeWindow parent_window;
120 if (web_contents) { 108 if (web_contents) {
121 parent_window = web_contents->GetTopLevelNativeWindow(); 109 parent_window = web_contents->GetTopLevelNativeWindow();
122 } else { 110 } else {
123 // Dialog is top level if we don't have a web_contents associated with us. 111 // Dialog is top level if we don't have a web_contents associated with us.
124 parent_window = NULL; 112 parent_window = NULL;
125 } 113 }
126 views::DialogDelegate::CreateDialogWidget(this, NULL, parent_window)->Show(); 114 views::DialogDelegate::CreateDialogWidget(this, NULL, parent_window)->Show();
127 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698