OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view.h" | 5 #include "chrome/browser/chromeos/login/webui_login_view.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } // namespace | 106 } // namespace |
107 | 107 |
108 namespace chromeos { | 108 namespace chromeos { |
109 | 109 |
110 // WebUILoginView public: ------------------------------------------------------ | 110 // WebUILoginView public: ------------------------------------------------------ |
111 | 111 |
112 WebUILoginView::WebUILoginView() | 112 WebUILoginView::WebUILoginView() |
113 : webui_login_(NULL), | 113 : webui_login_(NULL), |
114 login_window_(NULL), | 114 login_window_(NULL), |
115 host_window_frozen_(false), | 115 host_window_frozen_(false), |
116 login_page_is_loaded_(false), | |
117 should_emit_login_prompt_visible_(true) { | 116 should_emit_login_prompt_visible_(true) { |
118 | |
119 registrar_.Add(this, | 117 registrar_.Add(this, |
120 chrome::NOTIFICATION_LOGIN_WEBUI_READY, | 118 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
121 content::NotificationService::AllSources()); | |
122 registrar_.Add(this, | |
123 chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED, | |
124 content::NotificationService::AllSources()); | |
125 registrar_.Add(this, | |
126 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | |
127 content::NotificationService::AllSources()); | |
128 registrar_.Add(this, | |
129 chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN, | |
130 content::NotificationService::AllSources()); | 119 content::NotificationService::AllSources()); |
131 | 120 |
132 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = | 121 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = |
133 kAccelNameCancel; | 122 kAccelNameCancel; |
134 accel_map_[ui::Accelerator(ui::VKEY_E, | 123 accel_map_[ui::Accelerator(ui::VKEY_E, |
135 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] = | 124 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] = |
136 kAccelNameEnrollment; | 125 kAccelNameEnrollment; |
137 accel_map_[ui::Accelerator(ui::VKEY_V, ui::EF_ALT_DOWN)] = | 126 accel_map_[ui::Accelerator(ui::VKEY_V, ui::EF_ALT_DOWN)] = |
138 kAccelNameVersion; | 127 kAccelNameVersion; |
139 | 128 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 254 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
266 GetWidget()->Activate(); | 255 GetWidget()->Activate(); |
267 } | 256 } |
268 | 257 |
269 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { | 258 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { |
270 new SnifferObserver(host, GetWebUI()); | 259 new SnifferObserver(host, GetWebUI()); |
271 } | 260 } |
272 | 261 |
273 void WebUILoginView::OnTabMainFrameLoaded() { | 262 void WebUILoginView::OnTabMainFrameLoaded() { |
274 VLOG(1) << "WebUI login main frame loaded."; | 263 VLOG(1) << "WebUI login main frame loaded."; |
| 264 tab_watcher_.reset(); |
275 } | 265 } |
276 | 266 |
277 void WebUILoginView::OnTabMainFrameRender() { | 267 void WebUILoginView::OnTabMainFrameRender() { |
278 if (!login_page_is_loaded_) | |
279 return; | |
280 | |
281 VLOG(1) << "WebUI login main frame rendered."; | |
282 tab_watcher_.reset(); | |
283 | |
284 if (should_emit_login_prompt_visible_) { | |
285 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | |
286 EmitLoginPromptVisible(); | |
287 } | |
288 | |
289 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); | |
290 // Notify OOBE that the login frame has been rendered. Currently | |
291 // this is used to start camera presence check. | |
292 oobe_ui->OnLoginPromptVisible(); | |
293 } | 268 } |
294 | 269 |
295 void WebUILoginView::Observe(int type, | 270 void WebUILoginView::Observe(int type, |
296 const content::NotificationSource& source, | 271 const content::NotificationSource& source, |
297 const content::NotificationDetails& details) { | 272 const content::NotificationDetails& details) { |
298 switch (type) { | 273 switch (type) { |
299 case chrome::NOTIFICATION_LOGIN_WEBUI_READY: | 274 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: |
300 case chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED: | 275 OnLoginPromptVisible(); |
301 case chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN: | 276 registrar_.RemoveAll(); |
302 case chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN: | |
303 login_page_is_loaded_ = true; | |
304 break; | 277 break; |
305 default: | 278 default: |
306 NOTREACHED() << "Unexpected notification " << type; | 279 NOTREACHED() << "Unexpected notification " << type; |
307 } | 280 } |
308 } | 281 } |
309 | 282 |
310 // WebUILoginView private: ----------------------------------------------------- | 283 // WebUILoginView private: ----------------------------------------------------- |
311 | 284 |
312 bool WebUILoginView::HandleContextMenu( | 285 bool WebUILoginView::HandleContextMenu( |
313 const content::ContextMenuParams& params) { | 286 const content::ContextMenuParams& params) { |
(...skipping 27 matching lines...) Expand all Loading... |
341 ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray(); | 314 ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray(); |
342 if (tray && tray->GetWidget()->IsVisible()) { | 315 if (tray && tray->GetWidget()->IsVisible()) { |
343 tray->SetNextFocusableView(this); | 316 tray->SetNextFocusableView(this); |
344 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : | 317 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : |
345 ash::Shell::FORWARD); | 318 ash::Shell::FORWARD); |
346 } | 319 } |
347 | 320 |
348 return true; | 321 return true; |
349 } | 322 } |
350 | 323 |
| 324 void WebUILoginView::OnLoginPromptVisible() { |
| 325 if (should_emit_login_prompt_visible_) { |
| 326 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 327 EmitLoginPromptVisible(); |
| 328 } |
| 329 |
| 330 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); |
| 331 // Notify OOBE that the login frame has been rendered. Currently |
| 332 // this is used to start camera presence check. |
| 333 oobe_ui->OnLoginPromptVisible(); |
| 334 } |
| 335 |
351 void WebUILoginView::ReturnFocus(bool reverse) { | 336 void WebUILoginView::ReturnFocus(bool reverse) { |
352 // Return the focus to the web contents. | 337 // Return the focus to the web contents. |
353 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 338 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
354 GetWidget()->Activate(); | 339 GetWidget()->Activate(); |
355 } | 340 } |
356 | 341 |
357 } // namespace chromeos | 342 } // namespace chromeos |
OLD | NEW |