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_DOM_LOGIN_DISPLAY_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_DOM_LOGIN_DISPLAY_H_ 7 #pragma once 8 9 #include <vector> 10 11 #include "base/memory/singleton.h" 12 #include "base/scoped_ptr.h" 13 #include "chrome/browser/chromeos/login/login_display.h" 14 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/ui/webui/chromeos/login/login_ui.h" 16 17 namespace gfx { 18 class Rect; 19 } // namespace gfx 20 21 namespace chromeos { 22 23 class DOMBrowser; 24 25 // DOM-based login UI implementation. 26 // This class is a Singleton. It allows the LoginDisplayHost and LoginUIHandler 27 // to access it without having to be coupled with each other. It is created with 28 // NULL for the delegate and a 0-size rectangle for the background 29 // bounds. Before use these values should be set to a sane value. When done with 30 // the object, the ExistingUserController should call Destroy and not free the 31 // pointer, where as accessing classes should do nothing with the pointer. 32 // 33 // Expected order of commands to setup for LoginDisplayHost: 34 // DOMLoginDisplay::GetInstance(); 35 // set_delegate(delegate); 36 // set_background_bounds(background_bounds()); 37 // Init(); 38 // 39 // Expected order of commands to setup for LoginUIHandler: 40 // DOMLoginDisplay::GetInstance(); 41 // set_login_handler(this); 42 43 class DOMLoginDisplay : public LoginDisplay, 44 public LoginUIHandlerDelegate { 45 public: 46 virtual ~DOMLoginDisplay(); 47 48 // Singleton implementation: 49 static DOMLoginDisplay* GetInstance(); 50 51 // LoginDisplay implementation: 52 virtual void Destroy() OVERRIDE; 53 virtual void Init(const std::vector<UserManager::User>& users, 54 bool show_guest, 55 bool show_new_user) OVERRIDE; 56 virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE; 57 virtual void OnUserImageChanged(UserManager::User* user) OVERRIDE; 58 virtual void OnUserRemoved(const std::string& username) OVERRIDE; 59 virtual void OnFadeOut() OVERRIDE; 60 virtual void SetUIEnabled(bool is_enabled) OVERRIDE; 61 virtual void ShowError(int error_msg_id, 62 int login_attempts, 63 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; 64 65 // LoginUIHandlerDelegate 66 virtual void Login(const std::string& username, 67 const std::string& password) OVERRIDE; 68 virtual void LoginAsGuest() OVERRIDE; 69 70 private: 71 // Singleton implementation: 72 friend struct DefaultSingletonTraits<DOMLoginDisplay>; 73 DOMLoginDisplay(); 74 75 // Set of Users in the systemvisible UserControllers. 76 std::vector<UserManager::User> users_; 77 78 // Container of the screen we are displaying 79 DOMBrowser* login_screen_; 80 81 DISALLOW_COPY_AND_ASSIGN(DOMLoginDisplay); 82 }; 83 84 } // namespace chromeos 85 86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_DOM_LOGIN_DISPLAY_H_ 87