| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/views/profiles/user_manager_view.h" | 5 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 parent_->OnDialogDestroyed(); | 128 parent_->OnDialogDestroyed(); |
| 129 parent_ = nullptr; | 129 parent_ = nullptr; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 // UserManager ----------------------------------------------------------------- | 133 // UserManager ----------------------------------------------------------------- |
| 134 | 134 |
| 135 // static | 135 // static |
| 136 void UserManager::Show( | 136 void UserManager::Show( |
| 137 const base::FilePath& profile_path_to_focus, | 137 const base::FilePath& profile_path_to_focus, |
| 138 profiles::UserManagerTutorialMode tutorial_mode, | |
| 139 profiles::UserManagerAction user_manager_action) { | 138 profiles::UserManagerAction user_manager_action) { |
| 140 DCHECK(profile_path_to_focus != ProfileManager::GetGuestProfilePath()); | 139 DCHECK(profile_path_to_focus != ProfileManager::GetGuestProfilePath()); |
| 141 | 140 |
| 142 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::OPEN_USER_MANAGER); | 141 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::OPEN_USER_MANAGER); |
| 143 if (instance_) { | 142 if (instance_) { |
| 144 // If we are showing the User Manager after locking a profile, change the | 143 // If we are showing the User Manager after locking a profile, change the |
| 145 // active profile to Guest. | 144 // active profile to Guest. |
| 146 profiles::SetActiveProfileToGuestIfLocked(); | 145 profiles::SetActiveProfileToGuestIfLocked(); |
| 147 | 146 |
| 148 // Note the time we started opening the User Manager. | 147 // Note the time we started opening the User Manager. |
| 149 instance_->set_user_manager_started_showing(base::Time::Now()); | 148 instance_->set_user_manager_started_showing(base::Time::Now()); |
| 150 | 149 |
| 151 // If there's a user manager window open already, just activate it. | 150 // If there's a user manager window open already, just activate it. |
| 152 instance_->GetWidget()->Activate(); | 151 instance_->GetWidget()->Activate(); |
| 153 return; | 152 return; |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Under some startup conditions, we can try twice to create the User Manager. | 155 // Under some startup conditions, we can try twice to create the User Manager. |
| 157 // Because creating the System profile is asynchronous, it's possible for | 156 // Because creating the System profile is asynchronous, it's possible for |
| 158 // there to then be multiple pending operations and eventually multiple | 157 // there to then be multiple pending operations and eventually multiple |
| 159 // User Managers. | 158 // User Managers. |
| 160 if (instance_under_construction_) | 159 if (instance_under_construction_) |
| 161 return; | 160 return; |
| 162 | 161 |
| 163 // Create the system profile, if necessary, and open the user manager | 162 // Create the system profile, if necessary, and open the user manager |
| 164 // from the system profile. | 163 // from the system profile. |
| 165 UserManagerView* user_manager = new UserManagerView(); | 164 UserManagerView* user_manager = new UserManagerView(); |
| 166 user_manager->set_user_manager_started_showing(base::Time::Now()); | 165 user_manager->set_user_manager_started_showing(base::Time::Now()); |
| 167 profiles::CreateSystemProfileForUserManager( | 166 profiles::CreateSystemProfileForUserManager( |
| 168 profile_path_to_focus, tutorial_mode, user_manager_action, | 167 profile_path_to_focus, user_manager_action, |
| 169 base::Bind(&UserManagerView::OnSystemProfileCreated, | 168 base::Bind(&UserManagerView::OnSystemProfileCreated, |
| 170 base::Passed(base::WrapUnique(user_manager)), | 169 base::Passed(base::WrapUnique(user_manager)), |
| 171 base::Owned(new base::AutoReset<bool>( | 170 base::Owned(new base::AutoReset<bool>( |
| 172 &instance_under_construction_, true)))); | 171 &instance_under_construction_, true)))); |
| 173 } | 172 } |
| 174 | 173 |
| 175 // static | 174 // static |
| 176 void UserManager::Hide() { | 175 void UserManager::Hide() { |
| 177 if (instance_) | 176 if (instance_) |
| 178 instance_->GetWidget()->Close(); | 177 instance_->GetWidget()->Close(); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 delegate_->DisplayErrorMessage(); | 444 delegate_->DisplayErrorMessage(); |
| 446 } | 445 } |
| 447 | 446 |
| 448 void UserManagerView::SetSigninProfilePath(const base::FilePath& profile_path) { | 447 void UserManagerView::SetSigninProfilePath(const base::FilePath& profile_path) { |
| 449 signin_profile_path_ = profile_path; | 448 signin_profile_path_ = profile_path; |
| 450 } | 449 } |
| 451 | 450 |
| 452 base::FilePath UserManagerView::GetSigninProfilePath() { | 451 base::FilePath UserManagerView::GetSigninProfilePath() { |
| 453 return signin_profile_path_; | 452 return signin_profile_path_; |
| 454 } | 453 } |
| OLD | NEW |