| Index: chrome/browser/chromeos/login/existing_user_controller.cc
|
| diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
|
| index 75eefb3f2758c8889114ff71179f0a044db3e6e2..f939fc75f1ead402e2a438036ae6d602c22c81dc 100644
|
| --- a/chrome/browser/chromeos/login/existing_user_controller.cc
|
| +++ b/chrome/browser/chromeos/login/existing_user_controller.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/chromeos/login/existing_user_controller.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| @@ -13,6 +14,7 @@
|
| #include "base/values.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/boot_times_loader.h"
|
| +#include "chrome/browser/chromeos/cros_settings.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/cros/cryptohome_library.h"
|
| #include "chrome/browser/chromeos/cros/login_library.h"
|
| @@ -24,7 +26,6 @@
|
| #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
|
| #include "chrome/browser/chromeos/login/wizard_controller.h"
|
| #include "chrome/browser/chromeos/status/status_area_view.h"
|
| -#include "chrome/browser/chromeos/user_cros_settings_provider.h"
|
| #include "chrome/browser/google/google_util.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -78,8 +79,8 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host)
|
| : login_status_consumer_(NULL),
|
| host_(host),
|
| num_login_attempts_(0),
|
| - user_settings_(new UserCrosSettingsProvider),
|
| - method_factory_(this),
|
| + user_settings_(CrosSettings::Get()),
|
| + pointer_factory_(this),
|
| is_owner_login_(false) {
|
| DCHECK(current_controller_ == NULL);
|
| current_controller_ = this;
|
| @@ -93,20 +94,32 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host)
|
|
|
| void ExistingUserController::Init(const UserVector& users) {
|
| UserVector filtered_users;
|
| - if (UserCrosSettingsProvider::cached_show_users_on_signin()) {
|
| - for (size_t i = 0; i < users.size(); ++i)
|
| + bool show_users_on_signin;
|
| +
|
| + // TODO(pastarmovj): Make this class an observer of the CrosSettings to be
|
| + // able to update the UI whenever policy is loaded.
|
| + user_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
|
| + &show_users_on_signin);
|
| + if (show_users_on_signin) {
|
| + bool allow_new_user = false;
|
| + const base::ListValue *user_list;
|
| + user_settings_->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
|
| + user_settings_->GetList(kAccountsPrefUsers, &user_list);
|
| + for (size_t i = 0; i < users.size(); ++i) {
|
| + base::StringValue email(users[i].email());
|
| // TODO(xiyuan): Clean user profile whose email is not in whitelist.
|
| - if (UserCrosSettingsProvider::cached_allow_new_user() ||
|
| - UserCrosSettingsProvider::IsEmailInCachedWhitelist(
|
| - users[i].email())) {
|
| + if (allow_new_user ||
|
| + user_list->Find(email) != user_list->end()) {
|
| filtered_users.push_back(users[i]);
|
| }
|
| + }
|
| }
|
|
|
| // If no user pods are visible, fallback to single new user pod which will
|
| // have guest session link.
|
| - bool show_guest = UserCrosSettingsProvider::cached_allow_guest() &&
|
| - !filtered_users.empty();
|
| + bool show_guest;
|
| + user_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest);
|
| + show_guest &= !filtered_users.empty();
|
| bool show_new_user = true;
|
| login_display_->set_parent_window(GetNativeWindow());
|
| login_display_->Init(filtered_users, show_guest, show_new_user);
|
| @@ -230,15 +243,18 @@ void ExistingUserController::LoginAsGuest() {
|
|
|
| // Check allow_guest in case this call is fired from key accelerator.
|
| // Must not proceed without signature verification.
|
| - bool trusted_setting_available = user_settings_->RequestTrustedAllowGuest(
|
| - method_factory_.NewRunnableMethod(
|
| - &ExistingUserController::LoginAsGuest));
|
| + bool trusted_setting_available = user_settings_->GetTrusted(
|
| + kAccountsPrefAllowGuest,
|
| + base::Bind(&ExistingUserController::LoginAsGuest,
|
| + pointer_factory_.GetWeakPtr()));
|
| if (!trusted_setting_available) {
|
| // Value of AllowGuest setting is still not verified.
|
| // Another attempt will be invoked again after verification completion.
|
| return;
|
| }
|
| - if (!UserCrosSettingsProvider::cached_allow_guest()) {
|
| + bool allow_guest;
|
| + user_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
|
| + if (!allow_guest) {
|
| // Disallowed.
|
| return;
|
| }
|
| @@ -327,7 +343,9 @@ void ExistingUserController::OnLoginFailure(const LoginFailure& failure) {
|
| // 1. ClientLogin returns ServiceUnavailable code.
|
| // 2. Internet connectivity may be behind the captive portal.
|
| // Suggesting user to try sign in to a portal in Guest mode.
|
| - if (UserCrosSettingsProvider::cached_allow_guest())
|
| + bool allow_guest;
|
| + user_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
|
| + if (allow_guest)
|
| ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL, error);
|
| else
|
| ShowError(IDS_LOGIN_ERROR_CAPTIVE_PORTAL_NO_GUEST_MODE, error);
|
| @@ -468,10 +486,11 @@ void ExistingUserController::OnOffTheRecordLoginSuccess() {
|
| void ExistingUserController::OnPasswordChangeDetected(
|
| const GaiaAuthConsumer::ClientLoginResult& credentials) {
|
| // Must not proceed without signature verification.
|
| - bool trusted_setting_available = user_settings_->RequestTrustedOwner(
|
| - method_factory_.NewRunnableMethod(
|
| - &ExistingUserController::OnPasswordChangeDetected,
|
| - credentials));
|
| + bool trusted_setting_available = user_settings_->GetTrusted(
|
| + kDeviceOwner,
|
| + base::Bind(&ExistingUserController::OnPasswordChangeDetected,
|
| + pointer_factory_.GetWeakPtr(),
|
| + credentials));
|
| if (!trusted_setting_available) {
|
| // Value of owner email is still not verified.
|
| // Another attempt will be invoked after verification completion.
|
| @@ -574,9 +593,10 @@ void ExistingUserController::ShowError(int error_id,
|
| }
|
|
|
| void ExistingUserController::StartAutomaticFreeDiskSpaceControl() {
|
| - bool trusted_owner_available = user_settings_->RequestTrustedOwner(
|
| - method_factory_.NewRunnableMethod(
|
| - &ExistingUserController::StartAutomaticFreeDiskSpaceControl));
|
| + bool trusted_owner_available = user_settings_->GetTrusted(
|
| + kDeviceOwner,
|
| + base::Bind(&ExistingUserController::StartAutomaticFreeDiskSpaceControl,
|
| + pointer_factory_.GetWeakPtr()));
|
| if (!trusted_owner_available) {
|
| // Value of owner email is still not verified.
|
| // Another attempt will be invoked after verification completion.
|
| @@ -584,8 +604,9 @@ void ExistingUserController::StartAutomaticFreeDiskSpaceControl() {
|
| }
|
| if (CrosLibrary::Get()->EnsureLoaded()) {
|
| CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary();
|
| - cryptohomed->AsyncSetOwnerUser(
|
| - UserCrosSettingsProvider::cached_owner(), NULL);
|
| + std::string owner;
|
| + user_settings_->GetString(kDeviceOwner, &owner);
|
| + cryptohomed->AsyncSetOwnerUser(owner, NULL);
|
| cryptohomed->AsyncDoAutomaticFreeDiskSpaceControl(NULL);
|
| }
|
| }
|
|
|