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/time/time.h" | 9 #include "base/time/time.h" |
9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/lifetime/keep_alive_types.h" | 12 #include "chrome/browser/lifetime/keep_alive_types.h" |
12 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 13 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/profiles/profile_metrics.h" | 16 #include "chrome/browser/profiles/profile_metrics.h" |
16 #include "chrome/browser/profiles/profile_window.h" | 17 #include "chrome/browser/profiles/profile_window.h" |
17 #include "chrome/browser/profiles/profiles_state.h" | 18 #include "chrome/browser/profiles/profiles_state.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // there to then be multiple pending operations and eventually multiple | 180 // there to then be multiple pending operations and eventually multiple |
180 // User Managers. | 181 // User Managers. |
181 if (instance_under_construction_) | 182 if (instance_under_construction_) |
182 return; | 183 return; |
183 | 184 |
184 // Create the system profile, if necessary, and open the user manager | 185 // Create the system profile, if necessary, and open the user manager |
185 // from the system profile. | 186 // from the system profile. |
186 UserManagerView* user_manager = new UserManagerView(); | 187 UserManagerView* user_manager = new UserManagerView(); |
187 user_manager->set_user_manager_started_showing(base::Time::Now()); | 188 user_manager->set_user_manager_started_showing(base::Time::Now()); |
188 profiles::CreateSystemProfileForUserManager( | 189 profiles::CreateSystemProfileForUserManager( |
189 profile_path_to_focus, | 190 profile_path_to_focus, tutorial_mode, profile_open_action, |
190 tutorial_mode, | |
191 profile_open_action, | |
192 base::Bind(&UserManagerView::OnSystemProfileCreated, | 191 base::Bind(&UserManagerView::OnSystemProfileCreated, |
193 base::Passed(make_scoped_ptr(user_manager)), | 192 base::Passed(base::WrapUnique(user_manager)), |
194 base::Owned(new base::AutoReset<bool>( | 193 base::Owned(new base::AutoReset<bool>( |
195 &instance_under_construction_, true)))); | 194 &instance_under_construction_, true)))); |
196 } | 195 } |
197 | 196 |
198 // static | 197 // static |
199 void UserManager::Hide() { | 198 void UserManager::Hide() { |
200 if (instance_) | 199 if (instance_) |
201 instance_->GetWidget()->Close(); | 200 instance_->GetWidget()->Close(); |
202 } | 201 } |
203 | 202 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::USER_MANAGER_VIEW, | 251 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::USER_MANAGER_VIEW, |
253 KeepAliveRestartOption::DISABLED)); | 252 KeepAliveRestartOption::DISABLED)); |
254 #endif // !defined(USE_ASH) | 253 #endif // !defined(USE_ASH) |
255 } | 254 } |
256 | 255 |
257 UserManagerView::~UserManagerView() { | 256 UserManagerView::~UserManagerView() { |
258 } | 257 } |
259 | 258 |
260 // static | 259 // static |
261 void UserManagerView::OnSystemProfileCreated( | 260 void UserManagerView::OnSystemProfileCreated( |
262 scoped_ptr<UserManagerView> instance, | 261 std::unique_ptr<UserManagerView> instance, |
263 base::AutoReset<bool>* pending, | 262 base::AutoReset<bool>* pending, |
264 Profile* system_profile, | 263 Profile* system_profile, |
265 const std::string& url) { | 264 const std::string& url) { |
266 // If we are showing the User Manager after locking a profile, change the | 265 // If we are showing the User Manager after locking a profile, change the |
267 // active profile to Guest. | 266 // active profile to Guest. |
268 profiles::SetActiveProfileToGuestIfLocked(); | 267 profiles::SetActiveProfileToGuestIfLocked(); |
269 | 268 |
270 DCHECK(!instance_); | 269 DCHECK(!instance_); |
271 instance_ = instance.release(); // |instance_| takes over ownership. | 270 instance_ = instance.release(); // |instance_| takes over ownership. |
272 instance_->Init(system_profile, GURL(url)); | 271 instance_->Init(system_profile, GURL(url)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // Now that the window is closed, we can allow a new one to be opened. | 390 // Now that the window is closed, we can allow a new one to be opened. |
392 // (WindowClosing comes in asynchronously from the call to Close() and we | 391 // (WindowClosing comes in asynchronously from the call to Close() and we |
393 // may have already opened a new instance). | 392 // may have already opened a new instance). |
394 if (instance_ == this) | 393 if (instance_ == this) |
395 instance_ = NULL; | 394 instance_ = NULL; |
396 } | 395 } |
397 | 396 |
398 bool UserManagerView::UseNewStyleForThisDialog() const { | 397 bool UserManagerView::UseNewStyleForThisDialog() const { |
399 return false; | 398 return false; |
400 } | 399 } |
OLD | NEW |