OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
9 #include <propkey.h> | 9 #include <propkey.h> |
10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
(...skipping 30 matching lines...) Expand all Loading... |
41 std::wstring GetProfileIdFromPath(const FilePath& profile_path) { | 41 std::wstring GetProfileIdFromPath(const FilePath& profile_path) { |
42 // Return empty string if profile_path is empty | 42 // Return empty string if profile_path is empty |
43 if (profile_path.empty()) | 43 if (profile_path.empty()) |
44 return std::wstring(); | 44 return std::wstring(); |
45 | 45 |
46 FilePath default_user_data_dir; | 46 FilePath default_user_data_dir; |
47 // Return empty string if profile_path is in default user data | 47 // Return empty string if profile_path is in default user data |
48 // dir and is the default profile. | 48 // dir and is the default profile. |
49 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && | 49 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && |
50 profile_path.DirName() == default_user_data_dir && | 50 profile_path.DirName() == default_user_data_dir && |
51 profile_path.BaseName().value() == chrome::kNotSignedInProfile) | 51 profile_path.BaseName().value() == |
| 52 ASCIIToUTF16(chrome::kNotSignedInProfile)) { |
52 return std::wstring(); | 53 return std::wstring(); |
| 54 } |
53 | 55 |
54 // Get joined basenames of user data dir and profile. | 56 // Get joined basenames of user data dir and profile. |
55 std::wstring basenames = profile_path.DirName().BaseName().value() + | 57 std::wstring basenames = profile_path.DirName().BaseName().value() + |
56 L"." + profile_path.BaseName().value(); | 58 L"." + profile_path.BaseName().value(); |
57 | 59 |
58 std::wstring profile_id; | 60 std::wstring profile_id; |
59 profile_id.reserve(basenames.size()); | 61 profile_id.reserve(basenames.size()); |
60 | 62 |
61 // Generate profile_id from sanitized basenames. | 63 // Generate profile_id from sanitized basenames. |
62 for (size_t i = 0; i < basenames.length(); ++i) { | 64 for (size_t i = 0; i < basenames.length(); ++i) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 MAX_PATH))) | 214 MAX_PATH))) |
213 return false; | 215 return false; |
214 | 216 |
215 // Get expected app id from shortcut command line. | 217 // Get expected app id from shortcut command line. |
216 CommandLine command_line = CommandLine::FromString(StringPrintf( | 218 CommandLine command_line = CommandLine::FromString(StringPrintf( |
217 L"\"%ls\" %ls", source.c_str(), arguments.c_str())); | 219 L"\"%ls\" %ls", source.c_str(), arguments.c_str())); |
218 | 220 |
219 FilePath profile_path; | 221 FilePath profile_path; |
220 if (command_line.HasSwitch(switches::kUserDataDir)) { | 222 if (command_line.HasSwitch(switches::kUserDataDir)) { |
221 profile_path = | 223 profile_path = |
222 command_line.GetSwitchValuePath(switches::kUserDataDir).Append( | 224 command_line.GetSwitchValuePath(switches::kUserDataDir).AppendASCII( |
223 chrome::kNotSignedInProfile); | 225 chrome::kNotSignedInProfile); |
224 } | 226 } |
225 | 227 |
226 std::wstring app_name; | 228 std::wstring app_name; |
227 if (command_line.HasSwitch(switches::kApp)) { | 229 if (command_line.HasSwitch(switches::kApp)) { |
228 app_name = UTF8ToWide(web_app::GenerateApplicationNameFromURL( | 230 app_name = UTF8ToWide(web_app::GenerateApplicationNameFromURL( |
229 GURL(command_line.GetSwitchValueASCII(switches::kApp)))); | 231 GURL(command_line.GetSwitchValueASCII(switches::kApp)))); |
230 } else if (command_line.HasSwitch(switches::kAppId)) { | 232 } else if (command_line.HasSwitch(switches::kAppId)) { |
231 app_name = UTF8ToWide(web_app::GenerateApplicationNameFromExtensionId( | 233 app_name = UTF8ToWide(web_app::GenerateApplicationNameFromExtensionId( |
232 command_line.GetSwitchValueASCII(switches::kAppId))); | 234 command_line.GetSwitchValueASCII(switches::kAppId))); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 profile_path); | 414 profile_path); |
413 } | 415 } |
414 | 416 |
415 void ShellIntegration::MigrateChromiumShortcuts() { | 417 void ShellIntegration::MigrateChromiumShortcuts() { |
416 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 418 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
417 return; | 419 return; |
418 | 420 |
419 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
420 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); | 422 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); |
421 } | 423 } |
OLD | NEW |