OLD | NEW |
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/shell_integration_win.h" | 5 #include "chrome/browser/shell_integration_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlwapi.h> | 8 #include <shlwapi.h> |
9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
10 #include <propkey.h> // Needs to come after shobjidl.h. | 10 #include <propkey.h> // Needs to come after shobjidl.h. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 return base::string16(out_buffer); | 199 return base::string16(out_buffer); |
200 } | 200 } |
201 | 201 |
202 base::string16 GetAppForProtocolUsingRegistry(const GURL& url) { | 202 base::string16 GetAppForProtocolUsingRegistry(const GURL& url) { |
203 const base::string16 cmd_key_path = | 203 const base::string16 cmd_key_path = |
204 base::ASCIIToUTF16(url.scheme() + "\\shell\\open\\command"); | 204 base::ASCIIToUTF16(url.scheme() + "\\shell\\open\\command"); |
205 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, | 205 base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, |
206 cmd_key_path.c_str(), | 206 cmd_key_path.c_str(), |
207 KEY_READ); | 207 KEY_READ); |
208 base::string16 application_to_launch; | 208 base::string16 command_to_launch; |
209 if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { | 209 if (cmd_key.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS) { |
210 const base::string16 url_spec = | 210 // Parse the command line in the registry, and return the basename of the |
211 base::ASCIIToUTF16(url.possibly_invalid_spec()); | 211 // program path. |
212 base::ReplaceSubstringsAfterOffset(&application_to_launch, | 212 base::CommandLine command_line( |
213 0, | 213 base::CommandLine::FromString(command_to_launch)); |
214 L"%1", | 214 return base::WideToUTF16(command_line.GetProgram().BaseName().value()); |
215 url_spec); | |
216 return application_to_launch; | |
217 } | 215 } |
218 return base::string16(); | 216 return base::string16(); |
219 } | 217 } |
220 | 218 |
221 DefaultWebClientState GetDefaultWebClientStateFromShellUtilDefaultState( | 219 DefaultWebClientState GetDefaultWebClientStateFromShellUtilDefaultState( |
222 ShellUtil::DefaultState default_state) { | 220 ShellUtil::DefaultState default_state) { |
223 switch (default_state) { | 221 switch (default_state) { |
224 case ShellUtil::NOT_DEFAULT: | 222 case ShellUtil::NOT_DEFAULT: |
225 return DefaultWebClientState::NOT_DEFAULT; | 223 return DefaultWebClientState::NOT_DEFAULT; |
226 case ShellUtil::IS_DEFAULT: | 224 case ShellUtil::IS_DEFAULT: |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 if (base::PathExists(shortcut)) | 851 if (base::PathExists(shortcut)) |
854 return shortcut; | 852 return shortcut; |
855 } | 853 } |
856 | 854 |
857 return base::FilePath(); | 855 return base::FilePath(); |
858 } | 856 } |
859 | 857 |
860 } // namespace win | 858 } // namespace win |
861 | 859 |
862 } // namespace shell_integration | 860 } // namespace shell_integration |
OLD | NEW |