Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 971383002: Removing FRE UI for unicorn accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing the observer. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chromeos/login/session/user_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "chrome/browser/net/crl_set_fetcher.h" 58 #include "chrome/browser/net/crl_set_fetcher.h"
59 #include "chrome/browser/net/nss_context.h" 59 #include "chrome/browser/net/nss_context.h"
60 #include "chrome/browser/pref_service_flags_storage.h" 60 #include "chrome/browser/pref_service_flags_storage.h"
61 #include "chrome/browser/prefs/session_startup_pref.h" 61 #include "chrome/browser/prefs/session_startup_pref.h"
62 #include "chrome/browser/profiles/profile.h" 62 #include "chrome/browser/profiles/profile.h"
63 #include "chrome/browser/profiles/profile_manager.h" 63 #include "chrome/browser/profiles/profile_manager.h"
64 #include "chrome/browser/rlz/rlz.h" 64 #include "chrome/browser/rlz/rlz.h"
65 #include "chrome/browser/signin/account_tracker_service_factory.h" 65 #include "chrome/browser/signin/account_tracker_service_factory.h"
66 #include "chrome/browser/signin/easy_unlock_service.h" 66 #include "chrome/browser/signin/easy_unlock_service.h"
67 #include "chrome/browser/signin/signin_manager_factory.h" 67 #include "chrome/browser/signin/signin_manager_factory.h"
68 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
69 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h"
68 #include "chrome/browser/ui/app_list/start_page_service.h" 70 #include "chrome/browser/ui/app_list/start_page_service.h"
69 #include "chrome/browser/ui/startup/startup_browser_creator.h" 71 #include "chrome/browser/ui/startup/startup_browser_creator.h"
70 #include "chrome/common/chrome_switches.h" 72 #include "chrome/common/chrome_switches.h"
71 #include "chrome/common/logging_chrome.h" 73 #include "chrome/common/logging_chrome.h"
72 #include "chrome/common/pref_names.h" 74 #include "chrome/common/pref_names.h"
73 #include "chrome/common/url_constants.h" 75 #include "chrome/common/url_constants.h"
74 #include "chromeos/cert_loader.h" 76 #include "chromeos/cert_loader.h"
75 #include "chromeos/chromeos_switches.h" 77 #include "chromeos/chromeos_switches.h"
76 #include "chromeos/cryptohome/cryptohome_util.h" 78 #include "chromeos/cryptohome/cryptohome_util.h"
77 #include "chromeos/dbus/cryptohome_client.h" 79 #include "chromeos/dbus/cryptohome_client.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 UserSessionManager::UserSessionManager() 320 UserSessionManager::UserSessionManager()
319 : delegate_(nullptr), 321 : delegate_(nullptr),
320 authenticator_(nullptr), 322 authenticator_(nullptr),
321 has_auth_cookies_(false), 323 has_auth_cookies_(false),
322 user_sessions_restored_(false), 324 user_sessions_restored_(false),
323 user_sessions_restore_in_progress_(false), 325 user_sessions_restore_in_progress_(false),
324 exit_after_session_restore_(false), 326 exit_after_session_restore_(false),
325 session_restore_strategy_( 327 session_restore_strategy_(
326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), 328 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN),
327 running_easy_unlock_key_ops_(false), 329 running_easy_unlock_key_ops_(false),
328 should_launch_browser_(true) { 330 should_launch_browser_(true),
331 requesting_start_urls_(false),
332 profile_fetching_flags_(nullptr),
333 weak_factory_(this) {
329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 334 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
330 user_manager::UserManager::Get()->AddSessionStateObserver(this); 335 user_manager::UserManager::Get()->AddSessionStateObserver(this);
331 } 336 }
332 337
333 UserSessionManager::~UserSessionManager() { 338 UserSessionManager::~UserSessionManager() {
334 // UserManager is destroyed before singletons, so we need to check if it 339 // UserManager is destroyed before singletons, so we need to check if it
335 // still exists. 340 // still exists.
336 // TODO(nkostylev): fix order of destruction of UserManager 341 // TODO(nkostylev): fix order of destruction of UserManager
337 // / UserSessionManager objects. 342 // / UserSessionManager objects.
338 if (user_manager::UserManager::IsInitialized()) 343 if (user_manager::UserManager::IsInitialized())
339 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); 344 user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
340 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 345 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
341 } 346 }
342 347
348 // static
349 const int UserSessionManager::kFlagsFetchingLoginTimeoutMs = 1000;
Marc Treib 2015/03/04 16:31:48 Can we make this large enough so that we get a sec
merkulova 2015/03/04 19:06:49 That's a tricky question: we want the FRE UI to ap
350
343 void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) { 351 void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) {
344 VLOG(1) << "Completing guest session login"; 352 VLOG(1) << "Completing guest session login";
345 353
346 // For guest session we ask session_manager to restart Chrome with --bwsi 354 // For guest session we ask session_manager to restart Chrome with --bwsi
347 // flag. We keep only some of the arguments of this process. 355 // flag. We keep only some of the arguments of this process.
348 const base::CommandLine& browser_command_line = 356 const base::CommandLine& browser_command_line =
349 *base::CommandLine::ForCurrentProcess(); 357 *base::CommandLine::ForCurrentProcess();
350 base::CommandLine command_line(browser_command_line.GetProgram()); 358 base::CommandLine command_line(browser_command_line.GetProgram());
351 std::string cmd_line_str = 359 std::string cmd_line_str =
352 GetOffTheRecordCommandLine(start_url, 360 GetOffTheRecordCommandLine(start_url,
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // users once it is fully multi-profile aware. http://crbug.com/238987 780 // users once it is fully multi-profile aware. http://crbug.com/238987
773 // For now if we have other user pending sessions they'll override OAuth 781 // For now if we have other user pending sessions they'll override OAuth
774 // session restore for previous users. 782 // session restore for previous users.
775 RestoreAuthenticationSession(profile); 783 RestoreAuthenticationSession(profile);
776 } 784 }
777 785
778 // Restore other user sessions if any. 786 // Restore other user sessions if any.
779 RestorePendingUserSessions(); 787 RestorePendingUserSessions();
780 } 788 }
781 789
790 void UserSessionManager::OnChildAccountStatusChanged() {
791 ChildAccountService* child_service =
792 ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_);
793 StopStatusObserving();
794
795 if (!child_service)
Marc Treib 2015/03/04 16:31:48 Can this actually happen? If so, add a comment ple
merkulova 2015/03/04 19:06:49 I hope not, this all relies on CAServiceFactory. I
Marc Treib 2015/03/05 10:08:07 It might (or might not) happen in some unit tests;
merkulova 2015/03/10 09:18:22 Done.
796 return;
797 if (!child_service->IsChildAccountStatusKnown()) {
Marc Treib 2015/03/04 16:31:48 DCHECK(child_service->IsChildAccountStatusKnown())
merkulova 2015/03/04 19:06:49 Done.
798 NOTREACHED() << "Child account status was changed to UNKNOWN";
799 } else if (requesting_start_urls_) {
Marc Treib 2015/03/04 16:31:48 I think you can move this block into StopStatusObs
merkulova 2015/03/04 19:06:49 Done.
800 InitializeStartUrls();
801 requesting_start_urls_ = false;
802 }
803 }
804
805 void UserSessionManager::OnStatusObservingCancelled() {
806 StopStatusObserving();
807 if (requesting_start_urls_) {
Marc Treib 2015/03/04 16:31:48 ^^
merkulova 2015/03/04 19:06:49 Done.
808 InitializeStartUrls();
809 requesting_start_urls_ = false;
810 }
811 }
812
813 void UserSessionManager::StopStatusObserving() {
814 if (!profile_fetching_flags_)
815 return;
816 ChildAccountService* child_service =
817 ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_);
818 if (child_service)
819 child_service->RemoveStatusObserver(this);
820 profile_fetching_flags_ = nullptr;
821 }
822
782 void UserSessionManager::CreateUserSession(const UserContext& user_context, 823 void UserSessionManager::CreateUserSession(const UserContext& user_context,
783 bool has_auth_cookies) { 824 bool has_auth_cookies) {
784 user_context_ = user_context; 825 user_context_ = user_context;
785 has_auth_cookies_ = has_auth_cookies; 826 has_auth_cookies_ = has_auth_cookies;
786 InitSessionRestoreStrategy(); 827 InitSessionRestoreStrategy();
787 } 828 }
788 829
789 void UserSessionManager::PreStartSession() { 830 void UserSessionManager::PreStartSession() {
790 // Switch log file as soon as possible. 831 // Switch log file as soon as possible.
791 if (base::SysInfo::IsRunningOnChromeOS()) 832 if (base::SysInfo::IsRunningOnChromeOS())
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 void UserSessionManager::ActivateWizard(const std::string& screen_name) { 1079 void UserSessionManager::ActivateWizard(const std::string& screen_name) {
1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); 1080 LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
1040 CHECK(host); 1081 CHECK(host);
1041 host->StartWizard(screen_name); 1082 host->StartWizard(screen_name);
1042 } 1083 }
1043 1084
1044 void UserSessionManager::InitializeStartUrls() const { 1085 void UserSessionManager::InitializeStartUrls() const {
1045 std::vector<std::string> start_urls; 1086 std::vector<std::string> start_urls;
1046 1087
1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1088 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1089
1048 bool can_show_getstarted_guide = 1090 bool can_show_getstarted_guide =
1049 user_manager->GetActiveUser()->GetType() == 1091 user_manager->GetActiveUser()->GetType() ==
1050 user_manager::USER_TYPE_REGULAR && 1092 user_manager::USER_TYPE_REGULAR &&
1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); 1093 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral();
1094
1052 // Skip the default first-run behavior for public accounts. 1095 // Skip the default first-run behavior for public accounts.
1053 if (!user_manager->IsLoggedInAsPublicAccount()) { 1096 if (!user_manager->IsLoggedInAsPublicAccount()) {
1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { 1097 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
1055 const char* url = kChromeVoxTutorialURLPattern; 1098 const char* url = kChromeVoxTutorialURLPattern;
1056 PrefService* prefs = g_browser_process->local_state(); 1099 PrefService* prefs = g_browser_process->local_state();
1057 const std::string current_locale = 1100 const std::string current_locale =
1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); 1101 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); 1102 std::string vox_url = base::StringPrintf(url, current_locale.c_str());
1060 start_urls.push_back(vox_url); 1103 start_urls.push_back(vox_url);
1061 can_show_getstarted_guide = false; 1104 can_show_getstarted_guide = false;
(...skipping 11 matching lines...) Expand all
1073 ::switches::kSilentLaunch); 1116 ::switches::kSilentLaunch);
1074 first_run::MaybeLaunchDialogAfterSessionStart(); 1117 first_run::MaybeLaunchDialogAfterSessionStart();
1075 } else { 1118 } else {
1076 for (size_t i = 0; i < start_urls.size(); ++i) { 1119 for (size_t i = 0; i < start_urls.size(); ++i) {
1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); 1120 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
1078 } 1121 }
1079 } 1122 }
1080 } 1123 }
1081 1124
1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { 1125 bool UserSessionManager::InitializeUserSession(Profile* profile) {
1126 ChildAccountService* child_service =
1127 ChildAccountServiceFactory::GetForProfile(profile);
1128 if (child_service)
Marc Treib 2015/03/04 16:31:48 Here too: Can this actually happen?
merkulova 2015/03/04 19:06:49 I hope no. It all relies on CAServiceFactory. If i
Marc Treib 2015/03/05 10:08:07 Yup, please remove :)
merkulova 2015/03/10 09:18:22 Done.
1129 child_service->AddStatusObserver(this);
1130 base::MessageLoopProxy::current()->PostDelayedTask(
1131 FROM_HERE,
1132 base::Bind(&UserSessionManager::OnStatusObservingCancelled,
1133 weak_factory_.GetWeakPtr()),
1134 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs));
1135 profile_fetching_flags_ = profile;
1136
1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1137 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1084 1138
1085 // Kiosk apps has their own session initialization pipeline. 1139 // Kiosk apps has their own session initialization pipeline.
1086 if (user_manager->IsLoggedInAsKioskApp()) 1140 if (user_manager->IsLoggedInAsKioskApp())
1087 return false; 1141 return false;
1088 1142
1089 if (start_session_type_ == PRIMARY_USER_SESSION) { 1143 if (start_session_type_ == PRIMARY_USER_SESSION) {
1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); 1144 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow();
1091 WizardController* oobe_controller = WizardController::default_controller(); 1145 WizardController* oobe_controller = WizardController::default_controller();
1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 1146 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
1093 bool skip_post_login_screens = 1147 bool skip_post_login_screens =
1094 user_flow->ShouldSkipPostLoginScreens() || 1148 user_flow->ShouldSkipPostLoginScreens() ||
1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || 1149 (oobe_controller && oobe_controller->skip_post_login_screens()) ||
1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); 1150 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin);
1097 1151
1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { 1152 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) {
1099 // Don't specify start URLs if the administrator has configured the start 1153 // Don't specify start URLs if the administrator has configured the start
1100 // URLs via policy. 1154 // URLs via policy.
1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) 1155 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) {
1102 InitializeStartUrls(); 1156 if (child_service && child_service->IsChildAccountStatusKnown())
1157 InitializeStartUrls();
1158 else
1159 requesting_start_urls_ = true;
1160 }
1103 1161
1104 // Mark the device as registered., i.e. the second part of OOBE as 1162 // Mark the device as registered., i.e. the second part of OOBE as
1105 // completed. 1163 // completed.
1106 if (!StartupUtils::IsDeviceRegistered()) 1164 if (!StartupUtils::IsDeviceRegistered())
1107 StartupUtils::MarkDeviceRegistered(base::Closure()); 1165 StartupUtils::MarkDeviceRegistered(base::Closure());
1108 1166
1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); 1167 ActivateWizard(WizardController::kTermsOfServiceScreenName);
1110 return false; 1168 return false;
1111 } 1169 }
1112 } 1170 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 default_ime_states_.erase(profile); 1600 default_ime_states_.erase(profile);
1543 } 1601 }
1544 1602
1545 void UserSessionManager::InjectStubUserContext( 1603 void UserSessionManager::InjectStubUserContext(
1546 const UserContext& user_context) { 1604 const UserContext& user_context) {
1547 injected_user_context_.reset(new UserContext(user_context)); 1605 injected_user_context_.reset(new UserContext(user_context));
1548 authenticator_ = NULL; 1606 authenticator_ = NULL;
1549 } 1607 }
1550 1608
1551 } // namespace chromeos 1609 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698