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

Unified Diff: chrome/browser/chromeos/login/login_performer.cc

Issue 7867044: PART1: Initiated the SignedSettings refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up some debug output. Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/login_performer.cc
diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc
index 161684d1d3d2aabd05418575125f039a9c2dceab..d2dd4a19b1d4e981e576c41f4a8e42195d5a5455 100644
--- a/chrome/browser/chromeos/login/login_performer.cc
+++ b/chrome/browser/chromeos/login/login_performer.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -14,11 +15,11 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros_settings.h"
Denis Lagno 2011/09/20 14:05:22 nit: / precedes _ in ASCII order.
pastarmovj 2011/09/20 17:11:52 Done.
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/cros_settings_names.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
-#include "chrome/browser/chromeos/user_cros_settings_provider.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -226,26 +227,6 @@ void LoginPerformer::OnPasswordChangeDetected(
}
////////////////////////////////////////////////////////////////////////////////
-// LoginPerformer, SignedSettingsHelper::Callback implementation:
-
-void LoginPerformer::OnCheckWhitelistCompleted(SignedSettings::ReturnCode code,
- const std::string& email) {
- if (code == SignedSettings::SUCCESS) {
- // Whitelist check passed, continue with authentication.
- if (auth_mode_ == AUTH_MODE_EXTENSION) {
- StartLoginCompletion();
- } else {
- StartAuthentication();
- }
- } else {
- if (delegate_)
- delegate_->WhiteListCheckFailed(email);
- else
- NOTREACHED();
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
// LoginPerformer, NotificationObserver implementation:
//
@@ -273,44 +254,44 @@ void LoginPerformer::CompleteLogin(const std::string& username,
auth_mode_ = AUTH_MODE_EXTENSION;
username_ = username;
password_ = password;
+
+ CrosSettings* cros_settings = CrosSettings::Get();
+
// Whitelist check is always performed during initial login and
// should not be performed when ScreenLock is active (pending online auth).
if (!ScreenLocker::default_screen_locker()) {
- // Must not proceed without signature verification.
- UserCrosSettingsProvider user_settings;
- bool trusted_setting_available = user_settings.RequestTrustedAllowNewUser(
- method_factory_.NewRunnableMethod(&LoginPerformer::CompleteLogin,
- username,
- password));
- if (!trusted_setting_available) {
+ // Must not proceed without signature verification or valid user list.
+ bool trusted_settings_available =
+ cros_settings->GetTrusted(
+ kAccountsPrefAllowNewUser,
+ base::Bind(&LoginPerformer::CompleteLogin, base::Unretained(this),
pastarmovj 2011/09/20 17:11:52 Fixed those too.
+ username, password)) ||
+ cros_settings->GetTrusted(
+ kAccountsPrefAllowNewUser,
+ base::Bind(&LoginPerformer::CompleteLogin, base::Unretained(this),
+ username, password));
+ if (!trusted_settings_available) {
// Value of AllowNewUser setting is still not verified.
// Another attempt will be invoked after verification completion.
return;
}
}
- if (ScreenLocker::default_screen_locker() ||
- UserCrosSettingsProvider::cached_allow_new_user()) {
+ bool allow_new_user = false;
+ cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
+ if (ScreenLocker::default_screen_locker() || allow_new_user) {
// Starts authentication if guest login is allowed or online auth pending.
StartLoginCompletion();
} else {
- // Otherwise, do whitelist check first.
- PrefService* local_state = g_browser_process->local_state();
- CHECK(local_state);
- if (local_state->IsManagedPreference(kAccountsPrefUsers)) {
- if (UserCrosSettingsProvider::IsEmailInCachedWhitelist(username)) {
- StartLoginCompletion();
- } else {
- if (delegate_)
- delegate_->WhiteListCheckFailed(username);
- else
- NOTREACHED();
- }
+ const ListValue *user_list;
+ if (cros_settings->GetList(kAccountsPrefUsers, &user_list) &&
+ user_list->Find(StringValue(username)) != user_list->end()) {
+ StartLoginCompletion();
} else {
- // In case of signed settings: with current implementation we do not
- // trust whitelist returned by PrefService. So make separate check.
- SignedSettingsHelper::Get()->StartCheckWhitelistOp(
- username, this);
+ if (delegate_)
+ delegate_->WhiteListCheckFailed(username);
+ else
+ NOTREACHED();
}
}
}
@@ -321,44 +302,43 @@ void LoginPerformer::Login(const std::string& username,
username_ = username;
password_ = password;
+ CrosSettings* cros_settings = CrosSettings::Get();
+
// Whitelist check is always performed during initial login and
// should not be performed when ScreenLock is active (pending online auth).
if (!ScreenLocker::default_screen_locker()) {
// Must not proceed without signature verification.
- UserCrosSettingsProvider user_settings;
- bool trusted_setting_available = user_settings.RequestTrustedAllowNewUser(
- method_factory_.NewRunnableMethod(&LoginPerformer::Login,
- username,
- password));
- if (!trusted_setting_available) {
+ bool trusted_settings_available =
+ cros_settings->GetTrusted(
+ kAccountsPrefAllowNewUser,
+ base::Bind(&LoginPerformer::CompleteLogin, base::Unretained(this),
+ username, password)) ||
+ cros_settings->GetTrusted(
+ kAccountsPrefAllowNewUser,
+ base::Bind(&LoginPerformer::CompleteLogin, base::Unretained(this),
+ username, password));
+ if (!trusted_settings_available) {
// Value of AllowNewUser setting is still not verified.
// Another attempt will be invoked after verification completion.
return;
}
}
- if (ScreenLocker::default_screen_locker() ||
- UserCrosSettingsProvider::cached_allow_new_user()) {
+ bool allow_new_user = false;
+ cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
+ if (ScreenLocker::default_screen_locker() || allow_new_user) {
// Starts authentication if guest login is allowed or online auth pending.
StartAuthentication();
} else {
- // Otherwise, do whitelist check first.
- PrefService* local_state = g_browser_process->local_state();
- CHECK(local_state);
- if (local_state->IsManagedPreference(kAccountsPrefUsers)) {
- if (UserCrosSettingsProvider::IsEmailInCachedWhitelist(username)) {
- StartAuthentication();
- } else {
- if (delegate_)
- delegate_->WhiteListCheckFailed(username);
- else
- NOTREACHED();
- }
+ const ListValue *user_list;
+ if (cros_settings->GetList(kAccountsPrefUsers, &user_list) &&
+ user_list->Find(StringValue(username)) != user_list->end()) {
+ StartAuthentication();
} else {
- // In case of signed settings: with current implementation we do not
- // trust whitelist returned by PrefService. So make separate check.
- SignedSettingsHelper::Get()->StartCheckWhitelistOp(
- username, this);
+ if (delegate_)
+ delegate_->WhiteListCheckFailed(username);
+ else
+ NOTREACHED();
}
}
}

Powered by Google App Engine
This is Rietveld 408576698