1 // Copyright (c) 2011 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_VIEWS_LOGIN_DISPLAY_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_VIEWS_LOGIN_DISPLAY_H_ 7 #pragma once 8 9 #include <string> 10 #include <vector> 11 12 #include "base/compiler_specific.h" 13 #include "base/memory/ref_counted.h" 14 #include "chrome/browser/chromeos/login/login_display.h" 15 #include "chrome/browser/chromeos/login/message_bubble.h" 16 #include "chrome/browser/chromeos/login/user_controller.h" 17 #include "ui/gfx/rect.h" 18 19 namespace chromeos { 20 21 class HelpAppLauncher; 22 class MessageBubble; 23 24 // Views-based login UI implementation. 25 // Uses UserController for each user pod / guest pod / new user pod and 26 // ExistingUserView / GuestUserView / NewUserView as their views. 27 // When Init is invoked, a UserController is created for each of the Users's 28 // in the UserManager (including one for new user and one for Guest login), 29 // and the window manager is then told to show the windows. 30 class ViewsLoginDisplay : public LoginDisplay, 31 public UserController::Delegate, 32 public MessageBubbleDelegate { 33 public: 34 ViewsLoginDisplay(LoginDisplay::Delegate* delegate, 35 const gfx::Rect& background_bounds); 36 virtual ~ViewsLoginDisplay(); 37 38 // LoginDisplay implementation: 39 virtual void Init(const std::vector<UserManager::User>& users, 40 bool show_guest, 41 bool show_new_user); 42 virtual void OnBeforeUserRemoved(const std::string& username); 43 virtual void OnUserImageChanged(UserManager::User* user); 44 virtual void OnUserRemoved(const std::string& username); 45 virtual void OnFadeOut(); 46 virtual void SetUIEnabled(bool is_enabled); 47 virtual void ShowError(int error_msg_id, 48 int login_attempts, 49 HelpAppLauncher::HelpTopic help_topic_id); 50 51 // UserController::Delegate implementation: 52 virtual void CreateAccount() OVERRIDE; 53 virtual void Login(UserController* source, const string16& password) OVERRIDE; 54 virtual void LoginAsGuest() OVERRIDE; 55 virtual void ClearErrors() OVERRIDE; 56 virtual void OnUserSelected(UserController* source) OVERRIDE; 57 virtual void RemoveUser(UserController* source) OVERRIDE; 58 virtual void SelectUser(int index) OVERRIDE; 59 virtual void StartEnterpriseEnrollment() OVERRIDE; 60 61 // Overridden from views::MessageBubbleDelegate: 62 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) { 63 bubble_ = NULL; 64 } 65 virtual bool CloseOnEscape() { return true; } 66 virtual bool FadeInOnShow() { return false; } 67 virtual void OnHelpLinkActivated(); 68 69 private: 70 // Returns existing UserController instance by |email|. 71 // NULL is returned if relevant instance is not found. 72 UserController* GetUserControllerByEmail(const std::string& email); 73 74 // Pointer to shown message bubble. We don't need to delete it because 75 // it will be deleted on bubble closing. 76 MessageBubble* bubble_; 77 78 // UserController that corresponds user that's in process of being removed. 79 // Has meaningful value only between OnBeforeUserRemoved() 80 // and OnUserRemoved() calls. 81 UserController* controller_for_removal_; 82 83 // The set of visible UserControllers. 84 std::vector<UserController*> controllers_; 85 86 // Last error message ID. 87 int error_msg_id_; 88 89 // Help application used for help dialogs. 90 scoped_refptr<HelpAppLauncher> help_app_; 91 92 // Last error help topic ID. 93 HelpAppLauncher::HelpTopic help_topic_id_; 94 95 // The set of invisible UserControllers. 96 std::vector<UserController*> invisible_controllers_; 97 98 // Index of selected user (from the set of visible users). 99 size_t selected_view_index_; 100 101 DISALLOW_COPY_AND_ASSIGN(ViewsLoginDisplay); 102 }; 103 104 } // namespace chromeos 105 106 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VIEWS_LOGIN_DISPLAY_H_ 107