Chromium Code Reviews| 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 0505daf8f72b899444083668d01698bbc4bb5797..51e854c4f8cce271f0da8b3dc130a24e1835bc00 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/message_loop.h" |
| #include "base/stringprintf.h" |
| @@ -12,6 +13,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" |
| @@ -23,7 +25,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" |
| @@ -77,8 +78,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; |
| @@ -92,20 +93,29 @@ 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; |
| + |
| + user_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| + &show_users_on_signin); |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
We have a long-standing bug about this value being
pastarmovj
2011/09/23 15:19:32
Actually CrosSettings supports observer interface
|
| + if (show_users_on_signin) { |
| + bool allow_new_user = false; |
| + const 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) { |
| // 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(StringValue(users[i].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); |
| @@ -229,15 +239,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())); |
|
Denis Lagno
2011/09/22 13:54:05
Are you really sure that this one still works as e
pastarmovj
2011/09/23 15:19:32
The Closure will take care of not calling run on a
|
| 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; |
| } |
| @@ -326,7 +339,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); |
| @@ -464,10 +479,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. |
| @@ -570,9 +586,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. |
| @@ -580,8 +597,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); |
| } |
| } |