Skip to content

Commit

Permalink
Password in user pods clears after minute of idle state.
Browse files Browse the repository at this point in the history
BUG=155440
TBR=nkostylev

Review URL: https://chromiumcodereview.appspot.com/12321136

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184987 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Feb 27, 2013
1 parent bcbaa11 commit 064701f
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1 deletion.
34 changes: 34 additions & 0 deletions chrome/browser/chromeos/login/webui_login_display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/chromeos/login/webui_login_display.h"

#include "ash/wm/user_activity_detector.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
Expand All @@ -21,11 +22,21 @@

namespace chromeos {

namespace {

const int kPasswordClearTimeoutSec = 60;

}

// WebUILoginDisplay, public: --------------------------------------------------

WebUILoginDisplay::~WebUILoginDisplay() {
if (webui_handler_)
webui_handler_->ResetSigninScreenHandlerDelegate();
ash::UserActivityDetector* activity_detector = ash::Shell::GetInstance()->
user_activity_detector();
if (activity_detector->HasObserver(this))
activity_detector->RemoveObserver(this);
}

// LoginDisplay implementation: ------------------------------------------------
Expand All @@ -48,6 +59,11 @@ void WebUILoginDisplay::Init(const UserList& users,
show_guest_ = show_guest;
show_users_ = show_users;
show_new_user_ = show_new_user;

ash::UserActivityDetector* activity_detector = ash::Shell::GetInstance()->
user_activity_detector();
if (!activity_detector->HasObserver(this))
activity_detector->AddObserver(this);
}

void WebUILoginDisplay::OnPreferencesChanged() {
Expand Down Expand Up @@ -324,4 +340,22 @@ void WebUILoginDisplay::Signout() {
delegate_->Signout();
}

void WebUILoginDisplay::OnUserActivity() {
if (!password_clear_timer_.IsRunning())
StartPasswordClearTimer();
password_clear_timer_.Reset();
}

void WebUILoginDisplay::StartPasswordClearTimer() {
DCHECK(!password_clear_timer_.IsRunning());
password_clear_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this,
&WebUILoginDisplay::OnPasswordClearTimerExpired);
}

void WebUILoginDisplay::OnPasswordClearTimerExpired() {
if (webui_handler_)
webui_handler_->ClearUserPodPassword();
}

} // namespace chromeos
14 changes: 13 additions & 1 deletion chrome/browser/chromeos/login/webui_login_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <string>
#include <vector>

#include "ash/wm/user_activity_observer.h"
#include "base/compiler_specific.h"
#include "base/timer.h"
#include "chrome/browser/chromeos/login/login_display.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h"
Expand All @@ -19,7 +21,8 @@ namespace chromeos {
// WebUI-based login UI implementation.
class WebUILoginDisplay : public LoginDisplay,
public NativeWindowDelegate,
public SigninScreenHandlerDelegate {
public SigninScreenHandlerDelegate,
public ash::UserActivityObserver {
public:
explicit WebUILoginDisplay(LoginDisplay::Delegate* delegate);
virtual ~WebUILoginDisplay();
Expand Down Expand Up @@ -79,7 +82,13 @@ class WebUILoginDisplay : public LoginDisplay,
virtual void SetDisplayEmail(const std::string& email) OVERRIDE;
virtual void Signout() OVERRIDE;

// UserActivityDetector implementation:
virtual void OnUserActivity() OVERRIDE;

private:
void StartPasswordClearTimer();
void OnPasswordClearTimerExpired();

// Set of Users that are visible.
UserList users_;

Expand All @@ -92,6 +101,9 @@ class WebUILoginDisplay : public LoginDisplay,
// Whether to show add new user.
bool show_new_user_;

// Timer for measuring idle state duration before password clear.
base::OneShotTimer<WebUILoginDisplay> password_clear_timer_;

// Reference to the WebUI handling layer for the login screen
LoginDisplayWebUIHandler* webui_handler_;

Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/resources/chromeos/login/display_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,13 @@ cr.define('cr.ui.login', function() {
loadTimeData.getString('disabledAddUserTooltip') : '';
}

/**
* Clears password field in user-pod.
*/
DisplayManager.clearUserPodPassword = function() {
$('pod-row').clearFocusedPod();
};

// Export
return {
DisplayManager: DisplayManager
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/resources/chromeos/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ cr.define('cr.ui', function() {
oobe.TermsOfServiceScreen.setTermsOfService(termsOfService);
};

/**
* Clears password field in user-pod.
*/
Oobe.clearUserPodPassword = function() {
DisplayManager.clearUserPodPassword();
};

// Export
return {
Oobe: Oobe
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/resources/chromeos/login/oobe.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ cr.define('cr.ui', function() {
oobe.TermsOfServiceScreen.setTermsOfService(termsOfService);
};

/**
* Clears password field in user-pod.
*/
Oobe.clearUserPodPassword = function() {
DisplayManager.clearUserPodPassword();
};

// Export
return {
Oobe: Oobe
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/resources/chromeos/login/user_pod_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,14 @@ cr.define('login', function() {
this.activatedPod_.reset(takeFocus);
},

/**
* Clears focused pod password field.
*/
clearFocusedPod: function() {
if (!this.disabled && this.focusedPod_)
this.focusedPod_.reset(true);
},

/**
* Shows signin UI.
* @param {string} email Email for signin UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ void SigninScreenHandler::ClearAndEnablePassword() {
web_ui()->CallJavascriptFunction("cr.ui.Oobe.resetSigninUI", force_online);
}

void SigninScreenHandler::ClearUserPodPassword() {
web_ui()->CallJavascriptFunction("cr.ui.Oobe.clearUserPodPassword");
}

void SigninScreenHandler::OnLoginSuccess(const std::string& username) {
base::StringValue username_value(username);
web_ui()->CallJavascriptFunction("cr.ui.Oobe.onLoginSuccess", username_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class User;
class LoginDisplayWebUIHandler {
public:
virtual void ClearAndEnablePassword() = 0;
virtual void ClearUserPodPassword() = 0;
virtual void OnLoginSuccess(const std::string& username) = 0;
virtual void OnUserRemoved(const std::string& username) = 0;
virtual void OnUserImageChanged(const User& user) = 0;
Expand Down Expand Up @@ -221,6 +222,7 @@ class SigninScreenHandler

// BaseLoginUIHandler implementation:
virtual void ClearAndEnablePassword() OVERRIDE;
virtual void ClearUserPodPassword() OVERRIDE;
virtual void OnLoginSuccess(const std::string& username) OVERRIDE;
virtual void OnUserRemoved(const std::string& username) OVERRIDE;
virtual void OnUserImageChanged(const User& user) OVERRIDE;
Expand Down

0 comments on commit 064701f

Please sign in to comment.