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

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

Issue 16374006: Place browser-modal dialogs like web-contents-modal dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert changes to c/b/chromeos files for now. Created 7 years, 6 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
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/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 "chrome/browser/ui/views/constrained_window_views.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
17 #include "grit/chromium_strings.h" 18 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/text/text_elider.h" 21 #include "ui/base/text/text_elider.h"
21 #include "ui/views/controls/message_box_view.h" 22 #include "ui/views/controls/message_box_view.h"
22 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
23 24
24 using content::WebContents; 25 using content::WebContents;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 message_box_view_->SetCheckBoxLabel( 155 message_box_view_->SetCheckBoxLabel(
155 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); 156 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
156 157
157 // 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.
158 HWND root_hwnd = NULL; 159 HWND root_hwnd = NULL;
159 if (web_contents_) { 160 if (web_contents_) {
160 root_hwnd = GetAncestor(web_contents_->GetView()->GetContentNativeView(), 161 root_hwnd = GetAncestor(web_contents_->GetView()->GetContentNativeView(),
161 GA_ROOT); 162 GA_ROOT);
162 } 163 }
163 164
164 views::DialogDelegate::CreateDialogWidget(this, NULL, root_hwnd)->Show(); 165 CreateBrowserModalDialogViews(this, root_hwnd)->Show();
165 } 166 }
166 167
167 // static 168 // static
168 std::wstring ExternalProtocolDialog::GetApplicationForProtocol( 169 std::wstring ExternalProtocolDialog::GetApplicationForProtocol(
169 const GURL& url) { 170 const GURL& url) {
170 // We shouldn't be accessing the registry from the UI thread, since it can go 171 // We shouldn't be accessing the registry from the UI thread, since it can go
171 // to disk. http://crbug.com/61996 172 // to disk. http://crbug.com/61996
172 base::ThreadRestrictions::ScopedAllowIO allow_io; 173 base::ThreadRestrictions::ScopedAllowIO allow_io;
173 174
174 std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec()); 175 std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec());
175 std::wstring cmd_key_path = 176 std::wstring cmd_key_path =
176 ASCIIToWide(url.scheme() + "\\shell\\open\\command"); 177 ASCIIToWide(url.scheme() + "\\shell\\open\\command");
177 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ); 178 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), KEY_READ);
178 size_t split_offset = url_spec.find(L':'); 179 size_t split_offset = url_spec.find(L':');
179 if (split_offset == std::wstring::npos) 180 if (split_offset == std::wstring::npos)
180 return std::wstring(); 181 return std::wstring();
181 std::wstring parameters = url_spec.substr(split_offset + 1, 182 std::wstring parameters = url_spec.substr(split_offset + 1,
182 url_spec.length() - 1); 183 url_spec.length() - 1);
183 std::wstring application_to_launch; 184 std::wstring application_to_launch;
184 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { 185 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) {
185 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); 186 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters);
186 return application_to_launch; 187 return application_to_launch;
187 } else { 188 } else {
188 return std::wstring(); 189 return std::wstring();
189 } 190 }
190 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698