Index: chrome/browser/chromeos/login/session/user_session_manager.cc |
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc |
index 246f4880e0b3262da320c88309bf6d33c15c55fb..8cfd62a92adb7cc332f5e3742a93290aa8a05f1d 100644 |
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc |
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc |
@@ -65,6 +65,8 @@ |
#include "chrome/browser/signin/account_tracker_service_factory.h" |
#include "chrome/browser/signin/easy_unlock_service.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
+#include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
+#include "chrome/browser/supervised_user/child_accounts/child_account_service_factory.h" |
#include "chrome/browser/ui/app_list/start_page_service.h" |
#include "chrome/browser/ui/startup/startup_browser_creator.h" |
#include "chrome/common/chrome_switches.h" |
@@ -325,7 +327,11 @@ UserSessionManager::UserSessionManager() |
session_restore_strategy_( |
OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), |
running_easy_unlock_key_ops_(false), |
- should_launch_browser_(true) { |
+ should_launch_browser_(true), |
+ flags_fetching_ended_(false), |
+ requesting_start_urls_(false), |
+ profile_fetching_flags_(nullptr), |
+ weak_factory_(this) { |
net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
user_manager::UserManager::Get()->AddSessionStateObserver(this); |
} |
@@ -340,6 +346,9 @@ UserSessionManager::~UserSessionManager() { |
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
} |
+// static |
+const int UserSessionManager::kFlagsFetchingLoginTimeoutMs = 1000; |
+ |
void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) { |
VLOG(1) << "Completing guest session login"; |
@@ -779,6 +788,29 @@ void UserSessionManager::OnProfilePrepared(Profile* profile, |
RestorePendingUserSessions(); |
} |
+void UserSessionManager::OnFlagsFetchingError() { |
+ FlagsFetchingStopped(); |
+} |
+ |
+void UserSessionManager::OnFlagsFetchingCancelled() { |
+ FlagsFetchingStopped(); |
+} |
+ |
+void UserSessionManager::OnFlagsFetchingCompleted(bool is_child_account) { |
+ FlagsFetchingStopped(); |
+} |
+ |
+void UserSessionManager::FlagsFetchingStopped() { |
+ flags_fetching_ended_ = true; |
+ if (requesting_start_urls_) { |
+ InitializeStartUrls(); |
+ requesting_start_urls_ = false; |
+ } |
+ ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_)-> |
+ RemoveFlagFetchingObserver(this); |
+ profile_fetching_flags_ = nullptr; |
+} |
+ |
void UserSessionManager::CreateUserSession(const UserContext& user_context, |
bool has_auth_cookies) { |
user_context_ = user_context; |
@@ -1045,10 +1077,12 @@ void UserSessionManager::InitializeStartUrls() const { |
std::vector<std::string> start_urls; |
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
+ |
bool can_show_getstarted_guide = |
user_manager->GetActiveUser()->GetType() == |
user_manager::USER_TYPE_REGULAR && |
!user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
+ |
// Skip the default first-run behavior for public accounts. |
if (!user_manager->IsLoggedInAsPublicAccount()) { |
if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
@@ -1080,6 +1114,15 @@ void UserSessionManager::InitializeStartUrls() const { |
} |
bool UserSessionManager::InitializeUserSession(Profile* profile) { |
+ ChildAccountServiceFactory::GetForProfile(profile)-> |
+ AddFlagFetchingObserver(this); |
Marc Treib
2015/03/04 09:59:15
Could the "is child account" status already be kno
merkulova
2015/03/04 10:06:27
Yes, it might be already know. Then we wait for th
Marc Treib
2015/03/04 10:17:53
Then I'd add an "IsChildAccountStatusKnown" method
merkulova
2015/03/04 14:55:11
Done.
|
+ base::MessageLoopProxy::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&UserSessionManager::OnFlagsFetchingCancelled, |
+ weak_factory_.GetWeakPtr()), |
+ base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs)); |
+ profile_fetching_flags_ = profile; |
+ |
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
// Kiosk apps has their own session initialization pipeline. |
@@ -1098,8 +1141,12 @@ bool UserSessionManager::InitializeUserSession(Profile* profile) { |
if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { |
// Don't specify start URLs if the administrator has configured the start |
// URLs via policy. |
- if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
- InitializeStartUrls(); |
+ if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) { |
+ if (flags_fetching_ended_) |
+ InitializeStartUrls(); |
+ else |
+ requesting_start_urls_ = true; |
+ } |
// Mark the device as registered., i.e. the second part of OOBE as |
// completed. |