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

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: Clean-up. 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 15 matching lines...) Expand all
93 #include "content/public/browser/browser_thread.h" 95 #include "content/public/browser/browser_thread.h"
94 #include "content/public/browser/notification_service.h" 96 #include "content/public/browser/notification_service.h"
95 #include "content/public/browser/storage_partition.h" 97 #include "content/public/browser/storage_partition.h"
96 #include "ui/base/ime/chromeos/input_method_manager.h" 98 #include "ui/base/ime/chromeos/input_method_manager.h"
97 #include "url/gurl.h" 99 #include "url/gurl.h"
98 100
99 namespace chromeos { 101 namespace chromeos {
100 102
101 namespace { 103 namespace {
102 104
105 // Milliseconds until we timeout our attempt to fetch flags from Child Account
Bernhard Bauer 2015/03/10 09:55:12 Nit: Child Account Service is not a common name, s
merkulova 2015/03/10 11:53:57 Done.
106 // Service.
107 static const int kFlagsFetchingLoginTimeoutMs = 1000;
108
103 // ChromeVox tutorial URL (used in place of "getting started" url when 109 // ChromeVox tutorial URL (used in place of "getting started" url when
104 // accessibility is enabled). 110 // accessibility is enabled).
105 const char kChromeVoxTutorialURLPattern[] = 111 const char kChromeVoxTutorialURLPattern[] =
106 "http://www.chromevox.com/tutorial/index.html?lang=%s"; 112 "http://www.chromevox.com/tutorial/index.html?lang=%s";
107 113
108 void InitLocaleAndInputMethodsForNewUser( 114 void InitLocaleAndInputMethodsForNewUser(
109 UserSessionManager* session_manager, 115 UserSessionManager* session_manager,
110 Profile* profile, 116 Profile* profile,
111 const std::string& public_session_locale, 117 const std::string& public_session_locale,
112 const std::string& public_session_input_method) { 118 const std::string& public_session_input_method) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 true /* path is absolute */, 312 true /* path is absolute */,
307 false /* don't create */); 313 false /* don't create */);
308 } 314 }
309 } 315 }
310 } 316 }
311 317
312 // static 318 // static
313 void UserSessionManager::RegisterPrefs(PrefRegistrySimple* registry) { 319 void UserSessionManager::RegisterPrefs(PrefRegistrySimple* registry) {
314 registry->RegisterStringPref(prefs::kRLZBrand, std::string()); 320 registry->RegisterStringPref(prefs::kRLZBrand, std::string());
315 registry->RegisterBooleanPref(prefs::kRLZDisabled, false); 321 registry->RegisterBooleanPref(prefs::kRLZDisabled, false);
322 registry->RegisterBooleanPref(prefs::kChildAccountStatusKnown, false);
Bernhard Bauer 2015/03/10 09:55:12 So who registers this pref? UserSessionManager or
merkulova 2015/03/10 11:53:57 ChildAccountService.
316 } 323 }
317 324
318 UserSessionManager::UserSessionManager() 325 UserSessionManager::UserSessionManager()
319 : delegate_(nullptr), 326 : delegate_(nullptr),
320 authenticator_(nullptr), 327 authenticator_(nullptr),
321 has_auth_cookies_(false), 328 has_auth_cookies_(false),
322 user_sessions_restored_(false), 329 user_sessions_restored_(false),
323 user_sessions_restore_in_progress_(false), 330 user_sessions_restore_in_progress_(false),
324 exit_after_session_restore_(false), 331 exit_after_session_restore_(false),
325 session_restore_strategy_( 332 session_restore_strategy_(
326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), 333 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN),
327 running_easy_unlock_key_ops_(false), 334 running_easy_unlock_key_ops_(false),
328 should_launch_browser_(true) { 335 should_launch_browser_(true),
336 init_start_urls_was_postponed_(false),
337 profile_fetching_flags_(nullptr),
338 weak_factory_(this) {
329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 339 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
330 user_manager::UserManager::Get()->AddSessionStateObserver(this); 340 user_manager::UserManager::Get()->AddSessionStateObserver(this);
331 } 341 }
332 342
333 UserSessionManager::~UserSessionManager() { 343 UserSessionManager::~UserSessionManager() {
334 // UserManager is destroyed before singletons, so we need to check if it 344 // UserManager is destroyed before singletons, so we need to check if it
335 // still exists. 345 // still exists.
336 // TODO(nkostylev): fix order of destruction of UserManager 346 // TODO(nkostylev): fix order of destruction of UserManager
337 // / UserSessionManager objects. 347 // / UserSessionManager objects.
338 if (user_manager::UserManager::IsInitialized()) 348 if (user_manager::UserManager::IsInitialized())
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // users once it is fully multi-profile aware. http://crbug.com/238987 782 // 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 783 // For now if we have other user pending sessions they'll override OAuth
774 // session restore for previous users. 784 // session restore for previous users.
775 RestoreAuthenticationSession(profile); 785 RestoreAuthenticationSession(profile);
776 } 786 }
777 787
778 // Restore other user sessions if any. 788 // Restore other user sessions if any.
779 RestorePendingUserSessions(); 789 RestorePendingUserSessions();
780 } 790 }
781 791
792 void UserSessionManager::OnChildAccountStatusChanged(bool is_child) {
793 StopStatusObserving();
794 }
795
796 void UserSessionManager::StopStatusObserving() {
797 if (!profile_fetching_flags_)
798 return;
799 ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_)->
800 RemoveStatusObserver(this);
801 profile_fetching_flags_ = nullptr;
802
803 if (init_start_urls_was_postponed_) {
804 InitializeStartUrls();
805 init_start_urls_was_postponed_ = false;
806 }
807 }
808
782 void UserSessionManager::CreateUserSession(const UserContext& user_context, 809 void UserSessionManager::CreateUserSession(const UserContext& user_context,
783 bool has_auth_cookies) { 810 bool has_auth_cookies) {
784 user_context_ = user_context; 811 user_context_ = user_context;
785 has_auth_cookies_ = has_auth_cookies; 812 has_auth_cookies_ = has_auth_cookies;
786 InitSessionRestoreStrategy(); 813 InitSessionRestoreStrategy();
787 } 814 }
788 815
789 void UserSessionManager::PreStartSession() { 816 void UserSessionManager::PreStartSession() {
790 // Switch log file as soon as possible. 817 // Switch log file as soon as possible.
791 if (base::SysInfo::IsRunningOnChromeOS()) 818 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) { 1065 void UserSessionManager::ActivateWizard(const std::string& screen_name) {
1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); 1066 LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
1040 CHECK(host); 1067 CHECK(host);
1041 host->StartWizard(screen_name); 1068 host->StartWizard(screen_name);
1042 } 1069 }
1043 1070
1044 void UserSessionManager::InitializeStartUrls() const { 1071 void UserSessionManager::InitializeStartUrls() const {
1045 std::vector<std::string> start_urls; 1072 std::vector<std::string> start_urls;
1046 1073
1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1074 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1075
1048 bool can_show_getstarted_guide = 1076 bool can_show_getstarted_guide =
1049 user_manager->GetActiveUser()->GetType() == 1077 user_manager->GetActiveUser()->GetType() ==
1050 user_manager::USER_TYPE_REGULAR && 1078 user_manager::USER_TYPE_REGULAR &&
1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); 1079 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral();
1080
1052 // Skip the default first-run behavior for public accounts. 1081 // Skip the default first-run behavior for public accounts.
1053 if (!user_manager->IsLoggedInAsPublicAccount()) { 1082 if (!user_manager->IsLoggedInAsPublicAccount()) {
1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { 1083 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
1055 const char* url = kChromeVoxTutorialURLPattern; 1084 const char* url = kChromeVoxTutorialURLPattern;
1056 PrefService* prefs = g_browser_process->local_state(); 1085 PrefService* prefs = g_browser_process->local_state();
1057 const std::string current_locale = 1086 const std::string current_locale =
1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); 1087 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); 1088 std::string vox_url = base::StringPrintf(url, current_locale.c_str());
1060 start_urls.push_back(vox_url); 1089 start_urls.push_back(vox_url);
1061 can_show_getstarted_guide = false; 1090 can_show_getstarted_guide = false;
(...skipping 11 matching lines...) Expand all
1073 ::switches::kSilentLaunch); 1102 ::switches::kSilentLaunch);
1074 first_run::MaybeLaunchDialogAfterSessionStart(); 1103 first_run::MaybeLaunchDialogAfterSessionStart();
1075 } else { 1104 } else {
1076 for (size_t i = 0; i < start_urls.size(); ++i) { 1105 for (size_t i = 0; i < start_urls.size(); ++i) {
1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); 1106 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
1078 } 1107 }
1079 } 1108 }
1080 } 1109 }
1081 1110
1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { 1111 bool UserSessionManager::InitializeUserSession(Profile* profile) {
1112 ChildAccountService* child_service =
1113 ChildAccountServiceFactory::GetForProfile(profile);
1114 child_service->AddStatusObserver(this);
1115 base::MessageLoopProxy::current()->PostDelayedTask(
1116 FROM_HERE,
1117 base::Bind(&UserSessionManager::StopStatusObserving,
1118 weak_factory_.GetWeakPtr()),
1119 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs));
1120 profile_fetching_flags_ = profile;
1121
1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1122 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1084 1123
1085 // Kiosk apps has their own session initialization pipeline. 1124 // Kiosk apps has their own session initialization pipeline.
1086 if (user_manager->IsLoggedInAsKioskApp()) 1125 if (user_manager->IsLoggedInAsKioskApp())
1087 return false; 1126 return false;
1088 1127
1089 if (start_session_type_ == PRIMARY_USER_SESSION) { 1128 if (start_session_type_ == PRIMARY_USER_SESSION) {
1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); 1129 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow();
1091 WizardController* oobe_controller = WizardController::default_controller(); 1130 WizardController* oobe_controller = WizardController::default_controller();
1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 1131 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
1093 bool skip_post_login_screens = 1132 bool skip_post_login_screens =
1094 user_flow->ShouldSkipPostLoginScreens() || 1133 user_flow->ShouldSkipPostLoginScreens() ||
1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || 1134 (oobe_controller && oobe_controller->skip_post_login_screens()) ||
1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); 1135 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin);
1097 1136
1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { 1137 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) {
1099 // Don't specify start URLs if the administrator has configured the start 1138 // Don't specify start URLs if the administrator has configured the start
1100 // URLs via policy. 1139 // URLs via policy.
1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) 1140 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) {
1102 InitializeStartUrls(); 1141 if (child_service->IsChildAccountStatusKnown())
1142 InitializeStartUrls();
1143 else
1144 init_start_urls_was_postponed_ = true;
1145 }
1103 1146
1104 // Mark the device as registered., i.e. the second part of OOBE as 1147 // Mark the device as registered., i.e. the second part of OOBE as
1105 // completed. 1148 // completed.
1106 if (!StartupUtils::IsDeviceRegistered()) 1149 if (!StartupUtils::IsDeviceRegistered())
1107 StartupUtils::MarkDeviceRegistered(base::Closure()); 1150 StartupUtils::MarkDeviceRegistered(base::Closure());
1108 1151
1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); 1152 ActivateWizard(WizardController::kTermsOfServiceScreenName);
1110 return false; 1153 return false;
1111 } 1154 }
1112 } 1155 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 default_ime_states_.erase(profile); 1578 default_ime_states_.erase(profile);
1536 } 1579 }
1537 1580
1538 void UserSessionManager::InjectStubUserContext( 1581 void UserSessionManager::InjectStubUserContext(
1539 const UserContext& user_context) { 1582 const UserContext& user_context) {
1540 injected_user_context_.reset(new UserContext(user_context)); 1583 injected_user_context_.reset(new UserContext(user_context));
1541 authenticator_ = NULL; 1584 authenticator_ = NULL;
1542 } 1585 }
1543 1586
1544 } // namespace chromeos 1587 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698