summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/cros/cryptohome_library.cc10
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc8
-rw-r--r--chrome/browser/chromeos/login/password_changed_view.cc33
-rw-r--r--chrome/browser/chromeos/login/password_changed_view.h9
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
6 files changed, 50 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/cros/cryptohome_library.cc b/chrome/browser/chromeos/cros/cryptohome_library.cc
index cd9a31d..bfc8ef1 100644
--- a/chrome/browser/chromeos/cros/cryptohome_library.cc
+++ b/chrome/browser/chromeos/cros/cryptohome_library.cc
@@ -4,10 +4,12 @@
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
+#include "base/command_line.h"
#include "base/hash_tables.h"
#include "base/message_loop.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/common/chrome_switches.h"
namespace chromeos {
@@ -213,6 +215,14 @@ class CryptohomeLibraryStubImpl : public CryptohomeLibrary {
bool Mount(const std::string& user_email,
const std::string& passhash,
int* error_code) {
+ // For testing password change.
+ if (user_email ==
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kLoginUserWithNewPassword)) {
+ *error_code = kCryptohomeMountErrorKeyFailure;
+ return false;
+ }
+
return true;
}
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 1c4e4e7..fe77882 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -524,7 +524,13 @@ void ExistingUserController::OnPasswordChangeDetected(
return;
}
- PasswordChangedView* view = new PasswordChangedView(this);
+ // TODO(altimofeev): remove this constrain when full sync for the owner will
+ // be correctly handled.
+ // TODO(xiyuan): Wait for the cached settings update before using them.
+ bool full_sync_disabled = (UserCrosSettingsProvider::cached_owner() ==
+ controllers_[selected_view_index_]->user().email());
+
+ PasswordChangedView* view = new PasswordChangedView(this, full_sync_disabled);
views::Window* window = browser::CreateViewsWindow(GetNativeWindow(),
gfx::Rect(),
view);
diff --git a/chrome/browser/chromeos/login/password_changed_view.cc b/chrome/browser/chromeos/login/password_changed_view.cc
index 87c89d5..22f953f 100644
--- a/chrome/browser/chromeos/login/password_changed_view.cc
+++ b/chrome/browser/chromeos/login/password_changed_view.cc
@@ -30,13 +30,15 @@ namespace {
const int kPasswordFieldWidthChars = 20;
} // namespace
-PasswordChangedView::PasswordChangedView(Delegate* delegate)
+PasswordChangedView::PasswordChangedView(Delegate* delegate,
+ bool full_sync_disabled)
: title_label_(NULL),
description_label_(NULL),
full_sync_radio_(NULL),
delta_sync_radio_(NULL),
old_password_field_(NULL),
- delegate_(delegate) {
+ delegate_(delegate),
+ full_sync_disabled_(full_sync_disabled) {
}
bool PasswordChangedView::Accept() {
@@ -47,6 +49,15 @@ int PasswordChangedView::GetDialogButtons() const {
return MessageBoxFlags::DIALOGBUTTON_OK;
}
+views::View* PasswordChangedView::GetInitiallyFocusedView() {
+ if (!full_sync_disabled_) {
+ return views::DialogDelegate::GetInitiallyFocusedView();
+ } else {
+ DCHECK(old_password_field_);
+ return old_password_field_;
+ }
+}
+
std::wstring PasswordChangedView::GetWindowTitle() const {
return l10n_util::GetString(IDS_LOGIN_PASSWORD_CHANGED_DIALOG_BOX_TITLE);
}
@@ -87,7 +98,6 @@ void PasswordChangedView::Init() {
full_sync_radio_ = new RadioButton(
l10n_util::GetString(IDS_LOGIN_PASSWORD_CHANGED_RESET), 0);
full_sync_radio_->set_listener(this);
- full_sync_radio_->SetChecked(true);
full_sync_radio_->SetMultiLine(true);
delta_sync_radio_ = new RadioButton(
@@ -136,7 +146,17 @@ void PasswordChangedView::Init() {
layout->StartRow(0, 0);
layout->AddView(old_password_field_);
- old_password_field_->SetEnabled(false);
+
+ // Disable options if needed.
+ if (!full_sync_disabled_) {
+ full_sync_radio_->SetChecked(true);
+ old_password_field_->SetEnabled(false);
+ } else {
+ full_sync_radio_->SetEnabled(false);
+ delta_sync_radio_->SetChecked(true);
+ old_password_field_->SetEnabled(true);
+ }
+
}
bool PasswordChangedView::ExitDialog() {
@@ -173,9 +193,4 @@ bool PasswordChangedView::HandleKeystroke(views::Textfield* s,
return false;
}
-void PasswordChangedView::SelectDeltaSyncOption() {
- if (!delta_sync_radio_->checked())
- delta_sync_radio_->SetChecked(true);
-}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/password_changed_view.h b/chrome/browser/chromeos/login/password_changed_view.h
index 48f6ca3..b7d45da 100644
--- a/chrome/browser/chromeos/login/password_changed_view.h
+++ b/chrome/browser/chromeos/login/password_changed_view.h
@@ -42,7 +42,7 @@ class PasswordChangedView : public views::View,
virtual void ResyncEncryptedData() = 0;
};
- explicit PasswordChangedView(Delegate* delegate);
+ PasswordChangedView(Delegate* delegate, bool full_sync_disabled);
virtual ~PasswordChangedView() {}
// views::DialogDelegate overrides:
@@ -50,6 +50,7 @@ class PasswordChangedView : public views::View,
virtual int GetDialogButtons() const;
// views::WindowDelegate overrides:
+ virtual View* GetInitiallyFocusedView();
virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView() { return this; }
@@ -66,9 +67,6 @@ class PasswordChangedView : public views::View,
virtual void ContentsChanged(views::Textfield* sender,
const string16& new_contents) {}
- // Selects delta sync radio button.
- void SelectDeltaSyncOption();
-
protected:
// views::View overrides:
virtual gfx::Size GetPreferredSize();
@@ -93,6 +91,9 @@ class PasswordChangedView : public views::View,
// Notifications receiver.
Delegate* delegate_;
+ // Whether full sync option is disabled.
+ bool full_sync_disabled_;
+
DISALLOW_COPY_AND_ASSIGN(PasswordChangedView);
};
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 386395b..8f115c4 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1181,6 +1181,9 @@ const char kLoginUser[] = "login-user";
// Specifies a password to be used to login (along with login-user).
const char kLoginPassword[] = "login-password";
+// Allows to emulate situation when user logins with new password.
+const char kLoginUserWithNewPassword[] = "login-user-with-new-password";
+
// Attempts to perform Chrome OS offline and online login in parallel.
const char kParallelAuth[] = "parallel-auth";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 15ec7e5..f6e6f32 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -334,6 +334,7 @@ extern const char kTestLoadLibcros[];
extern const char kLoginProfile[];
extern const char kLoginUser[];
extern const char kLoginPassword[];
+extern const char kLoginUserWithNewPassword[];
extern const char kParallelAuth[];
extern const char kChromeosFrame[];
extern const char kCandidateWindowLang[];