Home | History | Annotate | Download | only in login
      1 // Copyright 2013 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 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h"
      6 
      7 #include "chrome/browser/chromeos/login/help_app_launcher.h"
      8 #include "chrome/browser/chromeos/login/login_utils.h"
      9 #include "chrome/browser/chromeos/login/user.h"
     10 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
     11 #include "content/public/browser/browser_thread.h"
     12 #include "grit/generated_resources.h"
     13 #include "ui/base/l10n/l10n_util.h"
     14 
     15 namespace chromeos {
     16 
     17 UserManager* AppLaunchSigninScreen::test_user_manager_ = NULL;
     18 
     19 AppLaunchSigninScreen::AppLaunchSigninScreen(
     20     OobeUI* oobe_ui, Delegate* delegate)
     21     : oobe_ui_(oobe_ui),
     22       delegate_(delegate),
     23       webui_handler_(NULL) {
     24 }
     25 
     26 AppLaunchSigninScreen::~AppLaunchSigninScreen() {
     27   oobe_ui_->ResetSigninScreenHandlerDelegate();
     28 }
     29 
     30 void AppLaunchSigninScreen::Show() {
     31   InitOwnerUserList();
     32   oobe_ui_->ShowSigninScreen(LoginScreenContext(), this, NULL);
     33 }
     34 
     35 void AppLaunchSigninScreen::InitOwnerUserList() {
     36   UserManager* user_manager = GetUserManager();
     37   const std::string& owner_email = user_manager->GetOwnerEmail();
     38   const UserList& all_users = user_manager->GetUsers();
     39 
     40   owner_user_list_.clear();
     41   for (UserList::const_iterator it = all_users.begin();
     42        it != all_users.end();
     43        ++it) {
     44     User* user = *it;
     45     if (user->email() == owner_email) {
     46       owner_user_list_.push_back(user);
     47       break;
     48     }
     49   }
     50 }
     51 
     52 // static
     53 void AppLaunchSigninScreen::SetUserManagerForTesting(
     54     UserManager* user_manager) {
     55   test_user_manager_ = user_manager;
     56 }
     57 
     58 UserManager* AppLaunchSigninScreen::GetUserManager() {
     59   return test_user_manager_ ? test_user_manager_ : UserManager::Get();
     60 }
     61 
     62 void AppLaunchSigninScreen::CancelPasswordChangedFlow() {
     63   NOTREACHED();
     64 }
     65 
     66 void AppLaunchSigninScreen::CancelUserAdding() {
     67   NOTREACHED();
     68 }
     69 
     70 void AppLaunchSigninScreen::CreateAccount() {
     71   NOTREACHED();
     72 }
     73 
     74 void AppLaunchSigninScreen::CompleteLogin(const UserContext& user_context) {
     75   NOTREACHED();
     76 }
     77 
     78 void AppLaunchSigninScreen::Login(const UserContext& user_context) {
     79   // Note: LoginUtils::CreateAuthenticator doesn't necessarily create
     80   // a new Authenticator object, and could reuse an existing one.
     81   authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
     82   content::BrowserThread::PostTask(
     83       content::BrowserThread::UI, FROM_HERE,
     84       base::Bind(&Authenticator::AuthenticateToUnlock,
     85                  authenticator_.get(),
     86                  user_context));
     87 }
     88 
     89 void AppLaunchSigninScreen::LoginAsRetailModeUser() {
     90   NOTREACHED();
     91 }
     92 
     93 void AppLaunchSigninScreen::LoginAsGuest() {
     94   NOTREACHED();
     95 }
     96 
     97 void AppLaunchSigninScreen::MigrateUserData(const std::string& old_password) {
     98   NOTREACHED();
     99 }
    100 
    101 void AppLaunchSigninScreen::LoginAsPublicAccount(const std::string& username) {
    102   NOTREACHED();
    103 }
    104 
    105 void AppLaunchSigninScreen::LoadWallpaper(const std::string& username) {
    106 }
    107 
    108 void AppLaunchSigninScreen::LoadSigninWallpaper() {
    109 }
    110 
    111 void AppLaunchSigninScreen::OnSigninScreenReady() {
    112 }
    113 
    114 void AppLaunchSigninScreen::RemoveUser(const std::string& username) {
    115   NOTREACHED();
    116 }
    117 
    118 void AppLaunchSigninScreen::ResyncUserData() {
    119   NOTREACHED();
    120 }
    121 
    122 void AppLaunchSigninScreen::ShowEnterpriseEnrollmentScreen() {
    123   NOTREACHED();
    124 }
    125 
    126 void AppLaunchSigninScreen::ShowKioskEnableScreen() {
    127   NOTREACHED();
    128 }
    129 
    130 void AppLaunchSigninScreen::ShowResetScreen() {
    131   NOTREACHED();
    132 }
    133 
    134 void AppLaunchSigninScreen::ShowKioskAutolaunchScreen() {
    135   NOTREACHED();
    136 }
    137 
    138 void AppLaunchSigninScreen::ShowWrongHWIDScreen() {
    139   NOTREACHED();
    140 }
    141 
    142 void AppLaunchSigninScreen::SetWebUIHandler(
    143     LoginDisplayWebUIHandler* webui_handler) {
    144   webui_handler_ = webui_handler;
    145 }
    146 
    147 void AppLaunchSigninScreen::ShowSigninScreenForCreds(
    148     const std::string& username,
    149     const std::string& password) {
    150   NOTREACHED();
    151 }
    152 
    153 const UserList& AppLaunchSigninScreen::GetUsers() const {
    154   return owner_user_list_;
    155 }
    156 
    157 bool AppLaunchSigninScreen::IsShowGuest() const {
    158   return false;
    159 }
    160 
    161 bool AppLaunchSigninScreen::IsShowUsers() const {
    162   return true;
    163 }
    164 
    165 bool AppLaunchSigninScreen::IsShowNewUser() const {
    166   return false;
    167 }
    168 
    169 bool AppLaunchSigninScreen::IsSigninInProgress() const {
    170   // Return true to suppress network processing in the signin screen.
    171   return true;
    172 }
    173 
    174 bool AppLaunchSigninScreen::IsUserSigninCompleted() const {
    175   return false;
    176 }
    177 
    178 void AppLaunchSigninScreen::SetDisplayEmail(const std::string& email) {
    179   return;
    180 }
    181 
    182 void AppLaunchSigninScreen::Signout() {
    183   NOTREACHED();
    184 }
    185 
    186 void AppLaunchSigninScreen::LoginAsKioskApp(const std::string& app_id) {
    187   NOTREACHED();
    188 }
    189 
    190 void AppLaunchSigninScreen::OnLoginFailure(const LoginFailure& error) {
    191   LOG(ERROR) << "Unlock failure: " << error.reason();
    192   webui_handler_->ClearAndEnablePassword();
    193   webui_handler_->ShowError(
    194      0,
    195      l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING_KIOSK),
    196      std::string(),
    197      HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE);
    198 }
    199 
    200 void AppLaunchSigninScreen::OnLoginSuccess(const UserContext& user_context) {
    201   delegate_->OnOwnerSigninSuccess();
    202 }
    203 
    204 }  // namespace chromeos
    205