• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chrome/browser/chromeos/login/dom_login_display.h"
6 
7 #include "chrome/browser/chromeos/frame/dom_browser.h"
8 #include "chrome/browser/chromeos/wm_ipc.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_window.h"
11 
12 namespace {
13 const char kLoginURL[] = "chrome://login";
14 }  // namespace
15 
16 namespace chromeos {
17 
18 // DOMLoginDisplay, public: ---------------------------------------------------
19 
~DOMLoginDisplay()20 DOMLoginDisplay::~DOMLoginDisplay() {
21   if (login_screen_)
22     login_screen_->CloseWindow();
23 }
24 
25 // DOMLoginDisplay, Singleton implementation: ----------------------------------
26 
27 // static
GetInstance()28 DOMLoginDisplay* DOMLoginDisplay::GetInstance() {
29   return Singleton<DOMLoginDisplay>::get();
30 }
31 
32 // LoginDisplay implementation: ------------------------------------------------
33 
Destroy()34 void DOMLoginDisplay::Destroy() {
35   background_bounds_ = gfx::Rect();
36   delegate_ = NULL;
37 }
38 
Init(const std::vector<UserManager::User> & users,bool show_guest,bool show_new_user)39 void DOMLoginDisplay::Init(const std::vector<UserManager::User>& users,
40                            bool show_guest,
41                            bool show_new_user) {
42   // Testing that the delegate has been set.
43   DCHECK(delegate_);
44   users_ = users;
45 
46   // TODO(rharrison): Add mechanism to pass in the show_guest and show_new_user
47   // values.
48   login_screen_ = DOMBrowser::CreateForDOM(ProfileManager::GetDefaultProfile());
49   login_screen_->AddSelectedTabWithURL(GURL(kLoginURL),
50                                        PageTransition::START_PAGE);
51   login_screen_->window()->Show();
52 }
53 
OnBeforeUserRemoved(const std::string & username)54 void DOMLoginDisplay::OnBeforeUserRemoved(const std::string& username) {
55   // TODO(rharrison): Figure out if I need to split anything between this and
56   // OnUserRemoved
57 }
58 
OnUserImageChanged(UserManager::User * user)59 void DOMLoginDisplay::OnUserImageChanged(UserManager::User* user) {
60   // TODO(rharrison): Update the user in the user vector
61   // TODO(rharrison): Push the change to DOM Login screen
62 }
63 
OnUserRemoved(const std::string & username)64 void DOMLoginDisplay::OnUserRemoved(const std::string& username) {
65   // TODO(rharrison): Remove the user from the user vector
66   // TODO(rharrison): Push the change to DOM Login screen
67 }
68 
OnFadeOut()69 void DOMLoginDisplay::OnFadeOut() { }
70 
SetUIEnabled(bool is_enabled)71 void DOMLoginDisplay::SetUIEnabled(bool is_enabled) {
72   // Send message to WM to enable/disable click on windows.
73   WmIpc::Message message(WM_IPC_MESSAGE_WM_SET_LOGIN_STATE);
74   message.set_param(0, is_enabled);
75   WmIpc::instance()->SendMessage(message);
76 
77   if (is_enabled)
78     login_handler_->ClearAndEnablePassword();
79 }
80 
ShowError(int error_msg_id,int login_attempts,HelpAppLauncher::HelpTopic help_topic_id)81 void DOMLoginDisplay::ShowError(int error_msg_id,
82                                 int login_attempts,
83                                 HelpAppLauncher::HelpTopic help_topic_id) {
84   // TODO(rharrison): Figure out what we should be doing here
85 }
86 
87 // DOMLoginDisplay, LoginUIHandlerDelegate implementation: ---------------------
88 
Login(const std::string & username,const std::string & password)89 void DOMLoginDisplay::Login(const std::string& username,
90                             const std::string& password) {
91   DCHECK(delegate_);
92   delegate_->Login(username, password);
93 }
94 
LoginAsGuest()95 void DOMLoginDisplay::LoginAsGuest() {
96   DCHECK(delegate_);
97   delegate_->LoginAsGuest();
98 }
99 
100 // DOMLoginDisplay, private: ---------------------------------------------------
101 
102 // Singleton implementation: ---------------------------------------------------
103 
DOMLoginDisplay()104 DOMLoginDisplay::DOMLoginDisplay()
105     : LoginDisplay(NULL, gfx::Rect()),
106       LoginUIHandlerDelegate(),
107       login_screen_(NULL) {}
108 
109 }  // namespace chromeos
110