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

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

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const std::wstring& command) 127 const std::wstring& command)
128 : web_contents_(web_contents), 128 : web_contents_(web_contents),
129 url_(url), 129 url_(url),
130 creation_time_(base::TimeTicks::Now()) { 130 creation_time_(base::TimeTicks::Now()) {
131 const int kMaxUrlWithoutSchemeSize = 256; 131 const int kMaxUrlWithoutSchemeSize = 256;
132 const int kMaxCommandSize = 256; 132 const int kMaxCommandSize = 256;
133 string16 elided_url_without_scheme; 133 string16 elided_url_without_scheme;
134 string16 elided_command; 134 string16 elided_command;
135 ui::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()), 135 ui::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()),
136 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); 136 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
137 ui::ElideString(WideToUTF16Hack(command), kMaxCommandSize, &elided_command); 137 ui::ElideString(base::WideToUTF16Hack(command), kMaxCommandSize,
138 &elided_command);
138 139
139 string16 message_text = l10n_util::GetStringFUTF16( 140 string16 message_text = l10n_util::GetStringFUTF16(
140 IDS_EXTERNAL_PROTOCOL_INFORMATION, 141 IDS_EXTERNAL_PROTOCOL_INFORMATION,
141 ASCIIToUTF16(url.scheme() + ":"), 142 ASCIIToUTF16(url.scheme() + ":"),
142 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); 143 elided_url_without_scheme) + ASCIIToUTF16("\n\n");
143 144
144 message_text += l10n_util::GetStringFUTF16( 145 message_text += l10n_util::GetStringFUTF16(
145 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, 146 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH,
146 elided_command) + ASCIIToUTF16("\n\n"); 147 elided_command) + ASCIIToUTF16("\n\n");
147 148
(...skipping 16 matching lines...) Expand all
164 views::Widget::CreateWindowWithParent(this, root_hwnd)->Show(); 165 views::Widget::CreateWindowWithParent(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 = base::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 base::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
« no previous file with comments | « chrome/browser/ui/views/extensions/native_app_window_views.cc ('k') | chrome/browser/ui/views/external_tab_container_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698