OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "base/registry.h" | 10 #include "base/registry.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 void ExternalProtocolHandler::RunExternalProtocolDialog( | 32 void ExternalProtocolHandler::RunExternalProtocolDialog( |
33 const GURL& url, int render_process_host_id, int routing_id) { | 33 const GURL& url, int render_process_host_id, int routing_id) { |
34 std::wstring command = | 34 std::wstring command = |
35 ExternalProtocolDialog::GetApplicationForProtocol(url); | 35 ExternalProtocolDialog::GetApplicationForProtocol(url); |
36 if (command.empty()) { | 36 if (command.empty()) { |
37 // ShellExecute won't do anything. Don't bother warning the user. | 37 // ShellExecute won't do anything. Don't bother warning the user. |
38 return; | 38 return; |
39 } | 39 } |
40 TabContents* tab_contents = tab_util::GetTabContentsByID( | 40 TabContents* tab_contents = tab_util::GetTabContentsByID( |
41 render_process_host_id, routing_id); | 41 render_process_host_id, routing_id); |
| 42 DCHECK(tab_contents); |
42 ExternalProtocolDialog* handler = | 43 ExternalProtocolDialog* handler = |
43 new ExternalProtocolDialog(tab_contents, url, command); | 44 new ExternalProtocolDialog(tab_contents, url, command); |
44 } | 45 } |
45 | 46 |
46 /////////////////////////////////////////////////////////////////////////////// | 47 /////////////////////////////////////////////////////////////////////////////// |
47 // ExternalProtocolDialog | 48 // ExternalProtocolDialog |
48 | 49 |
49 ExternalProtocolDialog::~ExternalProtocolDialog() { | 50 ExternalProtocolDialog::~ExternalProtocolDialog() { |
50 } | 51 } |
51 | 52 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ASCIIToWide(url.scheme() + ":"), | 122 ASCIIToWide(url.scheme() + ":"), |
122 ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n"; | 123 ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n"; |
123 | 124 |
124 message_text += l10n_util::GetStringF( | 125 message_text += l10n_util::GetStringF( |
125 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n"; | 126 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n"; |
126 | 127 |
127 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); | 128 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); |
128 | 129 |
129 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, | 130 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, |
130 message_text, | 131 message_text, |
131 L"", | 132 std::wstring(), |
132 kMessageWidth); | 133 kMessageWidth); |
133 message_box_view_->SetCheckBoxLabel( | 134 message_box_view_->SetCheckBoxLabel( |
134 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); | 135 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); |
135 | 136 |
136 HWND root_hwnd; | 137 HWND root_hwnd; |
137 if (tab_contents_) { | 138 if (tab_contents_) { |
138 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); | 139 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); |
139 } else { | 140 } else { |
140 // Dialog is top level if we don't have a tab_contents associated with us. | 141 // Dialog is top level if we don't have a tab_contents associated with us. |
141 root_hwnd = NULL; | 142 root_hwnd = NULL; |
(...skipping 15 matching lines...) Expand all Loading... |
157 std::wstring parameters = url_spec.substr(split_offset + 1, | 158 std::wstring parameters = url_spec.substr(split_offset + 1, |
158 url_spec.length() - 1); | 159 url_spec.length() - 1); |
159 std::wstring application_to_launch; | 160 std::wstring application_to_launch; |
160 if (cmd_key.ReadValue(NULL, &application_to_launch)) { | 161 if (cmd_key.ReadValue(NULL, &application_to_launch)) { |
161 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); | 162 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); |
162 return application_to_launch; | 163 return application_to_launch; |
163 } else { | 164 } else { |
164 return std::wstring(); | 165 return std::wstring(); |
165 } | 166 } |
166 } | 167 } |
OLD | NEW |