| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/external_protocol_dialog.h" | 5 #include "chrome/browser/views/external_protocol_dialog.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "app/text_elider.h" |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/thread.h" | 12 #include "base/thread.h" |
| 12 #include "base/thread_restrictions.h" | 13 #include "base/thread_restrictions.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 15 #include "chrome/browser/external_protocol_handler.h" | 16 #include "chrome/browser/external_protocol_handler.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
| 18 #include "grit/chromium_strings.h" | 19 #include "grit/chromium_strings.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, | 116 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, |
| 116 const GURL& url, | 117 const GURL& url, |
| 117 const std::wstring& command) | 118 const std::wstring& command) |
| 118 : tab_contents_(tab_contents), | 119 : tab_contents_(tab_contents), |
| 119 url_(url), | 120 url_(url), |
| 120 creation_time_(base::TimeTicks::Now()) { | 121 creation_time_(base::TimeTicks::Now()) { |
| 121 const int kMaxUrlWithoutSchemeSize = 256; | 122 const int kMaxUrlWithoutSchemeSize = 256; |
| 122 const int kMaxCommandSize = 256; | 123 const int kMaxCommandSize = 256; |
| 123 std::wstring elided_url_without_scheme; | 124 std::wstring elided_url_without_scheme; |
| 124 std::wstring elided_command; | 125 std::wstring elided_command; |
| 125 ElideString(ASCIIToWide(url.possibly_invalid_spec()), | 126 gfx::ElideString(ASCIIToWide(url.possibly_invalid_spec()), |
| 126 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 127 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
| 127 ElideString(command, kMaxCommandSize, &elided_command); | 128 gfx::ElideString(command, kMaxCommandSize, &elided_command); |
| 128 | 129 |
| 129 std::wstring message_text = l10n_util::GetStringF( | 130 std::wstring message_text = l10n_util::GetStringF( |
| 130 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 131 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
| 131 ASCIIToWide(url.scheme() + ":"), | 132 ASCIIToWide(url.scheme() + ":"), |
| 132 elided_url_without_scheme) + L"\n\n"; | 133 elided_url_without_scheme) + L"\n\n"; |
| 133 | 134 |
| 134 message_text += l10n_util::GetStringF( | 135 message_text += l10n_util::GetStringF( |
| 135 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, elided_command) + L"\n\n"; | 136 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, elided_command) + L"\n\n"; |
| 136 | 137 |
| 137 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); | 138 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 std::wstring parameters = url_spec.substr(split_offset + 1, | 172 std::wstring parameters = url_spec.substr(split_offset + 1, |
| 172 url_spec.length() - 1); | 173 url_spec.length() - 1); |
| 173 std::wstring application_to_launch; | 174 std::wstring application_to_launch; |
| 174 if (cmd_key.ReadValue(NULL, &application_to_launch)) { | 175 if (cmd_key.ReadValue(NULL, &application_to_launch)) { |
| 175 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); | 176 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); |
| 176 return application_to_launch; | 177 return application_to_launch; |
| 177 } else { | 178 } else { |
| 178 return std::wstring(); | 179 return std::wstring(); |
| 179 } | 180 } |
| 180 } | 181 } |
| OLD | NEW |