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