Chromium Code Reviews| 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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 path); | 281 path); |
| 282 g_browser_process->profile_manager()->CreateProfileAsync( | 282 g_browser_process->profile_manager()->CreateProfileAsync( |
| 283 path, | 283 path, |
| 284 base::Bind(&OpenBrowserWindowForProfile, | 284 base::Bind(&OpenBrowserWindowForProfile, |
| 285 callback, | 285 callback, |
| 286 always_create, | 286 always_create, |
| 287 false, | 287 false, |
| 288 desktop_type), | 288 desktop_type), |
| 289 base::string16(), | 289 base::string16(), |
| 290 base::string16(), | 290 base::string16(), |
| 291 std::string()); | 291 user_manager::UserID(std::string(), std::string())); |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:47
EmptyUserID
| |
| 292 } | 292 } |
| 293 | 293 |
| 294 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, | 294 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, |
| 295 ProfileManager::CreateCallback callback) { | 295 ProfileManager::CreateCallback callback) { |
| 296 const base::FilePath& path = ProfileManager::GetGuestProfilePath(); | 296 const base::FilePath& path = ProfileManager::GetGuestProfilePath(); |
| 297 ProfileMetrics::LogProfileSwitch(ProfileMetrics::SWITCH_PROFILE_GUEST, | 297 ProfileMetrics::LogProfileSwitch(ProfileMetrics::SWITCH_PROFILE_GUEST, |
| 298 g_browser_process->profile_manager(), | 298 g_browser_process->profile_manager(), |
| 299 path); | 299 path); |
| 300 g_browser_process->profile_manager()->CreateProfileAsync( | 300 g_browser_process->profile_manager()->CreateProfileAsync( |
| 301 path, | 301 path, |
| 302 base::Bind(&OpenBrowserWindowForProfile, | 302 base::Bind(&OpenBrowserWindowForProfile, |
| 303 callback, | 303 callback, |
| 304 false, | 304 false, |
| 305 false, | 305 false, |
| 306 desktop_type), | 306 desktop_type), |
| 307 base::string16(), | 307 base::string16(), |
| 308 base::string16(), | 308 base::string16(), |
| 309 std::string()); | 309 user_manager::UserID(std::string(), std::string())); |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool HasProfileSwitchTargets(Profile* profile) { | 312 bool HasProfileSwitchTargets(Profile* profile) { |
| 313 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; | 313 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; |
| 314 size_t number_of_profiles = | 314 size_t number_of_profiles = |
| 315 g_browser_process->profile_manager()->GetNumberOfProfiles(); | 315 g_browser_process->profile_manager()->GetNumberOfProfiles(); |
| 316 return number_of_profiles >= min_profiles; | 316 return number_of_profiles >= min_profiles; |
| 317 } | 317 } |
| 318 | 318 |
| 319 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, | 319 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
| 320 ProfileManager::CreateCallback callback, | 320 ProfileManager::CreateCallback callback, |
| 321 ProfileMetrics::ProfileAdd metric) { | 321 ProfileMetrics::ProfileAdd metric) { |
| 322 ProfileInfoCache& cache = | 322 ProfileInfoCache& cache = |
| 323 g_browser_process->profile_manager()->GetProfileInfoCache(); | 323 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 324 | 324 |
| 325 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); | 325 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 326 ProfileManager::CreateMultiProfileAsync( | 326 ProfileManager::CreateMultiProfileAsync( |
| 327 cache.ChooseNameForNewProfile(placeholder_avatar_index), | 327 cache.ChooseNameForNewProfile(placeholder_avatar_index), |
| 328 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl( | 328 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl( |
| 329 placeholder_avatar_index)), | 329 placeholder_avatar_index)), |
| 330 base::Bind(&OpenBrowserWindowForProfile, | 330 base::Bind(&OpenBrowserWindowForProfile, |
| 331 callback, | 331 callback, |
| 332 true, | 332 true, |
| 333 true, | 333 true, |
| 334 desktop_type), | 334 desktop_type), |
| 335 std::string()); | 335 user_manager::UserID(std::string(), std::string())); |
| 336 ProfileMetrics::LogProfileAddNewUser(metric); | 336 ProfileMetrics::LogProfileAddNewUser(metric); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void GuestBrowserCloseSuccess(const base::FilePath& profile_path) { | 339 void GuestBrowserCloseSuccess(const base::FilePath& profile_path) { |
| 340 UserManager::Show(base::FilePath(), | 340 UserManager::Show(base::FilePath(), |
| 341 profiles::USER_MANAGER_NO_TUTORIAL, | 341 profiles::USER_MANAGER_NO_TUTORIAL, |
| 342 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 342 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void CloseGuestProfileWindows() { | 345 void CloseGuestProfileWindows() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 // from the system profile. | 423 // from the system profile. |
| 424 g_browser_process->profile_manager()->CreateProfileAsync( | 424 g_browser_process->profile_manager()->CreateProfileAsync( |
| 425 ProfileManager::GetSystemProfilePath(), | 425 ProfileManager::GetSystemProfilePath(), |
| 426 base::Bind(&OnUserManagerSystemProfileCreated, | 426 base::Bind(&OnUserManagerSystemProfileCreated, |
| 427 profile_path_to_focus, | 427 profile_path_to_focus, |
| 428 tutorial_mode, | 428 tutorial_mode, |
| 429 profile_open_action, | 429 profile_open_action, |
| 430 callback), | 430 callback), |
| 431 base::string16(), | 431 base::string16(), |
| 432 base::string16(), | 432 base::string16(), |
| 433 std::string()); | 433 user_manager::UserID(std::string(), std::string())); |
| 434 } | 434 } |
| 435 | 435 |
| 436 void ShowUserManagerMaybeWithTutorial(Profile* profile) { | 436 void ShowUserManagerMaybeWithTutorial(Profile* profile) { |
| 437 // Guest users cannot appear in the User Manager, nor display a tutorial. | 437 // Guest users cannot appear in the User Manager, nor display a tutorial. |
| 438 if (!profile || profile->IsGuestSession()) { | 438 if (!profile || profile->IsGuestSession()) { |
| 439 UserManager::Show(base::FilePath(), | 439 UserManager::Show(base::FilePath(), |
| 440 profiles::USER_MANAGER_NO_TUTORIAL, | 440 profiles::USER_MANAGER_NO_TUTORIAL, |
| 441 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 441 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 442 return; | 442 return; |
| 443 } | 443 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 PrefService* local_state = g_browser_process->local_state(); | 542 PrefService* local_state = g_browser_process->local_state(); |
| 543 const bool dismissed = local_state->GetBoolean( | 543 const bool dismissed = local_state->GetBoolean( |
| 544 prefs::kProfileAvatarRightClickTutorialDismissed); | 544 prefs::kProfileAvatarRightClickTutorialDismissed); |
| 545 | 545 |
| 546 // Don't show the tutorial if it's already been dismissed or if right-clicking | 546 // Don't show the tutorial if it's already been dismissed or if right-clicking |
| 547 // wouldn't show any targets. | 547 // wouldn't show any targets. |
| 548 return !dismissed && HasProfileSwitchTargets(profile); | 548 return !dismissed && HasProfileSwitchTargets(profile); |
| 549 } | 549 } |
| 550 | 550 |
| 551 } // namespace profiles | 551 } // namespace profiles |
| OLD | NEW |