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