OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
13 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 13 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
15 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
16 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/message_box_flags.h" | |
20 #include "ui/base/text/text_elider.h" | 19 #include "ui/base/text/text_elider.h" |
21 #include "ui/views/controls/message_box_view.h" | 20 #include "ui/views/controls/message_box_view.h" |
22 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 const int kMessageWidth = 400; | 25 const int kMessageWidth = 400; |
27 | 26 |
28 } // namespace | 27 } // namespace |
29 | 28 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ASCIIToUTF16(url.scheme() + ":"), | 139 ASCIIToUTF16(url.scheme() + ":"), |
141 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); | 140 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); |
142 | 141 |
143 message_text += l10n_util::GetStringFUTF16( | 142 message_text += l10n_util::GetStringFUTF16( |
144 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, | 143 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, |
145 elided_command) + ASCIIToUTF16("\n\n"); | 144 elided_command) + ASCIIToUTF16("\n\n"); |
146 | 145 |
147 message_text += l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_WARNING); | 146 message_text += l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_WARNING); |
148 | 147 |
149 message_box_view_ = new views::MessageBoxView( | 148 message_box_view_ = new views::MessageBoxView( |
150 ui::MessageBoxFlags::kIsConfirmMessageBox, | 149 views::MessageBoxView::NO_OPTIONS, |
151 message_text, | 150 message_text, |
152 string16(), | 151 string16(), |
153 kMessageWidth); | 152 kMessageWidth); |
154 message_box_view_->SetCheckBoxLabel( | 153 message_box_view_->SetCheckBoxLabel( |
155 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); | 154 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); |
156 | 155 |
157 HWND root_hwnd; | 156 HWND root_hwnd; |
158 if (tab_contents_) { | 157 if (tab_contents_) { |
159 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); | 158 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); |
160 } else { | 159 } else { |
(...skipping 21 matching lines...) Expand all Loading... |
182 std::wstring parameters = url_spec.substr(split_offset + 1, | 181 std::wstring parameters = url_spec.substr(split_offset + 1, |
183 url_spec.length() - 1); | 182 url_spec.length() - 1); |
184 std::wstring application_to_launch; | 183 std::wstring application_to_launch; |
185 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { | 184 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { |
186 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); | 185 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); |
187 return application_to_launch; | 186 return application_to_launch; |
188 } else { | 187 } else { |
189 return std::wstring(); | 188 return std::wstring(); |
190 } | 189 } |
191 } | 190 } |
OLD | NEW |