| 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/dom_login_display.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/frame/dom_browser.h" | |
| 8 #include "chrome/browser/chromeos/wm_ipc.h" | 7 #include "chrome/browser/chromeos/wm_ipc.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.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 // DOMLoginDisplay, public: --------------------------------------------------- |
| 19 | 19 |
| 20 DOMLoginDisplay::~DOMLoginDisplay() { | 20 DOMLoginDisplay::~DOMLoginDisplay() { |
| 21 if (login_screen_) | 21 if (webui_login_window_) |
| 22 login_screen_->CloseWindow(); | 22 webui_login_window_->Close(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 // DOMLoginDisplay, Singleton implementation: ---------------------------------- | 25 // DOMLoginDisplay, Singleton implementation: ---------------------------------- |
| 26 | 26 |
| 27 // static | 27 // static |
| 28 DOMLoginDisplay* DOMLoginDisplay::GetInstance() { | 28 DOMLoginDisplay* DOMLoginDisplay::GetInstance() { |
| 29 return Singleton<DOMLoginDisplay>::get(); | 29 return Singleton<DOMLoginDisplay>::get(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // LoginDisplay implementation: ------------------------------------------------ | 32 // LoginDisplay implementation: ------------------------------------------------ |
| 33 | 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 |
| 34 void DOMLoginDisplay::Destroy() { | 43 void DOMLoginDisplay::Destroy() { |
| 35 background_bounds_ = gfx::Rect(); | 44 background_bounds_ = gfx::Rect(); |
| 36 delegate_ = NULL; | 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; |
| 37 } | 52 } |
| 38 | 53 |
| 39 void DOMLoginDisplay::Init(const std::vector<UserManager::User>& users, | 54 void DOMLoginDisplay::Init(const std::vector<UserManager::User>& users, |
| 40 bool show_guest, | 55 bool show_guest, |
| 41 bool show_new_user) { | 56 bool show_new_user) { |
| 42 // Testing that the delegate has been set. | 57 // Testing that the delegate has been set. |
| 43 DCHECK(delegate_); | 58 DCHECK(delegate_); |
| 44 users_ = users; | 59 users_ = users; |
| 45 | 60 |
| 46 // 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 |
| 47 // values. | 62 // values. |
| 48 login_screen_ = DOMBrowser::CreateForDOM(ProfileManager::GetDefaultProfile()); | 63 webui_login_window_ = WebUILoginView::CreateWindowContainingView( |
| 49 login_screen_->AddSelectedTabWithURL(GURL(kLoginURL), | 64 background_bounds_, |
| 50 PageTransition::START_PAGE); | 65 GURL(kLoginURL), |
| 51 login_screen_->window()->Show(); | 66 &webui_login_view_); |
| 67 webui_login_window_->Show(); |
| 52 } | 68 } |
| 53 | 69 |
| 54 void DOMLoginDisplay::OnBeforeUserRemoved(const std::string& username) { | 70 void DOMLoginDisplay::OnBeforeUserRemoved(const std::string& username) { |
| 55 // 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 |
| 56 // OnUserRemoved | 72 // OnUserRemoved |
| 57 } | 73 } |
| 58 | 74 |
| 59 void DOMLoginDisplay::OnUserImageChanged(UserManager::User* user) { | 75 void DOMLoginDisplay::OnUserImageChanged(UserManager::User* user) { |
| 60 // TODO(rharrison): Update the user in the user vector | 76 // TODO(rharrison): Update the user in the user vector |
| 61 // TODO(rharrison): Push the change to DOM Login screen | 77 // TODO(rharrison): Push the change to DOM Login screen |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 delegate_->LoginAsGuest(); | 113 delegate_->LoginAsGuest(); |
| 98 } | 114 } |
| 99 | 115 |
| 100 // DOMLoginDisplay, private: --------------------------------------------------- | 116 // DOMLoginDisplay, private: --------------------------------------------------- |
| 101 | 117 |
| 102 // Singleton implementation: --------------------------------------------------- | 118 // Singleton implementation: --------------------------------------------------- |
| 103 | 119 |
| 104 DOMLoginDisplay::DOMLoginDisplay() | 120 DOMLoginDisplay::DOMLoginDisplay() |
| 105 : LoginDisplay(NULL, gfx::Rect()), | 121 : LoginDisplay(NULL, gfx::Rect()), |
| 106 LoginUIHandlerDelegate(), | 122 LoginUIHandlerDelegate(), |
| 107 login_screen_(NULL) {} | 123 webui_login_view_(NULL), |
| 124 webui_login_window_(NULL) { |
| 125 } |
| 108 | 126 |
| 109 } // namespace chromeos | 127 } // namespace chromeos |
| OLD | NEW |