| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // Destroy all profiles that we're keeping track of. | 67 // Destroy all profiles that we're keeping track of. |
| 68 for (const_iterator i(begin()); i != end(); ++i) | 68 for (const_iterator i(begin()); i != end(); ++i) |
| 69 delete *i; | 69 delete *i; |
| 70 profiles_.clear(); | 70 profiles_.clear(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 FilePath ProfileManager::GetDefaultProfileDir( | 73 FilePath ProfileManager::GetDefaultProfileDir( |
| 74 const FilePath& user_data_dir) { | 74 const FilePath& user_data_dir) { |
| 75 FilePath default_profile_dir(user_data_dir); | 75 FilePath default_profile_dir(user_data_dir); |
| 76 default_profile_dir = default_profile_dir.Append( | 76 default_profile_dir = |
| 77 FilePath::FromWStringHack(chrome::kNotSignedInProfile)); | 77 default_profile_dir.AppendASCII(chrome::kNotSignedInProfile); |
| 78 return default_profile_dir; | 78 return default_profile_dir; |
| 79 } | 79 } |
| 80 | 80 |
| 81 FilePath ProfileManager::GetProfilePrefsPath( | 81 FilePath ProfileManager::GetProfilePrefsPath( |
| 82 const FilePath &profile_dir) { | 82 const FilePath &profile_dir) { |
| 83 FilePath default_prefs_path(profile_dir); | 83 FilePath default_prefs_path(profile_dir); |
| 84 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename); | 84 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename); |
| 85 return default_prefs_path; | 85 return default_prefs_path; |
| 86 } | 86 } |
| 87 | 87 |
| 88 FilePath ProfileManager::GetCurrentProfileDir() { | 88 FilePath ProfileManager::GetCurrentProfileDir() { |
| 89 FilePath relative_profile_dir; | 89 FilePath relative_profile_dir; |
| 90 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
| 91 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 91 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 92 if (logged_in_) { | 92 if (logged_in_) { |
| 93 FilePath profile_dir; | 93 FilePath profile_dir; |
| 94 // If the user has logged in, pick up the new profile. | 94 // If the user has logged in, pick up the new profile. |
| 95 if (command_line.HasSwitch(switches::kLoginProfile)) { | 95 if (command_line.HasSwitch(switches::kLoginProfile)) { |
| 96 profile_dir = command_line.GetSwitchValuePath(switches::kLoginProfile); | 96 profile_dir = command_line.GetSwitchValuePath(switches::kLoginProfile); |
| 97 } else { | 97 } else { |
| 98 // We should never be logged in with no profile dir. | 98 // We should never be logged in with no profile dir. |
| 99 NOTREACHED(); | 99 NOTREACHED(); |
| 100 return FilePath(""); | 100 return FilePath(""); |
| 101 } | 101 } |
| 102 relative_profile_dir = relative_profile_dir.Append(profile_dir); | 102 relative_profile_dir = relative_profile_dir.Append(profile_dir); |
| 103 return relative_profile_dir; | 103 return relative_profile_dir; |
| 104 } | 104 } |
| 105 #endif | 105 #endif |
| 106 relative_profile_dir = relative_profile_dir.Append( | 106 relative_profile_dir = |
| 107 FilePath::FromWStringHack(chrome::kNotSignedInProfile)); | 107 relative_profile_dir.AppendASCII(chrome::kNotSignedInProfile); |
| 108 return relative_profile_dir; | 108 return relative_profile_dir; |
| 109 } | 109 } |
| 110 | 110 |
| 111 Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) { | 111 Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) { |
| 112 FilePath default_profile_dir(user_data_dir); | 112 FilePath default_profile_dir(user_data_dir); |
| 113 default_profile_dir = default_profile_dir.Append(GetCurrentProfileDir()); | 113 default_profile_dir = default_profile_dir.Append(GetCurrentProfileDir()); |
| 114 #if defined(OS_CHROMEOS) | 114 #if defined(OS_CHROMEOS) |
| 115 if (!logged_in_) { | 115 if (!logged_in_) { |
| 116 Profile* profile; | 116 Profile* profile; |
| 117 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 117 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (!file_util::PathExists(path)) { | 302 if (!file_util::PathExists(path)) { |
| 303 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 303 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
| 304 // profile directory. We should eventually be able to run in this | 304 // profile directory. We should eventually be able to run in this |
| 305 // situation. | 305 // situation. |
| 306 if (!file_util::CreateDirectory(path)) | 306 if (!file_util::CreateDirectory(path)) |
| 307 return NULL; | 307 return NULL; |
| 308 } | 308 } |
| 309 | 309 |
| 310 return Profile::CreateProfile(path); | 310 return Profile::CreateProfile(path); |
| 311 } | 311 } |
| OLD | NEW |