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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 656283002: [session_manager] Move user session initialization code out of ExistingUserController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move first run session init and browser launch out of EUC Created 6 years, 2 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 (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/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 20 #include "base/values.h"
22 #include "base/version.h" 21 #include "base/version.h"
23 #include "chrome/browser/accessibility/accessibility_events.h" 22 #include "chrome/browser/accessibility/accessibility_events.h"
24 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_process_platform_part.h" 24 #include "chrome/browser/browser_process_platform_part.h"
26 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
28 #include "chrome/browser/chromeos/boot_times_loader.h" 26 #include "chrome/browser/chromeos/boot_times_loader.h"
29 #include "chrome/browser/chromeos/customization_document.h" 27 #include "chrome/browser/chromeos/customization_document.h"
30 #include "chrome/browser/chromeos/first_run/first_run.h"
31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
32 #include "chrome/browser/chromeos/login/helper.h" 29 #include "chrome/browser/chromeos/login/helper.h"
33 #include "chrome/browser/chromeos/login/login_utils.h" 30 #include "chrome/browser/chromeos/login/login_utils.h"
34 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 31 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
35 #include "chrome/browser/chromeos/login/startup_utils.h" 32 #include "chrome/browser/chromeos/login/startup_utils.h"
36 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 33 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
37 #include "chrome/browser/chromeos/login/user_flow.h" 34 #include "chrome/browser/chromeos/login/user_flow.h"
38 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 35 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
39 #include "chrome/browser/chromeos/login/wizard_controller.h" 36 #include "chrome/browser/chromeos/login/wizard_controller.h"
40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
41 #include "chrome/browser/chromeos/policy/device_local_account.h" 38 #include "chrome/browser/chromeos/policy/device_local_account.h"
42 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 39 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
43 #include "chrome/browser/chromeos/profiles/profile_helper.h" 40 #include "chrome/browser/chromeos/profiles/profile_helper.h"
44 #include "chrome/browser/chromeos/settings/cros_settings.h" 41 #include "chrome/browser/chromeos/settings/cros_settings.h"
45 #include "chrome/browser/prefs/session_startup_pref.h"
46 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" 42 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
47 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/chrome_version_info.h" 44 #include "chrome/common/chrome_version_info.h"
49 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
50 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
51 #include "chrome/grit/generated_resources.h" 47 #include "chrome/grit/generated_resources.h"
52 #include "chromeos/chromeos_switches.h" 48 #include "chromeos/chromeos_switches.h"
53 #include "chromeos/dbus/dbus_thread_manager.h" 49 #include "chromeos/dbus/dbus_thread_manager.h"
54 #include "chromeos/dbus/power_manager_client.h" 50 #include "chromeos/dbus/power_manager_client.h"
55 #include "chromeos/dbus/session_manager_client.h" 51 #include "chromeos/dbus/session_manager_client.h"
(...skipping 25 matching lines...) Expand all
81 #include "ui/views/widget/widget.h" 77 #include "ui/views/widget/widget.h"
82 78
83 namespace chromeos { 79 namespace chromeos {
84 80
85 namespace { 81 namespace {
86 82
87 // URL for account creation. 83 // URL for account creation.
88 const char kCreateAccountURL[] = 84 const char kCreateAccountURL[] =
89 "https://accounts.google.com/NewAccount?service=mail"; 85 "https://accounts.google.com/NewAccount?service=mail";
90 86
91 // ChromeVox tutorial URL (used in place of "getting started" url when
92 // accessibility is enabled).
93 const char kChromeVoxTutorialURLPattern[] =
94 "http://www.chromevox.com/tutorial/index.html?lang=%s";
95
96 // Delay for transferring the auth cache to the system profile. 87 // Delay for transferring the auth cache to the system profile.
97 const long int kAuthCacheTransferDelayMs = 2000; 88 const long int kAuthCacheTransferDelayMs = 2000;
98 89
99 // Delay for restarting the ui if safe-mode login has failed. 90 // Delay for restarting the ui if safe-mode login has failed.
100 const long int kSafeModeRestartUiDelayMs = 30000; 91 const long int kSafeModeRestartUiDelayMs = 30000;
101 92
102 // Makes a call to the policy subsystem to reload the policy when we detect 93 // Makes a call to the policy subsystem to reload the policy when we detect
103 // authentication change. 94 // authentication change.
104 void RefreshPoliciesOnUIThread() { 95 void RefreshPoliciesOnUIThread() {
105 if (g_browser_process->policy_service()) 96 if (g_browser_process->policy_service())
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 this); 859 this);
869 860
870 // Update user's displayed email. 861 // Update user's displayed email.
871 if (!display_email_.empty()) { 862 if (!display_email_.empty()) {
872 user_manager::UserManager::Get()->SaveUserDisplayEmail( 863 user_manager::UserManager::Get()->SaveUserDisplayEmail(
873 user_context.GetUserID(), display_email_); 864 user_context.GetUserID(), display_email_);
874 display_email_.clear(); 865 display_email_.clear();
875 } 866 }
876 } 867 }
877 868
878 void ExistingUserController::OnProfilePrepared(Profile* profile) { 869 void ExistingUserController::OnProfilePrepared(Profile* profile,
870 bool browser_launched) {
879 // Reenable clicking on other windows and status area. 871 // Reenable clicking on other windows and status area.
880 login_display_->SetUIEnabled(true); 872 login_display_->SetUIEnabled(true);
881 873
882 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 874 if (browser_launched)
Nikita (slow) 2014/10/16 11:27:12 This block is moved to SupervisedUserLoginFlow.
883 if (user_manager->IsCurrentUserNew() && 875 host_ = NULL;
884 user_manager->IsLoggedInAsSupervisedUser()) {
885 // Supervised users should launch into empty desktop on first run.
886 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch);
887 }
888 876
889 if (user_manager->IsCurrentUserNew() &&
Nikita (slow) 2014/10/16 11:27:12 This block is moved to UserSessionManager::Initial
890 !ChromeUserManager::Get()
891 ->GetCurrentUserFlow()
892 ->ShouldSkipPostLoginScreens() &&
893 !WizardController::default_controller()->skip_post_login_screens()) {
894 // Don't specify start URLs if the administrator has configured the start
895 // URLs via policy.
896 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs()))
897 InitializeStartUrls();
898
899 // Mark the device as registered., i.e. the second part of OOBE as
900 // completed.
901 if (!StartupUtils::IsDeviceRegistered())
902 StartupUtils::MarkDeviceRegistered(base::Closure());
903
904 if (CommandLine::ForCurrentProcess()->HasSwitch(
905 chromeos::switches::kOobeSkipPostLogin)) {
906 LoginUtils::Get()->DoBrowserLaunch(profile, host_);
907 host_ = NULL;
908 } else {
909 ActivateWizard(WizardController::kTermsOfServiceScreenName);
910 }
911 } else {
912 LoginUtils::Get()->DoBrowserLaunch(profile, host_);
913 host_ = NULL;
914 }
915 // Inform |auth_status_consumer_| about successful login. 877 // Inform |auth_status_consumer_| about successful login.
916 if (auth_status_consumer_) 878 if (auth_status_consumer_)
917 auth_status_consumer_->OnAuthSuccess(UserContext()); 879 auth_status_consumer_->OnAuthSuccess(UserContext());
Denis Kuznetsov (DE-MUC) 2014/10/16 12:21:42 Why do we pass empty user context here, what if co
Nikita (slow) 2014/10/17 13:17:41 Done.
918 } 880 }
919 881
920 void ExistingUserController::OnOffTheRecordAuthSuccess() { 882 void ExistingUserController::OnOffTheRecordAuthSuccess() {
921 is_login_in_progress_ = false; 883 is_login_in_progress_ = false;
922 offline_failed_ = false; 884 offline_failed_ = false;
923 885
924 // Mark the device as registered., i.e. the second part of OOBE as completed. 886 // Mark the device as registered., i.e. the second part of OOBE as completed.
925 if (!StartupUtils::IsDeviceRegistered()) 887 if (!StartupUtils::IsDeviceRegistered())
926 StartupUtils::MarkDeviceRegistered(base::Closure()); 888 StartupUtils::MarkDeviceRegistered(base::Closure());
927 889
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 978
1017 void ExistingUserController::DeviceSettingsChanged() { 979 void ExistingUserController::DeviceSettingsChanged() {
1018 if (host_ != NULL) { 980 if (host_ != NULL) {
1019 // Signed settings or user list changed. Notify views and update them. 981 // Signed settings or user list changed. Notify views and update them.
1020 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers()); 982 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers());
1021 ConfigurePublicSessionAutoLogin(); 983 ConfigurePublicSessionAutoLogin();
1022 return; 984 return;
1023 } 985 }
1024 } 986 }
1025 987
1026 void ExistingUserController::ActivateWizard(const std::string& screen_name) {
1027 scoped_ptr<base::DictionaryValue> params;
1028 host_->StartWizard(screen_name, params.Pass());
1029 }
1030
1031 LoginPerformer::AuthorizationMode ExistingUserController::auth_mode() const { 988 LoginPerformer::AuthorizationMode ExistingUserController::auth_mode() const {
1032 if (login_performer_) 989 if (login_performer_)
1033 return login_performer_->auth_mode(); 990 return login_performer_->auth_mode();
1034 991
1035 return auth_mode_; 992 return auth_mode_;
1036 } 993 }
1037 994
1038 bool ExistingUserController::password_changed() const { 995 bool ExistingUserController::password_changed() const {
1039 if (login_performer_) 996 if (login_performer_)
1040 return login_performer_->password_changed(); 997 return login_performer_->password_changed();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 public_session_auto_login_delay_), 1072 public_session_auto_login_delay_),
1116 base::Bind( 1073 base::Bind(
1117 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, 1074 &ExistingUserController::OnPublicSessionAutoLoginTimerFire,
1118 weak_factory_.GetWeakPtr())); 1075 weak_factory_.GetWeakPtr()));
1119 } 1076 }
1120 1077
1121 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 1078 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
1122 return host_->GetNativeWindow(); 1079 return host_->GetNativeWindow();
1123 } 1080 }
1124 1081
1125 void ExistingUserController::InitializeStartUrls() const {
1126 std::vector<std::string> start_urls;
1127
1128 const base::ListValue *urls;
1129 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1130 bool can_show_getstarted_guide =
1131 user_manager->GetActiveUser()->GetType() ==
1132 user_manager::USER_TYPE_REGULAR &&
1133 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral();
1134 if (user_manager->IsLoggedInAsDemoUser()) {
1135 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) {
1136 // The retail mode user will get start URLs from a special policy if it is
1137 // set.
1138 for (base::ListValue::const_iterator it = urls->begin();
1139 it != urls->end(); ++it) {
1140 std::string url;
1141 if ((*it)->GetAsString(&url))
1142 start_urls.push_back(url);
1143 }
1144 }
1145 can_show_getstarted_guide = false;
1146 // Skip the default first-run behavior for public accounts.
1147 } else if (!user_manager->IsLoggedInAsPublicAccount()) {
1148 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
1149 const char* url = kChromeVoxTutorialURLPattern;
1150 PrefService* prefs = g_browser_process->local_state();
1151 const std::string current_locale =
1152 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
1153 std::string vox_url = base::StringPrintf(url, current_locale.c_str());
1154 start_urls.push_back(vox_url);
1155 can_show_getstarted_guide = false;
1156 }
1157 }
1158
1159 // Only show getting started guide for a new user.
1160 const bool should_show_getstarted_guide = user_manager->IsCurrentUserNew();
1161
1162 if (can_show_getstarted_guide && should_show_getstarted_guide) {
1163 // Don't open default Chrome window if we're going to launch the first-run
1164 // app. Because we dont' want the first-run app to be hidden in the
1165 // background.
1166 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch);
1167 first_run::MaybeLaunchDialogAfterSessionStart();
1168 } else {
1169 for (size_t i = 0; i < start_urls.size(); ++i) {
1170 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
1171 }
1172 }
1173 }
1174
1175 void ExistingUserController::ShowError(int error_id, 1082 void ExistingUserController::ShowError(int error_id,
1176 const std::string& details) { 1083 const std::string& details) {
1177 // TODO(dpolukhin): show detailed error info. |details| string contains 1084 // TODO(dpolukhin): show detailed error info. |details| string contains
1178 // low level error info that is not localized and even is not user friendly. 1085 // low level error info that is not localized and even is not user friendly.
1179 // For now just ignore it because error_text contains all required information 1086 // For now just ignore it because error_text contains all required information
1180 // for end users, developers can see details string in Chrome logs. 1087 // for end users, developers can see details string in Chrome logs.
1181 VLOG(1) << details; 1088 VLOG(1) << details;
1182 HelpAppLauncher::HelpTopic help_topic_id; 1089 HelpAppLauncher::HelpTopic help_topic_id;
1183 bool is_offline = !network_state_helper_->IsConnected(); 1090 bool is_offline = !network_state_helper_->IsConnected();
1184 switch (login_performer_->error().state()) { 1091 switch (login_performer_->error().state()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 // Only one instance of LoginPerformer should exist at a time. 1162 // Only one instance of LoginPerformer should exist at a time.
1256 login_performer_.reset(NULL); 1163 login_performer_.reset(NULL);
1257 login_performer_.reset(new LoginPerformer(this)); 1164 login_performer_.reset(new LoginPerformer(this));
1258 is_login_in_progress_ = true; 1165 is_login_in_progress_ = true;
1259 login_performer_->LoginAsPublicSession(user_context); 1166 login_performer_->LoginAsPublicSession(user_context);
1260 SendAccessibilityAlert( 1167 SendAccessibilityAlert(
1261 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 1168 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
1262 } 1169 }
1263 1170
1264 } // namespace chromeos 1171 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698