OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 41 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
42 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 42 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
43 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 43 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
44 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 44 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
45 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" | 45 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" |
46 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 46 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
47 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 47 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
48 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 48 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
49 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" | 49 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" |
50 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 50 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 51 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
51 #include "chrome/browser/chromeos/login/user_flow.h" | 52 #include "chrome/browser/chromeos/login/user_flow.h" |
52 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 53 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
53 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 54 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
54 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 55 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
55 #include "chrome/browser/chromeos/settings/cros_settings.h" | 56 #include "chrome/browser/chromeos/settings/cros_settings.h" |
56 #include "chrome/browser/extensions/extension_service.h" | 57 #include "chrome/browser/extensions/extension_service.h" |
57 #include "chrome/browser/first_run/first_run.h" | 58 #include "chrome/browser/first_run/first_run.h" |
58 #include "chrome/browser/google/google_brand_chromeos.h" | 59 #include "chrome/browser/google/google_brand_chromeos.h" |
59 #include "chrome/browser/lifetime/application_lifetime.h" | 60 #include "chrome/browser/lifetime/application_lifetime.h" |
60 #include "chrome/browser/pref_service_flags_storage.h" | 61 #include "chrome/browser/pref_service_flags_storage.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 bool has_auth_cookies, | 189 bool has_auth_cookies, |
189 bool has_active_session, | 190 bool has_active_session, |
190 LoginUtils::Delegate* delegate) override; | 191 LoginUtils::Delegate* delegate) override; |
191 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) override; | 192 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) override; |
192 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 193 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
193 AuthStatusConsumer* consumer) override; | 194 AuthStatusConsumer* consumer) override; |
194 virtual bool RestartToApplyPerSessionFlagsIfNeed(Profile* profile, | 195 virtual bool RestartToApplyPerSessionFlagsIfNeed(Profile* profile, |
195 bool early_restart) override; | 196 bool early_restart) override; |
196 | 197 |
197 // UserSessionManager::Delegate implementation: | 198 // UserSessionManager::Delegate implementation: |
198 virtual void OnProfilePrepared(Profile* profile) override; | 199 virtual void OnProfilePrepared(Profile* profile, |
| 200 bool browser_launched) override; |
199 #if defined(ENABLE_RLZ) | 201 #if defined(ENABLE_RLZ) |
200 virtual void OnRlzInitialized() override; | 202 virtual void OnRlzInitialized() override; |
201 #endif | 203 #endif |
202 | 204 |
203 private: | 205 private: |
204 void DoBrowserLaunchInternal(Profile* profile, | 206 void DoBrowserLaunchInternal(Profile* profile, |
205 LoginDisplayHost* login_host, | 207 LoginDisplayHost* login_host, |
206 bool locale_pref_checked); | 208 bool locale_pref_checked); |
207 | 209 |
208 // Switch to the locale that |profile| wishes to use and invoke |callback|. | 210 // Switch to the locale that |profile| wishes to use and invoke |callback|. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 361 |
360 void LoginUtilsImpl::PrepareProfile( | 362 void LoginUtilsImpl::PrepareProfile( |
361 const UserContext& user_context, | 363 const UserContext& user_context, |
362 bool has_auth_cookies, | 364 bool has_auth_cookies, |
363 bool has_active_session, | 365 bool has_active_session, |
364 LoginUtils::Delegate* delegate) { | 366 LoginUtils::Delegate* delegate) { |
365 // TODO(nkostylev): We have to initialize LoginUtils delegate as long | 367 // TODO(nkostylev): We have to initialize LoginUtils delegate as long |
366 // as it coexist with SessionManager. | 368 // as it coexist with SessionManager. |
367 delegate_ = delegate; | 369 delegate_ = delegate; |
368 | 370 |
| 371 UserSessionManager::StartSessionType start_session_type = |
| 372 UserAddingScreen::Get()->IsRunning() ? |
| 373 UserSessionManager::SECONDARY_USER_SESSION : |
| 374 UserSessionManager::PRIMARY_USER_SESSION; |
| 375 |
369 // For the transition part LoginUtils will just delegate profile | 376 // For the transition part LoginUtils will just delegate profile |
370 // creation and initialization to SessionManager. Later LoginUtils will be | 377 // creation and initialization to SessionManager. Later LoginUtils will be |
371 // removed and all LoginUtils clients will just work with SessionManager | 378 // removed and all LoginUtils clients will just work with SessionManager |
372 // directly. | 379 // directly. |
373 UserSessionManager::GetInstance()->StartSession( | 380 UserSessionManager::GetInstance()->StartSession(user_context, |
374 user_context, authenticator_, has_auth_cookies, has_active_session, this); | 381 start_session_type, |
| 382 authenticator_, |
| 383 has_auth_cookies, |
| 384 has_active_session, |
| 385 this); |
375 } | 386 } |
376 | 387 |
377 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { | 388 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { |
378 if (delegate_ == delegate) | 389 if (delegate_ == delegate) |
379 delegate_ = NULL; | 390 delegate_ = NULL; |
380 } | 391 } |
381 | 392 |
382 bool LoginUtilsImpl::RestartToApplyPerSessionFlagsIfNeed(Profile* profile, | 393 bool LoginUtilsImpl::RestartToApplyPerSessionFlagsIfNeed(Profile* profile, |
383 bool early_restart) { | 394 bool early_restart) { |
384 if (ProfileHelper::IsSigninProfile(profile)) | 395 if (ProfileHelper::IsSigninProfile(profile)) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 428 |
418 if (authenticator_.get() == NULL) { | 429 if (authenticator_.get() == NULL) { |
419 authenticator_ = new ChromeCryptohomeAuthenticator(consumer); | 430 authenticator_ = new ChromeCryptohomeAuthenticator(consumer); |
420 } else { | 431 } else { |
421 // TODO(nkostylev): Fix this hack by improving Authenticator dependencies. | 432 // TODO(nkostylev): Fix this hack by improving Authenticator dependencies. |
422 authenticator_->SetConsumer(consumer); | 433 authenticator_->SetConsumer(consumer); |
423 } | 434 } |
424 return authenticator_; | 435 return authenticator_; |
425 } | 436 } |
426 | 437 |
427 void LoginUtilsImpl::OnProfilePrepared(Profile* profile) { | 438 void LoginUtilsImpl::OnProfilePrepared(Profile* profile, |
| 439 bool browser_launched) { |
428 if (delegate_) | 440 if (delegate_) |
429 delegate_->OnProfilePrepared(profile); | 441 delegate_->OnProfilePrepared(profile, browser_launched); |
430 } | 442 } |
431 | 443 |
432 #if defined(ENABLE_RLZ) | 444 #if defined(ENABLE_RLZ) |
433 void LoginUtilsImpl::OnRlzInitialized() { | 445 void LoginUtilsImpl::OnRlzInitialized() { |
434 if (delegate_) | 446 if (delegate_) |
435 delegate_->OnRlzInitialized(); | 447 delegate_->OnRlzInitialized(); |
436 } | 448 } |
437 #endif | 449 #endif |
438 | 450 |
439 void LoginUtilsImpl::AttemptRestart(Profile* profile) { | 451 void LoginUtilsImpl::AttemptRestart(Profile* profile) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 CrosSettings* cros_settings = CrosSettings::Get(); | 501 CrosSettings* cros_settings = CrosSettings::Get(); |
490 bool allow_new_user = false; | 502 bool allow_new_user = false; |
491 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 503 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
492 if (allow_new_user) | 504 if (allow_new_user) |
493 return true; | 505 return true; |
494 return cros_settings->FindEmailInList( | 506 return cros_settings->FindEmailInList( |
495 kAccountsPrefUsers, username, wildcard_match); | 507 kAccountsPrefUsers, username, wildcard_match); |
496 } | 508 } |
497 | 509 |
498 } // namespace chromeos | 510 } // namespace chromeos |
OLD | NEW |