OLD | NEW |
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 "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/text/text_elider.h" | 16 #include "ui/gfx/text_elider.h" |
17 | 17 |
18 ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(const GURL& url) | 18 ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(const GURL& url) |
19 : ProtocolDialogDelegate(url) { | 19 : ProtocolDialogDelegate(url) { |
20 } | 20 } |
21 | 21 |
22 ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() { | 22 ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() { |
23 } | 23 } |
24 | 24 |
25 string16 ExternalProtocolDialogDelegate::GetMessageText() const { | 25 string16 ExternalProtocolDialogDelegate::GetMessageText() const { |
26 const int kMaxUrlWithoutSchemeSize = 256; | 26 const int kMaxUrlWithoutSchemeSize = 256; |
27 const int kMaxCommandSize = 256; | 27 const int kMaxCommandSize = 256; |
28 // TODO(calamity): Look up the command in ExternalProtocolHandler and pass it | 28 // TODO(calamity): Look up the command in ExternalProtocolHandler and pass it |
29 // into the constructor. Will require simultaneous change of | 29 // into the constructor. Will require simultaneous change of |
30 // ExternalProtocolHandler::RunExternalProtocolDialog across all platforms. | 30 // ExternalProtocolHandler::RunExternalProtocolDialog across all platforms. |
31 string16 command = | 31 string16 command = |
32 UTF8ToUTF16(ShellIntegration::GetApplicationForProtocol(url())); | 32 UTF8ToUTF16(ShellIntegration::GetApplicationForProtocol(url())); |
33 string16 elided_url_without_scheme; | 33 string16 elided_url_without_scheme; |
34 string16 elided_command; | 34 string16 elided_command; |
35 ui::ElideString(ASCIIToUTF16(url().possibly_invalid_spec()), | 35 gfx::ElideString(ASCIIToUTF16(url().possibly_invalid_spec()), |
36 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 36 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
37 ui::ElideString(command, kMaxCommandSize, &elided_command); | 37 gfx::ElideString(command, kMaxCommandSize, &elided_command); |
38 | 38 |
39 string16 message_text = l10n_util::GetStringFUTF16( | 39 string16 message_text = l10n_util::GetStringFUTF16( |
40 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 40 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
41 ASCIIToUTF16(url().scheme() + ":"), | 41 ASCIIToUTF16(url().scheme() + ":"), |
42 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); | 42 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); |
43 | 43 |
44 message_text += l10n_util::GetStringFUTF16( | 44 message_text += l10n_util::GetStringFUTF16( |
45 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, | 45 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, |
46 elided_command) + ASCIIToUTF16("\n\n"); | 46 elided_command) + ASCIIToUTF16("\n\n"); |
47 | 47 |
(...skipping 21 matching lines...) Expand all Loading... |
69 } | 69 } |
70 | 70 |
71 void ExternalProtocolDialogDelegate::DoCancel( | 71 void ExternalProtocolDialogDelegate::DoCancel( |
72 const GURL& url, | 72 const GURL& url, |
73 bool dont_block) const { | 73 bool dont_block) const { |
74 if (dont_block) { | 74 if (dont_block) { |
75 ExternalProtocolHandler::SetBlockState( | 75 ExternalProtocolHandler::SetBlockState( |
76 url.scheme(), ExternalProtocolHandler::BLOCK); | 76 url.scheme(), ExternalProtocolHandler::BLOCK); |
77 } | 77 } |
78 } | 78 } |
OLD | NEW |