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

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: Rebase. 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 the child
106 // account 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 UserSessionManager::UserSessionManager() 324 UserSessionManager::UserSessionManager()
319 : delegate_(nullptr), 325 : delegate_(nullptr),
320 authenticator_(nullptr), 326 authenticator_(nullptr),
321 has_auth_cookies_(false), 327 has_auth_cookies_(false),
322 user_sessions_restored_(false), 328 user_sessions_restored_(false),
323 user_sessions_restore_in_progress_(false), 329 user_sessions_restore_in_progress_(false),
324 exit_after_session_restore_(false), 330 exit_after_session_restore_(false),
325 session_restore_strategy_( 331 session_restore_strategy_(
326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), 332 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN),
327 running_easy_unlock_key_ops_(false), 333 running_easy_unlock_key_ops_(false),
328 should_launch_browser_(true) { 334 should_launch_browser_(true),
335 waiting_for_child_account_status_(false),
336 weak_factory_(this) {
329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 337 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
330 user_manager::UserManager::Get()->AddSessionStateObserver(this); 338 user_manager::UserManager::Get()->AddSessionStateObserver(this);
331 } 339 }
332 340
333 UserSessionManager::~UserSessionManager() { 341 UserSessionManager::~UserSessionManager() {
334 // UserManager is destroyed before singletons, so we need to check if it 342 // UserManager is destroyed before singletons, so we need to check if it
335 // still exists. 343 // still exists.
336 // TODO(nkostylev): fix order of destruction of UserManager 344 // TODO(nkostylev): fix order of destruction of UserManager
337 // / UserSessionManager objects. 345 // / UserSessionManager objects.
338 if (user_manager::UserManager::IsInitialized()) 346 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 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::ChildAccountStatusReceivedCallback() {
791 StopChildStatusObserving();
792 }
793
794 void UserSessionManager::StopChildStatusObserving() {
795 if (!waiting_for_child_account_status_) {
796 InitializeStartUrls();
797 waiting_for_child_account_status_ = false;
798 }
799 }
800
782 void UserSessionManager::CreateUserSession(const UserContext& user_context, 801 void UserSessionManager::CreateUserSession(const UserContext& user_context,
783 bool has_auth_cookies) { 802 bool has_auth_cookies) {
784 user_context_ = user_context; 803 user_context_ = user_context;
785 has_auth_cookies_ = has_auth_cookies; 804 has_auth_cookies_ = has_auth_cookies;
786 InitSessionRestoreStrategy(); 805 InitSessionRestoreStrategy();
787 } 806 }
788 807
789 void UserSessionManager::PreStartSession() { 808 void UserSessionManager::PreStartSession() {
790 // Switch log file as soon as possible. 809 // Switch log file as soon as possible.
791 if (base::SysInfo::IsRunningOnChromeOS()) 810 if (base::SysInfo::IsRunningOnChromeOS())
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 delegate_->OnProfilePrepared(profile, browser_launched); 1054 delegate_->OnProfilePrepared(profile, browser_launched);
1036 } 1055 }
1037 1056
1038 void UserSessionManager::ActivateWizard(const std::string& screen_name) { 1057 void UserSessionManager::ActivateWizard(const std::string& screen_name) {
1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); 1058 LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
1040 CHECK(host); 1059 CHECK(host);
1041 host->StartWizard(screen_name); 1060 host->StartWizard(screen_name);
1042 } 1061 }
1043 1062
1044 void UserSessionManager::InitializeStartUrls() const { 1063 void UserSessionManager::InitializeStartUrls() const {
1064 // Child account status should be known by the time of this call.
1045 std::vector<std::string> start_urls; 1065 std::vector<std::string> start_urls;
1046 1066
1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1067 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1068
1048 bool can_show_getstarted_guide = 1069 bool can_show_getstarted_guide =
1049 user_manager->GetActiveUser()->GetType() == 1070 user_manager->GetActiveUser()->GetType() ==
1050 user_manager::USER_TYPE_REGULAR && 1071 user_manager::USER_TYPE_REGULAR &&
1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); 1072 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral();
1073
1052 // Skip the default first-run behavior for public accounts. 1074 // Skip the default first-run behavior for public accounts.
1053 if (!user_manager->IsLoggedInAsPublicAccount()) { 1075 if (!user_manager->IsLoggedInAsPublicAccount()) {
1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { 1076 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
1055 const char* url = kChromeVoxTutorialURLPattern; 1077 const char* url = kChromeVoxTutorialURLPattern;
1056 PrefService* prefs = g_browser_process->local_state(); 1078 PrefService* prefs = g_browser_process->local_state();
1057 const std::string current_locale = 1079 const std::string current_locale =
1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); 1080 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); 1081 std::string vox_url = base::StringPrintf(url, current_locale.c_str());
1060 start_urls.push_back(vox_url); 1082 start_urls.push_back(vox_url);
1061 can_show_getstarted_guide = false; 1083 can_show_getstarted_guide = false;
(...skipping 11 matching lines...) Expand all
1073 ::switches::kSilentLaunch); 1095 ::switches::kSilentLaunch);
1074 first_run::MaybeLaunchDialogAfterSessionStart(); 1096 first_run::MaybeLaunchDialogAfterSessionStart();
1075 } else { 1097 } else {
1076 for (size_t i = 0; i < start_urls.size(); ++i) { 1098 for (size_t i = 0; i < start_urls.size(); ++i) {
1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); 1099 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
1078 } 1100 }
1079 } 1101 }
1080 } 1102 }
1081 1103
1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { 1104 bool UserSessionManager::InitializeUserSession(Profile* profile) {
1105 ChildAccountService* child_service =
1106 ChildAccountServiceFactory::GetForProfile(profile);
1107 child_service->AddChildStatusReceivedCallback(base::Bind(
1108 &UserSessionManager::ChildAccountStatusReceivedCallback,
1109 weak_factory_.GetWeakPtr()));
1110 base::MessageLoopProxy::current()->PostDelayedTask(
1111 FROM_HERE,
1112 base::Bind(&UserSessionManager::StopChildStatusObserving,
1113 weak_factory_.GetWeakPtr()),
1114 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs));
1115
1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1116 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1084 1117
1085 // Kiosk apps has their own session initialization pipeline. 1118 // Kiosk apps has their own session initialization pipeline.
1086 if (user_manager->IsLoggedInAsKioskApp()) 1119 if (user_manager->IsLoggedInAsKioskApp())
1087 return false; 1120 return false;
1088 1121
1089 if (start_session_type_ == PRIMARY_USER_SESSION) { 1122 if (start_session_type_ == PRIMARY_USER_SESSION) {
1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); 1123 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow();
1091 WizardController* oobe_controller = WizardController::default_controller(); 1124 WizardController* oobe_controller = WizardController::default_controller();
1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 1125 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
1093 bool skip_post_login_screens = 1126 bool skip_post_login_screens =
1094 user_flow->ShouldSkipPostLoginScreens() || 1127 user_flow->ShouldSkipPostLoginScreens() ||
1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || 1128 (oobe_controller && oobe_controller->skip_post_login_screens()) ||
1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); 1129 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin);
1097 1130
1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { 1131 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) {
1099 // Don't specify start URLs if the administrator has configured the start 1132 // Don't specify start URLs if the administrator has configured the start
1100 // URLs via policy. 1133 // URLs via policy.
1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) 1134 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) {
1102 InitializeStartUrls(); 1135 if (child_service->IsChildAccountStatusKnown())
1136 InitializeStartUrls();
1137 else
1138 waiting_for_child_account_status_ = true;
1139 }
1103 1140
1104 // Mark the device as registered., i.e. the second part of OOBE as 1141 // Mark the device as registered., i.e. the second part of OOBE as
1105 // completed. 1142 // completed.
1106 if (!StartupUtils::IsDeviceRegistered()) 1143 if (!StartupUtils::IsDeviceRegistered())
1107 StartupUtils::MarkDeviceRegistered(base::Closure()); 1144 StartupUtils::MarkDeviceRegistered(base::Closure());
1108 1145
1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); 1146 ActivateWizard(WizardController::kTermsOfServiceScreenName);
1110 return false; 1147 return false;
1111 } 1148 }
1112 } 1149 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 default_ime_states_.erase(profile); 1572 default_ime_states_.erase(profile);
1536 } 1573 }
1537 1574
1538 void UserSessionManager::InjectStubUserContext( 1575 void UserSessionManager::InjectStubUserContext(
1539 const UserContext& user_context) { 1576 const UserContext& user_context) {
1540 injected_user_context_.reset(new UserContext(user_context)); 1577 injected_user_context_.reset(new UserContext(user_context));
1541 authenticator_ = NULL; 1578 authenticator_ = NULL;
1542 } 1579 }
1543 1580
1544 } // namespace chromeos 1581 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/session/user_session_manager.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698