Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / app_launch_signin_screen.cc
blob73e8fbb6d461f25e07a36fc66122c5b7c28bf7e6
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.
5 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h"
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"
15 namespace chromeos {
17 UserManager* AppLaunchSigninScreen::test_user_manager_ = NULL;
19 AppLaunchSigninScreen::AppLaunchSigninScreen(
20 OobeUI* oobe_ui, Delegate* delegate)
21 : oobe_ui_(oobe_ui),
22 delegate_(delegate),
23 webui_handler_(NULL) {
26 AppLaunchSigninScreen::~AppLaunchSigninScreen() {
27 oobe_ui_->ResetSigninScreenHandlerDelegate();
30 void AppLaunchSigninScreen::Show() {
31 InitOwnerUserList();
32 oobe_ui_->ShowSigninScreen(LoginScreenContext(), this, NULL);
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();
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;
52 // static
53 void AppLaunchSigninScreen::SetUserManagerForTesting(
54 UserManager* user_manager) {
55 test_user_manager_ = user_manager;
58 UserManager* AppLaunchSigninScreen::GetUserManager() {
59 return test_user_manager_ ? test_user_manager_ : UserManager::Get();
62 void AppLaunchSigninScreen::CancelPasswordChangedFlow() {
63 NOTREACHED();
66 void AppLaunchSigninScreen::CancelUserAdding() {
67 NOTREACHED();
70 void AppLaunchSigninScreen::CreateAccount() {
71 NOTREACHED();
74 void AppLaunchSigninScreen::CompleteLogin(const UserContext& user_context) {
75 NOTREACHED();
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));
89 void AppLaunchSigninScreen::LoginAsRetailModeUser() {
90 NOTREACHED();
93 void AppLaunchSigninScreen::LoginAsGuest() {
94 NOTREACHED();
97 void AppLaunchSigninScreen::MigrateUserData(const std::string& old_password) {
98 NOTREACHED();
101 void AppLaunchSigninScreen::LoginAsPublicAccount(const std::string& username) {
102 NOTREACHED();
105 void AppLaunchSigninScreen::LoadWallpaper(const std::string& username) {
108 void AppLaunchSigninScreen::LoadSigninWallpaper() {
111 void AppLaunchSigninScreen::OnSigninScreenReady() {
114 void AppLaunchSigninScreen::RemoveUser(const std::string& username) {
115 NOTREACHED();
118 void AppLaunchSigninScreen::ResyncUserData() {
119 NOTREACHED();
122 void AppLaunchSigninScreen::ShowEnterpriseEnrollmentScreen() {
123 NOTREACHED();
126 void AppLaunchSigninScreen::ShowKioskEnableScreen() {
127 NOTREACHED();
130 void AppLaunchSigninScreen::ShowResetScreen() {
131 NOTREACHED();
134 void AppLaunchSigninScreen::ShowKioskAutolaunchScreen() {
135 NOTREACHED();
138 void AppLaunchSigninScreen::ShowWrongHWIDScreen() {
139 NOTREACHED();
142 void AppLaunchSigninScreen::SetWebUIHandler(
143 LoginDisplayWebUIHandler* webui_handler) {
144 webui_handler_ = webui_handler;
147 void AppLaunchSigninScreen::ShowSigninScreenForCreds(
148 const std::string& username,
149 const std::string& password) {
150 NOTREACHED();
153 const UserList& AppLaunchSigninScreen::GetUsers() const {
154 return owner_user_list_;
157 bool AppLaunchSigninScreen::IsShowGuest() const {
158 return false;
161 bool AppLaunchSigninScreen::IsShowUsers() const {
162 return true;
165 bool AppLaunchSigninScreen::IsShowNewUser() const {
166 return false;
169 bool AppLaunchSigninScreen::IsSigninInProgress() const {
170 // Return true to suppress network processing in the signin screen.
171 return true;
174 bool AppLaunchSigninScreen::IsUserSigninCompleted() const {
175 return false;
178 void AppLaunchSigninScreen::SetDisplayEmail(const std::string& email) {
179 return;
182 void AppLaunchSigninScreen::Signout() {
183 NOTREACHED();
186 void AppLaunchSigninScreen::LoginAsKioskApp(const std::string& app_id) {
187 NOTREACHED();
190 void AppLaunchSigninScreen::OnLoginFailure(const LoginFailure& error) {
191 LOG(ERROR) << "Unlock failure: " << error.reason();
192 webui_handler_->ClearAndEnablePassword();
193 webui_handler_->ShowError(
195 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING_KIOSK),
196 std::string(),
197 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE);
200 void AppLaunchSigninScreen::OnLoginSuccess(const UserContext& user_context) {
201 delegate_->OnOwnerSigninSuccess();
204 } // namespace chromeos