| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/user_data_manager.h" | 7 #include "chrome/browser/user_data_manager.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 std::wstring profile_name; | 251 std::wstring profile_name; |
| 252 if (GetProfileNameFromFolderName(folder_name, &profile_name)) | 252 if (GetProfileNameFromFolderName(folder_name, &profile_name)) |
| 253 profiles->push_back(profile_name); | 253 profiles->push_back(profile_name); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool UserDataManager::CreateShortcutForProfileInFolder( | 257 bool UserDataManager::CreateShortcutForProfileInFolder( |
| 258 const FilePath& folder, | 258 const FilePath& folder, |
| 259 const std::wstring& profile_name) const { | 259 const std::wstring& profile_name) const { |
| 260 #if defined(OS_WIN) | 260 #if defined(OS_WIN) |
| 261 std::wstring exe_path; | 261 FilePath exe_path; |
| 262 if (!PathService::Get(base::FILE_EXE, &exe_path)) | 262 if (!PathService::Get(base::FILE_EXE, &exe_path)) |
| 263 return false; | 263 return false; |
| 264 | 264 |
| 265 // Working directory. | 265 // Working directory. |
| 266 std::wstring exe_folder = file_util::GetDirectoryFromPath(exe_path); | 266 FilePath exe_folder = exe_path.DirName(); |
| 267 | 267 |
| 268 // Command and arguments. | 268 // Command and arguments. |
| 269 std::wstring cmd; | 269 std::wstring cmd; |
| 270 cmd = StringPrintf(L"\"%ls\"", exe_path.c_str()); | 270 cmd = StringPrintf(L"\"%ls\"", exe_path.value().c_str()); |
| 271 std::wstring user_data_dir = GetUserDataFolderForProfile(profile_name); | 271 std::wstring user_data_dir = GetUserDataFolderForProfile(profile_name); |
| 272 std::wstring args = CommandLine::PrefixedSwitchStringWithValue( | 272 std::wstring args = CommandLine::PrefixedSwitchStringWithValue( |
| 273 switches::kUserDataDir, | 273 switches::kUserDataDir, |
| 274 user_data_dir); | 274 user_data_dir); |
| 275 args = StringPrintf(L"\"%ls\"", args.c_str()); | 275 args = StringPrintf(L"\"%ls\"", args.c_str()); |
| 276 | 276 |
| 277 // Shortcut path. | 277 // Shortcut path. |
| 278 std::wstring shortcut_name = l10n_util::GetStringF( | 278 std::wstring shortcut_name = l10n_util::GetStringF( |
| 279 IDS_START_IN_PROFILE_SHORTCUT_NAME, | 279 IDS_START_IN_PROFILE_SHORTCUT_NAME, |
| 280 profile_name); | 280 profile_name); |
| 281 shortcut_name.append(L".lnk"); | 281 shortcut_name.append(L".lnk"); |
| 282 FilePath shortcut_path = folder.Append(shortcut_name); | 282 FilePath shortcut_path = folder.Append(shortcut_name); |
| 283 | 283 |
| 284 // Profile path from user_data_dir. | 284 // Profile path from user_data_dir. |
| 285 FilePath profile_path = FilePath(user_data_dir).Append( | 285 FilePath profile_path = FilePath(user_data_dir).Append( |
| 286 chrome::kNotSignedInProfile); | 286 chrome::kNotSignedInProfile); |
| 287 | 287 |
| 288 return file_util::CreateShortcutLink( | 288 return file_util::CreateShortcutLink( |
| 289 cmd.c_str(), | 289 cmd.c_str(), |
| 290 shortcut_path.value().c_str(), | 290 shortcut_path.value().c_str(), |
| 291 exe_folder.c_str(), | 291 exe_folder.value().c_str(), |
| 292 args.c_str(), | 292 args.c_str(), |
| 293 NULL, | 293 NULL, |
| 294 exe_path.c_str(), | 294 exe_path.value().c_str(), |
| 295 0, | 295 0, |
| 296 ShellIntegration::GetChromiumAppId(profile_path).c_str()); | 296 ShellIntegration::GetChromiumAppId(profile_path).c_str()); |
| 297 #else | 297 #else |
| 298 // TODO(port): should probably use freedesktop.org standard for desktop files. | 298 // TODO(port): should probably use freedesktop.org standard for desktop files. |
| 299 // See shell_integration.h for an implementation; but this code is reportedly | 299 // See shell_integration.h for an implementation; but this code is reportedly |
| 300 // obsolete. | 300 // obsolete. |
| 301 NOTIMPLEMENTED(); | 301 NOTIMPLEMENTED(); |
| 302 return false; | 302 return false; |
| 303 #endif | 303 #endif |
| 304 } | 304 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 &GetProfilesHelper::InvokeDelegate, | 370 &GetProfilesHelper::InvokeDelegate, |
| 371 profiles.release())); | 371 profiles.release())); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void GetProfilesHelper::InvokeDelegate(std::vector<std::wstring>* profiles) { | 374 void GetProfilesHelper::InvokeDelegate(std::vector<std::wstring>* profiles) { |
| 375 scoped_ptr< std::vector<std::wstring> > udd_profiles(profiles); | 375 scoped_ptr< std::vector<std::wstring> > udd_profiles(profiles); |
| 376 // If the delegate is gone by now, no need to do any work. | 376 // If the delegate is gone by now, no need to do any work. |
| 377 if (delegate_) | 377 if (delegate_) |
| 378 delegate_->OnGetProfilesDone(*udd_profiles.get()); | 378 delegate_->OnGetProfilesDone(*udd_profiles.get()); |
| 379 } | 379 } |
| OLD | NEW |