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/webui_login_display.h" | 5 #include "chrome/browser/chromeos/login/webui_login_display.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/login/webui_login_view.h" | 7 #include "chrome/browser/chromeos/login/webui_login_view.h" |
8 #include "chrome/browser/chromeos/wm_ipc.h" | 8 #include "chrome/browser/chromeos/wm_ipc.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "views/widget/widget.h" | 11 #include "views/widget/widget.h" |
12 | 12 |
13 #if defined(TOUCH_UI) | 13 #if defined(TOUCH_UI) |
14 #include "chrome/browser/chromeos/login/touch_login_view.h" | 14 #include "chrome/browser/chromeos/login/touch_login_view.h" |
15 #endif | 15 #endif |
16 | 16 |
17 namespace { | |
18 const char kLoginURL[] = "chrome://login"; | |
19 } // namespace | |
20 | |
21 namespace chromeos { | 17 namespace chromeos { |
22 | 18 |
23 // WebUILoginDisplay, public: -------------------------------------------------- | 19 // WebUILoginDisplay, public: -------------------------------------------------- |
24 | 20 |
25 WebUILoginDisplay::~WebUILoginDisplay() { | 21 WebUILoginDisplay::~WebUILoginDisplay() { |
26 if (login_window_) | |
27 login_window_->Close(); | |
28 } | 22 } |
29 | 23 |
30 // WebUILoginDisplay, Singleton implementation: -------------------------------- | 24 // WebUILoginDisplay, Singleton implementation: -------------------------------- |
31 | 25 |
32 // static | 26 // static |
33 WebUILoginDisplay* WebUILoginDisplay::GetInstance() { | 27 WebUILoginDisplay* WebUILoginDisplay::GetInstance() { |
34 return Singleton<WebUILoginDisplay>::get(); | 28 return Singleton<WebUILoginDisplay>::get(); |
35 } | 29 } |
36 | 30 |
37 // LoginDisplay implementation: ------------------------------------------------ | 31 // LoginDisplay implementation: ------------------------------------------------ |
38 | 32 |
39 // static | 33 // static |
40 views::Widget* WebUILoginDisplay::GetLoginWindow() { | 34 views::Widget* WebUILoginDisplay::GetLoginWindow() { |
41 return WebUILoginDisplay::GetInstance()->LoginWindow(); | 35 return WebUILoginDisplay::GetInstance()->LoginWindow(); |
42 } | 36 } |
43 | 37 |
44 views::Widget* WebUILoginDisplay::LoginWindow() { | 38 views::Widget* WebUILoginDisplay::LoginWindow() { |
45 return login_window_; | 39 return login_window_; |
46 } | 40 } |
47 | 41 |
48 void WebUILoginDisplay::Destroy() { | 42 void WebUILoginDisplay::Destroy() { |
49 background_bounds_ = gfx::Rect(); | 43 background_bounds_ = gfx::Rect(); |
50 delegate_ = NULL; | 44 delegate_ = NULL; |
51 | |
52 if (login_window_) | |
53 login_window_->Close(); | |
54 | |
55 login_window_ = NULL; | |
56 } | 45 } |
57 | 46 |
58 // TODO(rharrison): Add mechanism to pass in the show_guest and show_new_user | 47 // TODO(rharrison): Add mechanism to pass in the show_guest and show_new_user |
59 // values. | 48 // values. |
60 void WebUILoginDisplay::Init(const std::vector<UserManager::User>& users, | 49 void WebUILoginDisplay::Init(const std::vector<UserManager::User>& users, |
61 bool show_guest, | 50 bool show_guest, |
62 bool show_new_user) { | 51 bool show_new_user) { |
63 // Testing that the delegate has been set. | 52 // Testing that the delegate has been set. |
64 DCHECK(delegate_); | 53 DCHECK(delegate_); |
| 54 |
65 users_ = users; | 55 users_ = users; |
66 | |
67 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | |
68 params.bounds = background_bounds_; | |
69 | |
70 login_window_ = new views::Widget; | |
71 login_window_->Init(params); | |
72 | |
73 #if defined(TOUCH_UI) | |
74 TouchLoginView* login_view = new TouchLoginView(); | |
75 #else | |
76 WebUILoginView* login_view = new WebUILoginView(); | |
77 #endif | |
78 login_view->Init(GURL(kLoginURL)); | |
79 login_window_->SetContentsView(login_view); | |
80 login_view->UpdateWindowType(); | |
81 | |
82 login_window_->Show(); | |
83 } | 56 } |
84 | 57 |
85 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { | 58 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { |
86 // TODO(rharrison): Figure out if I need to split anything between this and | 59 // TODO(rharrison): Figure out if I need to split anything between this and |
87 // OnUserRemoved | 60 // OnUserRemoved |
88 } | 61 } |
89 | 62 |
90 void WebUILoginDisplay::OnUserImageChanged(UserManager::User* user) { | 63 void WebUILoginDisplay::OnUserImageChanged(UserManager::User* user) { |
91 // TODO(rharrison): Update the user in the user vector | 64 // TODO(rharrison): Update the user in the user vector |
92 // TODO(rharrison): Push the change to WebUI Login screen | 65 // TODO(rharrison): Push the change to WebUI Login screen |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 109 |
137 // Singleton implementation: --------------------------------------------------- | 110 // Singleton implementation: --------------------------------------------------- |
138 | 111 |
139 WebUILoginDisplay::WebUILoginDisplay() | 112 WebUILoginDisplay::WebUILoginDisplay() |
140 : LoginDisplay(NULL, gfx::Rect()), | 113 : LoginDisplay(NULL, gfx::Rect()), |
141 LoginUIHandlerDelegate(), | 114 LoginUIHandlerDelegate(), |
142 login_window_(NULL) { | 115 login_window_(NULL) { |
143 } | 116 } |
144 | 117 |
145 } // namespace chromeos | 118 } // namespace chromeos |
OLD | NEW |