| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 StartupBrowserCreator browser_creator; | 120 StartupBrowserCreator browser_creator; |
| 121 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), | 121 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), |
| 122 process_startup, is_first_run, &return_code); | 122 process_startup, is_first_run, &return_code); |
| 123 #endif // defined(OS_IOS) | 123 #endif // defined(OS_IOS) |
| 124 } | 124 } |
| 125 | 125 |
| 126 void SwitchToProfile( | 126 void SwitchToProfile( |
| 127 const base::FilePath& path, | 127 const base::FilePath& path, |
| 128 chrome::HostDesktopType desktop_type, | 128 chrome::HostDesktopType desktop_type, |
| 129 bool always_create, | 129 bool always_create, |
| 130 ProfileSwitchingDoneCallback callback) { | 130 ProfileSwitchingDoneCallback callback, |
| 131 ProfileMetrics::ProfileOpen metric) { |
| 131 g_browser_process->profile_manager()->CreateProfileAsync( | 132 g_browser_process->profile_manager()->CreateProfileAsync( |
| 132 path, | 133 path, |
| 133 base::Bind(&OpenBrowserWindowForProfile, | 134 base::Bind(&OpenBrowserWindowForProfile, |
| 134 callback, | 135 callback, |
| 135 always_create, | 136 always_create, |
| 136 false, | 137 false, |
| 137 desktop_type), | 138 desktop_type), |
| 138 base::string16(), | 139 base::string16(), |
| 139 base::string16(), | 140 base::string16(), |
| 140 std::string()); | 141 std::string()); |
| 142 ProfileMetrics::LogProfileSwitchUser(metric); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, | 145 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, |
| 144 ProfileSwitchingDoneCallback callback) { | 146 ProfileSwitchingDoneCallback callback) { |
| 145 g_browser_process->profile_manager()->CreateProfileAsync( | 147 g_browser_process->profile_manager()->CreateProfileAsync( |
| 146 ProfileManager::GetGuestProfilePath(), | 148 ProfileManager::GetGuestProfilePath(), |
| 147 base::Bind(&OpenBrowserWindowForProfile, | 149 base::Bind(&OpenBrowserWindowForProfile, |
| 148 callback, | 150 callback, |
| 149 false, | 151 false, |
| 150 false, | 152 false, |
| 151 desktop_type), | 153 desktop_type), |
| 152 base::string16(), | 154 base::string16(), |
| 153 base::string16(), | 155 base::string16(), |
| 154 std::string()); | 156 std::string()); |
| 157 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); |
| 155 } | 158 } |
| 156 | 159 |
| 157 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, | 160 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
| 158 ProfileSwitchingDoneCallback callback) { | 161 ProfileSwitchingDoneCallback callback, |
| 162 ProfileMetrics::ProfileAdd metric) { |
| 159 ProfileManager::CreateMultiProfileAsync( | 163 ProfileManager::CreateMultiProfileAsync( |
| 160 base::string16(), | 164 base::string16(), |
| 161 base::string16(), | 165 base::string16(), |
| 162 base::Bind(&OpenBrowserWindowForProfile, | 166 base::Bind(&OpenBrowserWindowForProfile, |
| 163 callback, | 167 callback, |
| 164 true, | 168 true, |
| 165 true, | 169 true, |
| 166 desktop_type), | 170 desktop_type), |
| 167 std::string()); | 171 std::string()); |
| 172 ProfileMetrics::LogProfileAddNewUser(metric); |
| 168 } | 173 } |
| 169 | 174 |
| 170 void CloseGuestProfileWindows() { | 175 void CloseGuestProfileWindows() { |
| 171 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 176 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 172 Profile* profile = profile_manager->GetProfileByPath( | 177 Profile* profile = profile_manager->GetProfileByPath( |
| 173 ProfileManager::GetGuestProfilePath()); | 178 ProfileManager::GetGuestProfilePath()); |
| 174 | 179 |
| 175 if (profile) { | 180 if (profile) { |
| 176 BrowserList::CloseAllBrowsersWithProfile(profile); | 181 BrowserList::CloseAllBrowsersWithProfile(profile); |
| 177 } | 182 } |
| 178 } | 183 } |
| 179 | 184 |
| 180 void LockProfile(Profile* profile) { | 185 void LockProfile(Profile* profile) { |
| 181 DCHECK(profile); | 186 DCHECK(profile); |
| 182 ProfileInfoCache& cache = | 187 ProfileInfoCache& cache = |
| 183 g_browser_process->profile_manager()->GetProfileInfoCache(); | 188 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 184 | 189 |
| 185 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 190 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 186 cache.SetProfileSigninRequiredAtIndex(index, true); | 191 cache.SetProfileSigninRequiredAtIndex(index, true); |
| 187 chrome::ShowUserManager(profile->GetPath()); | 192 chrome::ShowUserManager(profile->GetPath()); |
| 188 BrowserList::CloseAllBrowsersWithProfile(profile); | 193 BrowserList::CloseAllBrowsersWithProfile(profile); |
| 189 } | 194 } |
| 190 | 195 |
| 191 } // namespace profiles | 196 } // namespace profiles |
| OLD | NEW |