Index: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
index 3624e4028278f4a459a0d966d87ddfb9edbde56c..247edd079da10b0925d4d8a8e1768207fc6e016c 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
@@ -42,6 +42,7 @@ |
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
+#include "chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h" |
#include "chrome/browser/io_thread.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h" |
@@ -67,6 +68,7 @@ |
#include "grit/generated_resources.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
+#include "ui/base/webui/web_ui_util.h" |
#if defined(USE_AURA) |
#include "ash/shell.h" |
@@ -346,6 +348,7 @@ SigninScreenHandler::~SigninScreenHandler() { |
if (delegate_) |
delegate_->SetWebUIHandler(NULL); |
network_state_informer_->RemoveObserver(this); |
+ ScreenlockBridge::Get()->SetLockHandler(NULL); |
} |
void SigninScreenHandler::DeclareLocalizedValues( |
@@ -748,6 +751,7 @@ void SigninScreenHandler::RegisterMessages() { |
AddCallback("scrapedPasswordVerificationFailed", |
&SigninScreenHandler::HandleScrapedPasswordVerificationFailed); |
AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); |
+ AddCallback("attemptUnlock", &SigninScreenHandler::HandleAttemptUnlock); |
AddCallback("completeLogin", &SigninScreenHandler::HandleCompleteLogin); |
AddCallback("completeAuthentication", |
&SigninScreenHandler::HandleCompleteAuthentication); |
@@ -792,8 +796,6 @@ void SigninScreenHandler::RegisterMessages() { |
AddCallback("updateOfflineLogin", |
&SigninScreenHandler::HandleUpdateOfflineLogin); |
AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); |
- AddCallback("customButtonClicked", |
- &SigninScreenHandler::HandleCustomButtonClicked); |
AddCallback("retrieveAuthenticatedUserEmail", |
&SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); |
@@ -859,53 +861,6 @@ void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { |
SetDelegate(NULL); |
} |
-void SigninScreenHandler::ShowBannerMessage(const std::string& message) { |
- CallJS("login.AccountPickerScreen.showBannerMessage", message); |
-} |
- |
-void SigninScreenHandler::ShowUserPodButton( |
- const std::string& username, |
- const std::string& iconURL, |
- const base::Closure& click_callback) { |
- user_pod_button_callback_map_[username] = click_callback; |
- CallJS("login.AccountPickerScreen.showUserPodButton", username, iconURL); |
- |
- // TODO(tengs): Move this code once we move unlocking to native code. |
- if (ScreenLocker::default_screen_locker()) { |
- UserManager* user_manager = UserManager::Get(); |
- const User* user = user_manager->FindUser(username); |
- if (!user) |
- return; |
- PrefService* profile_prefs = |
- user_manager->GetProfileByUser(user)->GetPrefs(); |
- if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { |
- CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
- profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
- } |
- } |
-} |
- |
-void SigninScreenHandler::HideUserPodButton(const std::string& username) { |
- CallJS("login.AccountPickerScreen.hideUserPodButton", username); |
-} |
- |
-void SigninScreenHandler::SetAuthType(const std::string& username, |
- LoginDisplay::AuthType auth_type, |
- const std::string& initial_value) { |
- user_auth_type_map_[username] = auth_type; |
- CallJS("login.AccountPickerScreen.setAuthType", |
- username, |
- static_cast<int>(auth_type), |
- base::StringValue(initial_value)); |
-} |
- |
-LoginDisplay::AuthType SigninScreenHandler::GetAuthType( |
- const std::string& username) const { |
- if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
- return LoginDisplay::OFFLINE_PASSWORD; |
- return user_auth_type_map_.find(username)->second; |
-} |
- |
void SigninScreenHandler::ShowError(int login_attempts, |
const std::string& error_text, |
const std::string& help_link_text, |
@@ -939,7 +894,7 @@ void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) { |
core_oobe_actor_->ShowSignInUI(email_); |
CallJS("login.setAuthType", |
username, |
- static_cast<int>(LoginDisplay::ONLINE_SIGN_IN), |
+ static_cast<int>(ONLINE_SIGN_IN), |
base::StringValue("")); |
} |
@@ -1007,6 +962,64 @@ void SigninScreenHandler::Observe(int type, |
} |
} |
+void SigninScreenHandler::ShowBannerMessage(const std::string& message) { |
+ CallJS("login.AccountPickerScreen.showBannerMessage", message); |
+} |
+ |
+void SigninScreenHandler::ShowUserPodCustomIcon( |
+ const std::string& username, |
+ const gfx::Image& icon) { |
+ GURL icon_url(webui::GetBitmapDataUrl(icon.AsBitmap())); |
+ CallJS("login.AccountPickerScreen.showUserPodCustomIcon", |
+ username, icon_url.spec()); |
+ |
+ // TODO(tengs): Move this code once we move unlocking to native code. |
+ if (ScreenLocker::default_screen_locker()) { |
+ UserManager* user_manager = UserManager::Get(); |
+ const User* user = user_manager->FindUser(username); |
+ if (!user) |
+ return; |
+ PrefService* profile_prefs = |
+ user_manager->GetProfileByUser(user)->GetPrefs(); |
+ if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { |
+ CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
+ profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
+ } |
+ } |
+} |
+ |
+void SigninScreenHandler::HideUserPodCustomIcon(const std::string& username) { |
+ CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", username); |
+} |
+ |
+void SigninScreenHandler::EnableInput() { |
+ // Only for lock screen at the moment. |
+ ScreenLocker::default_screen_locker()->EnableInput(); |
+} |
+ |
+void SigninScreenHandler::SetAuthType( |
+ const std::string& username, |
+ ScreenlockBridge::LockHandler::AuthType auth_type, |
+ const std::string& initial_value) { |
+ user_auth_type_map_[username] = auth_type; |
+ CallJS("login.AccountPickerScreen.setAuthType", |
+ username, |
+ static_cast<int>(auth_type), |
+ base::StringValue(initial_value)); |
+} |
+ |
+ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( |
+ const std::string& username) const { |
+ if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
+ return OFFLINE_PASSWORD; |
+ return user_auth_type_map_.find(username)->second; |
+} |
+ |
+void SigninScreenHandler::Unlock(const std::string& user_email) { |
+ DCHECK(ScreenLocker::default_screen_locker()); |
+ ScreenLocker::Hide(); |
+} |
+ |
void SigninScreenHandler::OnDnsCleared() { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
dns_clear_task_running_ = false; |
@@ -1183,6 +1196,27 @@ void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
delegate_->Login(user_context); |
} |
+void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
+ DCHECK(ScreenLocker::default_screen_locker()); |
+ |
+ const User* unlock_user = NULL; |
+ const UserList& users = delegate_->GetUsers(); |
+ for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
+ if ((*it)->email() == username) { |
+ unlock_user = *it; |
+ break; |
+ } |
+ } |
+ if (!unlock_user) |
+ return; |
+ |
+ Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user); |
+ extensions::ScreenlockPrivateEventRouter* router = |
+ extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( |
+ profile); |
+ router->OnAuthAttempted(GetAuthType(username), ""); |
+} |
+ |
void SigninScreenHandler::HandleLaunchDemoUser() { |
if (delegate_) |
delegate_->LoginAsRetailModeUser(); |
@@ -1284,11 +1318,12 @@ void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() { |
delegate_->ShowKioskAutolaunchScreen(); |
} |
-void SigninScreenHandler::FillUserDictionary(User* user, |
- bool is_owner, |
- bool is_signin_to_add, |
- LoginDisplay::AuthType auth_type, |
- base::DictionaryValue* user_dict) { |
+void SigninScreenHandler::FillUserDictionary( |
+ User* user, |
+ bool is_owner, |
+ bool is_signin_to_add, |
+ ScreenlockBridge::LockHandler::AuthType auth_type, |
+ base::DictionaryValue* user_dict) { |
const std::string& email = user->email(); |
const bool is_public_account = |
user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; |
@@ -1346,7 +1381,6 @@ void SigninScreenHandler::SendUserList(bool animated) { |
bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
UserManager::Get()->IsUserLoggedIn(); |
- user_pod_button_callback_map_.clear(); |
user_auth_type_map_.clear(); |
bool single_user = users.size() == 1; |
@@ -1370,9 +1404,8 @@ void SigninScreenHandler::SendUserList(bool animated) { |
if ((is_public_account && !is_signin_to_add) || |
is_owner || |
(!is_public_account && non_owner_count < max_non_owner_users)) { |
- LoginDisplay::AuthType initial_auth_type = |
- ShouldForceOnlineSignIn(*it) ? LoginDisplay::ONLINE_SIGN_IN |
- : LoginDisplay::OFFLINE_PASSWORD; |
+ AuthType initial_auth_type = |
+ ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN : OFFLINE_PASSWORD; |
user_auth_type_map_[email] = initial_auth_type; |
base::DictionaryValue* user_dict = new base::DictionaryValue(); |
@@ -1424,8 +1457,10 @@ void SigninScreenHandler::HandleAccountPickerReady() { |
is_account_picker_showing_first_time_ = true; |
MaybePreloadAuthExtension(); |
- if (ScreenLocker::default_screen_locker()) |
+ if (ScreenLocker::default_screen_locker()) { |
ScreenLocker::default_screen_locker()->delegate()->OnLockWebUIReady(); |
+ ScreenlockBridge::Get()->SetLockHandler(this); |
+ } |
if (delegate_) |
delegate_->OnSigninScreenReady(); |
@@ -1571,16 +1606,6 @@ void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { |
WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); |
} |
-void SigninScreenHandler::HandleCustomButtonClicked( |
- const std::string& username) { |
- if (user_pod_button_callback_map_.find(username) |
- == user_pod_button_callback_map_.end()) { |
- LOG(WARNING) << "User pod custom button clicked but no callback found"; |
- return; |
- } |
- user_pod_button_callback_map_[username].Run(); |
-} |
- |
void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( |
double attempt_token) { |
email_retriever_.reset(new AuthenticatedUserEmailRetriever( |