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

Side by Side Diff: chrome/browser/ui/external_protocol_dialog_delegate.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: Update based on UI review Created 4 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/external_protocol_dialog_delegate.h" 5 #include "chrome/browser/ui/external_protocol_dialog_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "chrome/browser/external_protocol/external_protocol_handler.h" 12 #include "chrome/browser/external_protocol/external_protocol_handler.h"
13 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/gfx/text_elider.h" 16 #include "ui/gfx/text_elider.h"
17 17
18 namespace {
19
20 const size_t kMaxCommandSize = 256;
21
22 base::string16 ElideCommandName(const base::string16& command_name) {
23 base::string16 elided_command;
24 gfx::ElideString(command_name, kMaxCommandSize, &elided_command);
25 return elided_command;
26 }
27 } // namespace
28
18 ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate( 29 ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(
19 const GURL& url, 30 const GURL& url,
20 int render_process_host_id, 31 int render_process_host_id,
21 int tab_contents_id) 32 int tab_contents_id)
22 : ProtocolDialogDelegate(url), 33 : ProtocolDialogDelegate(url),
23 render_process_host_id_(render_process_host_id), 34 render_process_host_id_(render_process_host_id),
24 tab_contents_id_(tab_contents_id), 35 tab_contents_id_(tab_contents_id),
25 program_name_(shell_integration::GetApplicationNameForProtocol(url)) {} 36 program_name_(shell_integration::GetApplicationNameForProtocol(url)) {}
26 37
27 ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() { 38 ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() {
28 } 39 }
29 40
41 base::string16 ExternalProtocolDialogDelegate::GetDialogButtonLabel(
42 ui::DialogButton button) const {
43 if (button == ui::DIALOG_BUTTON_OK)
44 return l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT,
45 ElideCommandName(program_name_));
46 else
47 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT);
48 }
49
30 base::string16 ExternalProtocolDialogDelegate::GetMessageText() const { 50 base::string16 ExternalProtocolDialogDelegate::GetMessageText() const {
31 const size_t kMaxUrlWithoutSchemeSize = 256; 51 return base::ASCIIToUTF16("");
32 const size_t kMaxCommandSize = 256;
33 base::string16 elided_url_without_scheme;
34 base::string16 elided_command;
35 gfx::ElideString(base::ASCIIToUTF16(url().possibly_invalid_spec()),
36 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
37 gfx::ElideString(program_name_, kMaxCommandSize, &elided_command);
38
39 base::string16 message_text = l10n_util::GetStringFUTF16(
40 IDS_EXTERNAL_PROTOCOL_INFORMATION,
41 base::ASCIIToUTF16(url().scheme() + ":"),
42 elided_url_without_scheme) + base::ASCIIToUTF16("\n\n");
43
44 message_text += l10n_util::GetStringFUTF16(
45 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH,
46 elided_command) + base::ASCIIToUTF16("\n\n");
47
48 message_text += l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_WARNING);
49 return message_text;
50 } 52 }
51 53
52 base::string16 ExternalProtocolDialogDelegate::GetCheckboxText() const { 54 base::string16 ExternalProtocolDialogDelegate::GetCheckboxText() const {
53 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT); 55 return l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT,
56 ElideCommandName(program_name_));
54 } 57 }
55 58
56 base::string16 ExternalProtocolDialogDelegate::GetTitleText() const { 59 base::string16 ExternalProtocolDialogDelegate::GetTitleText() const {
57 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_TITLE); 60 return l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_TITLE,
61 ElideCommandName(program_name_));
58 } 62 }
59 63
60 void ExternalProtocolDialogDelegate::DoAccept( 64 void ExternalProtocolDialogDelegate::DoAccept(
61 const GURL& url, 65 const GURL& url,
62 bool dont_block) const { 66 bool dont_block) const {
63 if (dont_block) { 67 if (dont_block) {
64 ExternalProtocolHandler::SetBlockState( 68 ExternalProtocolHandler::SetBlockState(
65 url.scheme(), ExternalProtocolHandler::DONT_BLOCK); 69 url.scheme(), ExternalProtocolHandler::DONT_BLOCK);
66 } 70 }
67 71
68 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( 72 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
69 url, render_process_host_id_, tab_contents_id_); 73 url, render_process_host_id_, tab_contents_id_);
70 } 74 }
71 75
72 void ExternalProtocolDialogDelegate::DoCancel( 76 void ExternalProtocolDialogDelegate::DoCancel(
73 const GURL& url, 77 const GURL& url,
74 bool dont_block) const { 78 bool dont_block) const {
75 if (dont_block) { 79 if (dont_block) {
76 ExternalProtocolHandler::SetBlockState( 80 ExternalProtocolHandler::SetBlockState(
77 url.scheme(), ExternalProtocolHandler::BLOCK); 81 url.scheme(), ExternalProtocolHandler::BLOCK);
78 } 82 }
79 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698