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

Side by Side Diff: chrome/browser/ui/views/external_protocol_dialog.cc

Issue 25589002: Enable external protocol dialog on Windows Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: linux Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/stubs_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/string_util.h" 8 #include "base/strings/string_util.h"
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"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 message_text += l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_WARNING); 150 message_text += l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_WARNING);
151 151
152 views::MessageBoxView::InitParams params(message_text); 152 views::MessageBoxView::InitParams params(message_text);
153 params.message_width = kMessageWidth; 153 params.message_width = kMessageWidth;
154 message_box_view_ = new views::MessageBoxView(params); 154 message_box_view_ = new views::MessageBoxView(params);
155 message_box_view_->SetCheckBoxLabel( 155 message_box_view_->SetCheckBoxLabel(
156 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); 156 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
157 157
158 // Dialog is top level if we don't have a web_contents associated with us. 158 // Dialog is top level if we don't have a web_contents associated with us.
159 HWND root_hwnd = NULL; 159 gfx::NativeWindow parent_window = NULL;
160 if (web_contents_) { 160 if (web_contents_)
161 root_hwnd = GetAncestor(web_contents_->GetView()->GetContentNativeView(), 161 parent_window = web_contents_->GetView()->GetTopLevelNativeWindow();
162 GA_ROOT); 162 CreateBrowserModalDialogViews(this, parent_window)->Show();
163 }
164
165 CreateBrowserModalDialogViews(this, root_hwnd)->Show();
166 } 163 }
167 164
168 // static 165 // static
169 std::wstring ExternalProtocolDialog::GetApplicationForProtocol( 166 std::wstring ExternalProtocolDialog::GetApplicationForProtocol(
170 const GURL& url) { 167 const GURL& url) {
171 // We shouldn't be accessing the registry from the UI thread, since it can go 168 // We shouldn't be accessing the registry from the UI thread, since it can go
172 // to disk. http://crbug.com/61996 169 // to disk. http://crbug.com/61996
173 base::ThreadRestrictions::ScopedAllowIO allow_io; 170 base::ThreadRestrictions::ScopedAllowIO allow_io;
174 171
175 std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec()); 172 std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec());
176 std::wstring cmd_key_path = 173 std::wstring cmd_key_path =
177 ASCIIToWide(url.scheme() + "\\shell\\open\\command"); 174 ASCIIToWide(url.scheme() + "\\shell\\open\\command");
178 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ); 175 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ);
179 size_t split_offset = url_spec.find(L':'); 176 size_t split_offset = url_spec.find(L':');
180 if (split_offset == std::wstring::npos) 177 if (split_offset == std::wstring::npos)
181 return std::wstring(); 178 return std::wstring();
182 std::wstring parameters = url_spec.substr(split_offset + 1, 179 std::wstring parameters = url_spec.substr(split_offset + 1,
183 url_spec.length() - 1); 180 url_spec.length() - 1);
184 std::wstring application_to_launch; 181 std::wstring application_to_launch;
185 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { 182 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) {
186 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); 183 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters);
187 return application_to_launch; 184 return application_to_launch;
188 } else { 185 } else {
189 return std::wstring(); 186 return std::wstring();
190 } 187 }
191 } 188 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/stubs_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698