Commit 173abf0f authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

chromeos: Break WebUILoginDisplay and SigninScreenHandler coupling on destruction.

So that neither of the two points to an invalid instance.

BUG=chromium-os:29669
TEST=Verify crash in chromium-os:29669 no longer happens.

Review URL: http://codereview.chromium.org/10213003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133959 0039d316-1c4b-4281-b951-d872f2087c98
parent ef92e177
......@@ -20,6 +20,8 @@ namespace chromeos {
// WebUILoginDisplay, public: --------------------------------------------------
WebUILoginDisplay::~WebUILoginDisplay() {
if (webui_handler_)
webui_handler_->ResetSigninScreenHandlerDelegate();
}
// LoginDisplay implementation: ------------------------------------------------
......@@ -59,24 +61,25 @@ void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) {
}
void WebUILoginDisplay::OnUserImageChanged(const User& user) {
DCHECK(webui_handler_);
webui_handler_->OnUserImageChanged(user);
if (webui_handler_)
webui_handler_->OnUserImageChanged(user);
}
void WebUILoginDisplay::OnUserRemoved(const std::string& username) {
DCHECK(webui_handler_);
webui_handler_->OnUserRemoved(username);
if (webui_handler_)
webui_handler_->OnUserRemoved(username);
}
void WebUILoginDisplay::OnFadeOut() {
}
void WebUILoginDisplay::OnLoginSuccess(const std::string& username) {
webui_handler_->OnLoginSuccess(username);
if (webui_handler_)
webui_handler_->OnLoginSuccess(username);
}
void WebUILoginDisplay::SetUIEnabled(bool is_enabled) {
if (is_enabled)
if (webui_handler_ && is_enabled)
webui_handler_->ClearAndEnablePassword();
}
......@@ -89,7 +92,8 @@ void WebUILoginDisplay::ShowError(int error_msg_id,
VLOG(1) << "Show error, error_id: " << error_msg_id
<< ", attempts:" << login_attempts
<< ", help_topic_id: " << help_topic_id;
DCHECK(webui_handler_);
if (!webui_handler_)
return;
std::string error_text;
switch (error_msg_id) {
......@@ -138,7 +142,8 @@ void WebUILoginDisplay::ShowError(int error_msg_id,
}
void WebUILoginDisplay::ShowGaiaPasswordChanged(const std::string& username) {
webui_handler_->ShowGaiaPasswordChanged(username);
if (webui_handler_)
webui_handler_->ShowGaiaPasswordChanged(username);
}
// WebUILoginDisplay, SigninScreenHandlerDelegate implementation: --------------
......@@ -195,8 +200,8 @@ void WebUILoginDisplay::SetWebUIHandler(
void WebUILoginDisplay::ShowSigninScreenForCreds(
const std::string& username,
const std::string& password) {
DCHECK(webui_handler_);
webui_handler_->ShowSigninScreenForCreds(username, password);
if (webui_handler_)
webui_handler_->ShowSigninScreenForCreds(username, password);
}
const UserList& WebUILoginDisplay::GetUsers() const {
......
......@@ -289,6 +289,8 @@ SigninScreenHandler::~SigninScreenHandler() {
cookie_remover_->RemoveObserver(this);
if (key_event_listener_)
key_event_listener_->RemoveCapsLockObserver(this);
if (delegate_)
delegate_->SetWebUIHandler(NULL);
CrosSettings::Get()->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this);
CrosSettings::Get()->RemoveSettingsObserver(kAccountsPrefAllowGuest, this);
}
......@@ -542,6 +544,10 @@ void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) {
"login.AccountPickerScreen.updateUserGaiaNeeded", email_value);
}
void SigninScreenHandler::ResetSigninScreenHandlerDelegate() {
SetDelegate(NULL);
}
void SigninScreenHandler::OnBrowsingDataRemoverDone() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
cookie_remover_ = NULL;
......
......@@ -47,6 +47,7 @@ class LoginDisplayWebUIHandler {
// Show siginin screen for the given credentials.
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) = 0;
virtual void ResetSigninScreenHandlerDelegate() = 0;
protected:
virtual ~LoginDisplayWebUIHandler() {}
};
......@@ -151,6 +152,7 @@ class SigninScreenHandler : public BaseScreenHandler,
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) OVERRIDE;
virtual void ShowGaiaPasswordChanged(const std::string& username) OVERRIDE;
virtual void ResetSigninScreenHandlerDelegate() OVERRIDE;
// BrowsingDataRemover::Observer overrides.
virtual void OnBrowsingDataRemoverDone() OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment