Home | History | Annotate | Download | only in login
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "ash/wm/user_activity_observer.h"
     12 #include "base/compiler_specific.h"
     13 #include "base/timer/timer.h"
     14 #include "chrome/browser/chromeos/login/login_display.h"
     15 #include "chrome/browser/chromeos/login/user.h"
     16 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h"
     17 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
     18 #include "ui/views/widget/widget.h"
     19 
     20 namespace chromeos {
     21 // WebUI-based login UI implementation.
     22 class WebUILoginDisplay : public LoginDisplay,
     23                           public NativeWindowDelegate,
     24                           public SigninScreenHandlerDelegate,
     25                           public ash::UserActivityObserver {
     26  public:
     27   explicit WebUILoginDisplay(LoginDisplay::Delegate* delegate);
     28   virtual ~WebUILoginDisplay();
     29 
     30   // LoginDisplay implementation:
     31   virtual void ClearAndEnablePassword() OVERRIDE;
     32   virtual void Init(const UserList& users,
     33                     bool show_guest,
     34                     bool show_users,
     35                     bool show_new_user) OVERRIDE;
     36   virtual void OnPreferencesChanged() OVERRIDE;
     37   virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE;
     38   virtual void OnUserImageChanged(const User& user) OVERRIDE;
     39   virtual void OnUserRemoved(const std::string& username) OVERRIDE;
     40   virtual void OnFadeOut() OVERRIDE;
     41   virtual void OnLoginSuccess(const std::string& username) OVERRIDE;
     42   virtual void SetUIEnabled(bool is_enabled) OVERRIDE;
     43   virtual void SelectPod(int index) OVERRIDE;
     44   virtual void ShowBannerMessage(const std::string& message) OVERRIDE;
     45   virtual void ShowUserPodButton(const std::string& username,
     46                                  const std::string& iconURL,
     47                                  const base::Closure& click_callback) OVERRIDE;
     48   virtual void ShowError(int error_msg_id,
     49                          int login_attempts,
     50                          HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE;
     51   virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE;
     52   virtual void ShowGaiaPasswordChanged(const std::string& username) OVERRIDE;
     53   virtual void ShowPasswordChangedDialog(bool show_password_error) OVERRIDE;
     54   virtual void ShowSigninUI(const std::string& email) OVERRIDE;
     55 
     56   // NativeWindowDelegate implementation:
     57   virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
     58 
     59   // SigninScreenHandlerDelegate implementation:
     60   virtual void CancelPasswordChangedFlow() OVERRIDE;
     61   virtual void CancelUserAdding() OVERRIDE;
     62   virtual void CreateAccount() OVERRIDE;
     63   virtual void CompleteLogin(const UserContext& user_context) OVERRIDE;
     64   virtual void Login(const UserContext& user_context) OVERRIDE;
     65   virtual void LoginAsRetailModeUser() OVERRIDE;
     66   virtual void LoginAsGuest() OVERRIDE;
     67   virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
     68   virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
     69   virtual void LoadWallpaper(const std::string& username) OVERRIDE;
     70   virtual void LoadSigninWallpaper() OVERRIDE;
     71   virtual void OnSigninScreenReady() OVERRIDE;
     72   virtual void RemoveUser(const std::string& username) OVERRIDE;
     73   virtual void ResyncUserData() OVERRIDE;
     74   virtual void ShowEnterpriseEnrollmentScreen() OVERRIDE;
     75   virtual void ShowKioskEnableScreen() OVERRIDE;
     76   virtual void ShowResetScreen() OVERRIDE;
     77   virtual void ShowKioskAutolaunchScreen() OVERRIDE;
     78   virtual void ShowWrongHWIDScreen() OVERRIDE;
     79   virtual void SetWebUIHandler(
     80       LoginDisplayWebUIHandler* webui_handler) OVERRIDE;
     81   virtual void ShowSigninScreenForCreds(const std::string& username,
     82                                         const std::string& password);
     83   virtual const UserList& GetUsers() const OVERRIDE;
     84   virtual bool IsShowGuest() const OVERRIDE;
     85   virtual bool IsShowUsers() const OVERRIDE;
     86   virtual bool IsShowNewUser() const OVERRIDE;
     87   virtual bool IsSigninInProgress() const OVERRIDE;
     88   virtual bool IsUserSigninCompleted() const OVERRIDE;
     89   virtual void SetDisplayEmail(const std::string& email) OVERRIDE;
     90   virtual void Signout() OVERRIDE;
     91   virtual void LoginAsKioskApp(const std::string& app_id) OVERRIDE;
     92 
     93   // UserActivityDetector implementation:
     94   virtual void OnUserActivity(const ui::Event* event) OVERRIDE;
     95 
     96  private:
     97   void StartPasswordClearTimer();
     98   void OnPasswordClearTimerExpired();
     99 
    100   // Set of Users that are visible.
    101   UserList users_;
    102 
    103   // Whether to show guest login.
    104   bool show_guest_;
    105 
    106   // Weather to show the user pads or a plain credentials dialogue.
    107   bool show_users_;
    108 
    109   // Whether to show add new user.
    110   bool show_new_user_;
    111 
    112   // Timer for measuring idle state duration before password clear.
    113   base::OneShotTimer<WebUILoginDisplay> password_clear_timer_;
    114 
    115   // Reference to the WebUI handling layer for the login screen
    116   LoginDisplayWebUIHandler* webui_handler_;
    117 
    118   DISALLOW_COPY_AND_ASSIGN(WebUILoginDisplay);
    119 };
    120 
    121 }  // namespace chromeos
    122 
    123 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_
    124