#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
+#include <map>
#include <set>
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/events/system_key_event_listener.h"
-#include "chrome/browser/chromeos/login/help_app_launcher.h"
-#include "chrome/browser/chromeos/login/login_display.h"
+#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h"
#include "chrome/browser/chromeos/login/screens/error_screen_actor.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/net/network_portal_detector.h"
+#include "chrome/browser/chromeos/login/signin_specifics.h"
+#include "chrome/browser/chromeos/login/ui/login_display.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+#include "chromeos/ime/ime_keyboard.h"
+#include "chromeos/network/portal_detector/network_portal_detector.h"
+#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui.h"
#include "net/base/net_errors.h"
+#include "ui/events/event_handler.h"
namespace base {
class DictionaryValue;
class AuthenticatedUserEmailRetriever;
class CaptivePortalWindowProxy;
class CoreOobeActor;
-class LocallyManagedUserCreationScreenHandler;
+class GaiaScreenHandler;
class NativeWindowDelegate;
+class SupervisedUserCreationScreenHandler;
class User;
-struct UserContext;
+class UserContext;
// Helper class to pass initial parameters to the login screen.
class LoginScreenContext {
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;
+ virtual void OnUserImageChanged(const user_manager::User& user) = 0;
virtual void OnPreferencesChanged() = 0;
virtual void ResetSigninScreenHandlerDelegate() = 0;
- virtual void ShowBannerMessage(const std::string& message) = 0;
- virtual void ShowUserPodButton(const std::string& username,
- const std::string& iconURL,
- const base::Closure& click_callback) = 0;
virtual void ShowError(int login_attempts,
const std::string& error_text,
const std::string& help_link_text,
// Show sign-in screen for the given credentials.
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) = 0;
+ virtual void LoadUsers(const base::ListValue& users_list,
+ bool show_guest) = 0;
+ virtual void SetPublicSessionDisplayName(const std::string& user_id,
+ const std::string& display_name) = 0;
+ virtual void SetPublicSessionLocales(const std::string& user_id,
+ scoped_ptr<base::ListValue> locales,
+ const std::string& default_locale,
+ bool multipleRecommendedLocales) = 0;
+
protected:
virtual ~LoginDisplayWebUIHandler() {}
};
// An interface for SigninScreenHandler to call WebUILoginDisplay.
class SigninScreenHandlerDelegate {
public:
+ // --------------- Password change flow methods.
// Cancels current password changed flow.
virtual void CancelPasswordChangedFlow() = 0;
- // Cancels user adding.
- virtual void CancelUserAdding() = 0;
-
- // Create a new Google account.
- virtual void CreateAccount() = 0;
+ // Decrypt cryptohome using user provided |old_password|
+ // and migrate to new password.
+ virtual void MigrateUserData(const std::string& old_password) = 0;
- // Confirms sign up by provided credentials in |user_context|.
- // Used for new user login via GAIA extension.
- virtual void CompleteLogin(const UserContext& user_context) = 0;
+ // Ignore password change, remove existing cryptohome and
+ // force full sync of user data.
+ virtual void ResyncUserData() = 0;
+ // --------------- Sign in/out methods.
// Sign in using username and password specified as a part of |user_context|.
// Used for both known and new users.
- virtual void Login(const UserContext& user_context) = 0;
-
- // Sign in into a retail mode session.
- virtual void LoginAsRetailModeUser() = 0;
+ virtual void Login(const UserContext& user_context,
+ const SigninSpecifics& specifics) = 0;
- // Sign in into guest session.
- virtual void LoginAsGuest() = 0;
-
- // Sign in into the public account identified by |username|.
- virtual void LoginAsPublicAccount(const std::string& username) = 0;
+ // Sign in as guest to create a new Google account.
+ virtual void CreateAccount() = 0;
- // Decrypt cryptohome using user provided |old_password|
- // and migrate to new password.
- virtual void MigrateUserData(const std::string& old_password) = 0;
+ // Returns true if sign in is in progress.
+ virtual bool IsSigninInProgress() const = 0;
- // Load wallpaper for given |username|.
- virtual void LoadWallpaper(const std::string& username) = 0;
+ // Signs out if the screen is currently locked.
+ virtual void Signout() = 0;
- // Loads the default sign-in wallpaper.
- virtual void LoadSigninWallpaper() = 0;
+ // --------------- Account creation methods.
+ // Confirms sign up by provided credentials in |user_context|.
+ // Used for new user login via GAIA extension.
+ virtual void CompleteLogin(const UserContext& user_context) = 0;
+ // --------------- Shared with login display methods.
// Notify the delegate when the sign-in UI is finished loading.
virtual void OnSigninScreenReady() = 0;
- // Attempts to remove given user.
- virtual void RemoveUser(const std::string& username) = 0;
-
- // Ignore password change, remove existing cryptohome and
- // force full sync of user data.
- virtual void ResyncUserData() = 0;
-
// Shows Enterprise Enrollment screen.
virtual void ShowEnterpriseEnrollmentScreen() = 0;
virtual void ShowKioskEnableScreen() = 0;
// Shows Reset screen.
- virtual void ShowResetScreen() = 0;
-
- // Shows Reset screen.
virtual void ShowKioskAutolaunchScreen() = 0;
// Show wrong hwid screen.
virtual void ShowWrongHWIDScreen() = 0;
+ // Sets the displayed email for the next login attempt. If it succeeds,
+ // user's displayed email value will be updated to |email|.
+ virtual void SetDisplayEmail(const std::string& email) = 0;
+
+ // --------------- Rest of the methods.
+ // Cancels user adding.
+ virtual void CancelUserAdding() = 0;
+
+ // Load wallpaper for given |username|.
+ virtual void LoadWallpaper(const std::string& username) = 0;
+
+ // Loads the default sign-in wallpaper.
+ virtual void LoadSigninWallpaper() = 0;
+
+ // Attempts to remove given user.
+ virtual void RemoveUser(const std::string& username) = 0;
+
// Let the delegate know about the handler it is supposed to be using.
virtual void SetWebUIHandler(LoginDisplayWebUIHandler* webui_handler) = 0;
// Returns users list to be shown.
- virtual const UserList& GetUsers() const = 0;
+ virtual const user_manager::UserList& GetUsers() const = 0;
// Whether login as guest is available.
virtual bool IsShowGuest() const = 0;
- // Whether login as guest is available.
+ // Weather to show the user pods or only GAIA sign in.
+ // Public sessions are always shown.
virtual bool IsShowUsers() const = 0;
- // Whether new user pod is available.
- virtual bool IsShowNewUser() const = 0;
-
- // Returns true if sign in is in progress.
- virtual bool IsSigninInProgress() const = 0;
-
// Whether user sign in has completed.
virtual bool IsUserSigninCompleted() const = 0;
- // Sets the displayed email for the next login attempt. If it succeeds,
- // user's displayed email value will be updated to |email|.
- virtual void SetDisplayEmail(const std::string& email) = 0;
+ // Request to (re)load user list.
+ virtual void HandleGetUsers() = 0;
- // Signs out if the screen is currently locked.
- virtual void Signout() = 0;
+ // Set authentication type (for easier unlocking).
+ virtual void SetAuthType(
+ const std::string& username,
+ ScreenlockBridge::LockHandler::AuthType auth_type) = 0;
- // Login to kiosk mode for app with |app_id|.
- virtual void LoginAsKioskApp(const std::string& app_id,
- bool diagnostic_mode) = 0;
+ // Get authentication type (for easier unlocking).
+ virtual ScreenlockBridge::LockHandler::AuthType GetAuthType(
+ const std::string& username) const = 0;
protected:
virtual ~SigninScreenHandlerDelegate() {}
class SigninScreenHandler
: public BaseScreenHandler,
public LoginDisplayWebUIHandler,
- public SystemKeyEventListener::CapsLockObserver,
public content::NotificationObserver,
- public NetworkStateInformer::NetworkStateInformerObserver {
+ public ScreenlockBridge::LockHandler,
+ public NetworkStateInformer::NetworkStateInformerObserver,
+ public input_method::ImeKeyboard::Observer {
public:
SigninScreenHandler(
const scoped_refptr<NetworkStateInformer>& network_state_informer,
UI_STATE_ACCOUNT_PICKER,
};
+ friend class GaiaScreenHandler;
friend class ReportDnsCacheClearedOnUIThread;
- friend class LocallyManagedUserCreationScreenHandler;
+ friend class SupervisedUserCreationScreenHandler;
void ShowImpl();
ErrorScreenActor::ErrorReason reason);
void HideOfflineMessage(NetworkStateInformer::State state,
ErrorScreenActor::ErrorReason reason);
- void ReloadGaiaScreen();
+ void ReloadGaia(bool force_reload);
// BaseScreenHandler implementation:
virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
// LoginDisplayWebUIHandler 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;
+ virtual void OnUserImageChanged(const user_manager::User& user) OVERRIDE;
virtual void OnPreferencesChanged() OVERRIDE;
virtual void ResetSigninScreenHandlerDelegate() OVERRIDE;
- virtual void ShowBannerMessage(const std::string& message) OVERRIDE;
- virtual void ShowUserPodButton(const std::string& username,
- const std::string& iconURL,
- const base::Closure& click_callback) OVERRIDE;
virtual void ShowError(int login_attempts,
const std::string& error_text,
const std::string& help_link_text,
virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE;
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) OVERRIDE;
-
- // SystemKeyEventListener::CapsLockObserver overrides.
- virtual void OnCapsLockChange(bool enabled) OVERRIDE;
+ virtual void LoadUsers(const base::ListValue& users_list,
+ bool show_guest) OVERRIDE;
+ virtual void SetPublicSessionDisplayName(
+ const std::string& user_id,
+ const std::string& display_name) OVERRIDE;
+ virtual void SetPublicSessionLocales(
+ const std::string& user_id,
+ scoped_ptr<base::ListValue> locales,
+ const std::string& default_locale,
+ bool multipleRecommendedLocales) OVERRIDE;
// content::NotificationObserver implementation:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // Shows signin screen after dns cache and cookie cleanup operations finish.
- void ShowSigninScreenIfReady();
-
- // Tells webui to load authentication extension. |force| is used to force the
- // extension reloading, if it has already been loaded. |silent_load| is true
- // for cases when extension should be loaded in the background and it
- // shouldn't grab the focus. |offline| is true when offline version of the
- // extension should be used.
- void LoadAuthExtension(bool force, bool silent_load, bool offline);
+ // ScreenlockBridge::LockHandler implementation:
+ virtual void ShowBannerMessage(const base::string16& message) OVERRIDE;
+ virtual void ShowUserPodCustomIcon(
+ const std::string& username,
+ const ScreenlockBridge::UserPodCustomIconOptions& icon) OVERRIDE;
+ virtual void HideUserPodCustomIcon(const std::string& username) OVERRIDE;
+ virtual void EnableInput() OVERRIDE;
+ virtual void SetAuthType(const std::string& username,
+ ScreenlockBridge::LockHandler::AuthType auth_type,
+ const base::string16& initial_value) OVERRIDE;
+ virtual ScreenlockBridge::LockHandler::AuthType GetAuthType(
+ const std::string& username) const OVERRIDE;
+ virtual void Unlock(const std::string& user_email) OVERRIDE;
// Updates authentication extension. Called when device settings that affect
// sign-in (allow BWSI and allow whitelist) are changed.
void RefocusCurrentPod();
// WebUI message handlers.
- void HandleCompleteAuthentication(const std::string& email,
- const std::string& password,
- const std::string& auth_code);
- void HandleCompleteLogin(const std::string& typed_email,
- const std::string& password,
- bool using_saml);
void HandleGetUsers();
- void HandleUsingSAMLAPI();
- void HandleScrapedPasswordCount(int password_count);
- void HandleScrapedPasswordVerificationFailed();
void HandleAuthenticateUser(const std::string& username,
const std::string& password);
+ void HandleAttemptUnlock(const std::string& username);
void HandleLaunchDemoUser();
void HandleLaunchIncognito();
- void HandleLaunchPublicAccount(const std::string& username);
+ void HandleLaunchPublicSession(const std::string& user_id,
+ const std::string& locale,
+ const std::string& input_method);
void HandleOfflineLogin(const base::ListValue* args);
void HandleShutdownSystem();
void HandleLoadWallpaper(const std::string& email);
void HandleToggleKioskEnableScreen();
void HandleToggleResetScreen();
void HandleToggleKioskAutolaunchScreen();
- void HandleLaunchHelpApp(double help_topic_id);
void HandleCreateAccount();
void HandleAccountPickerReady();
void HandleWallpaperReady();
- void HandleLoginWebuiReady();
void HandleSignOutUser();
- void HandleNetworkErrorShown();
void HandleOpenProxySettings();
void HandleLoginVisible(const std::string& source);
void HandleCancelPasswordChangedFlow();
void HandleLoginScreenUpdate();
void HandleShowLoadingTimeoutError();
void HandleUpdateOfflineLogin(bool offline_login_active);
- void HandleShowLocallyManagedUserCreationScreen();
+ void HandleShowSupervisedUserCreationScreen();
void HandleFocusPod(const std::string& user_id);
void HandleLaunchKioskApp(const std::string& app_id, bool diagnostic_mode);
- void HandleCustomButtonClicked(const std::string& username);
void HandleRetrieveAuthenticatedUserEmail(double attempt_token);
+ void HandleGetPublicSessionKeyboardLayouts(const std::string& user_id,
+ const std::string& locale);
+ void HandleCancelConsumerManagementEnrollment();
- // Fills |user_dict| with information about |user|.
- static void FillUserDictionary(User* user,
- bool is_owner,
- bool is_signin_to_add,
- base::DictionaryValue* user_dict);
-
- // Sends user list to account picker.
- void SendUserList(bool animated);
-
- // Kick off cookie / local storage cleanup.
- void StartClearingCookies(const base::Closure& on_clear_callback);
- void OnCookiesCleared(base::Closure on_clear_callback);
-
- // Kick off DNS cache flushing.
- void StartClearingDnsCache();
- void OnDnsCleared();
-
- // Decides whether an auth extension should be pre-loaded. If it should,
- // pre-loads it.
- void MaybePreloadAuthExtension();
+ // Sends the list of |keyboard_layouts| available for the |locale| that is
+ // currently selected for the public session identified by |user_id|.
+ void SendPublicSessionKeyboardLayouts(
+ const std::string& user_id,
+ const std::string& locale,
+ scoped_ptr<base::ListValue> keyboard_layouts);
// Returns true iff
// (i) log in is restricted to some user list,
// Returns true if offline login is allowed.
bool IsOfflineLoginAllowed() const;
- // Attempts login for test.
- void SubmitLoginFormForTest();
+ bool ShouldLoadGaia() const;
// Update current input method (namely keyboard layout) to LRU by this user.
void SetUserInputMethod(const std::string& username);
- // Invoked when auto enrollment check is finished to decide whether to
+ // Invoked when auto enrollment check progresses to decide whether to
// continue kiosk enable flow. Kiosk enable flow is resumed when
- // |should_auto_enroll| is false.
- void ContinueKioskEnableFlow(bool should_auto_enroll);
+ // |state| indicates that enrollment is not applicable.
+ void ContinueKioskEnableFlow(policy::AutoEnrollmentState state);
- // Shows signin screen for |email|.
- void OnShowAddUser(const std::string& email);
-
- // Updates the member variable and UMA histogram indicating whether the
- // principals API was used during SAML login.
- void SetSAMLPrincipalsAPIUsed(bool api_used);
+ // Shows signin.
+ void OnShowAddUser();
GaiaScreenHandler::FrameState FrameState() const;
net::Error FrameError() const;
+ // input_method::ImeKeyboard::Observer implementation:
+ virtual void OnCapsLockChanged(bool enabled) OVERRIDE;
+
// Current UI state of the signin screen.
UIState ui_state_;
// Keeps whether screen should be shown for OOBE.
bool oobe_ui_;
- // Is focus still stolen from Gaia page?
- bool focus_stolen_;
-
- // Has Gaia page silent load been started for the current sign-in attempt?
- bool gaia_silent_load_;
-
- // The active network at the moment when Gaia page was preloaded.
- std::string gaia_silent_load_network_;
-
// Is account picker being shown for the first time.
bool is_account_picker_showing_first_time_;
- // True if dns cache cleanup is done.
- bool dns_cleared_;
-
- // True if DNS cache task is already running.
- bool dns_clear_task_running_;
-
- // True if cookie jar cleanup is done.
- bool cookies_cleared_;
-
- // Help application used for help dialogs.
- scoped_refptr<HelpAppLauncher> help_app_;
-
// Network state informer used to keep signin screen up.
scoped_refptr<NetworkStateInformer> network_state_informer_;
- // Email to pre-populate with.
- std::string email_;
- // Emails of the users, whose passwords have recently been changed.
- std::set<std::string> password_changed_for_;
-
- // If the user authenticated via SAML, this indicates whether the principals
- // API was used.
- bool using_saml_api_;
-
- // Test credentials.
- std::string test_user_;
- std::string test_pass_;
- bool test_expects_complete_login_;
-
- base::WeakPtrFactory<SigninScreenHandler> weak_factory_;
-
// Set to true once |LOGIN_WEBUI_VISIBLE| notification is observed.
bool webui_visible_;
bool preferences_changed_delayed_;
// NOTIFICATION_AUTH_CANCELLED.
bool has_pending_auth_ui_;
- scoped_ptr<CrosSettings::ObserverSubscription> allow_new_user_subscription_;
- scoped_ptr<CrosSettings::ObserverSubscription> allow_guest_subscription_;
+ scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
+ auto_enrollment_progress_subscription_;
- bool wait_for_auto_enrollment_check_;
+ bool caps_lock_enabled_;
base::Closure kiosk_enable_flow_aborted_callback_for_test_;
- // Map of callbacks run when the custom button on a user pod is clicked.
- std::map<std::string, base::Closure> user_pod_button_callback_map_;
-
// Non-owning ptr.
- // TODO (ygorshenin@): remove this dependency.
+ // TODO(ygorshenin@): remove this dependency.
GaiaScreenHandler* gaia_screen_handler_;
// Helper that retrieves the authenticated user's e-mail address.
scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_;
+ // Whether consumer management enrollment is in progress.
+ bool is_enrolling_consumer_management_;
+
+ base::WeakPtrFactory<SigninScreenHandler> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler);
};