Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 namespace chromeos { | 109 namespace chromeos { |
| 110 | 110 |
| 111 // WebUILoginView public: ------------------------------------------------------ | 111 // WebUILoginView public: ------------------------------------------------------ |
| 112 | 112 |
| 113 WebUILoginView::WebUILoginView() | 113 WebUILoginView::WebUILoginView() |
| 114 : webui_login_(NULL), | 114 : webui_login_(NULL), |
| 115 login_window_(NULL), | 115 login_window_(NULL), |
| 116 host_window_frozen_(false), | 116 host_window_frozen_(false), |
| 117 login_page_is_loaded_(false), | 117 login_page_is_loaded_(false), |
| 118 login_prompt_visible_notified_(false), | |
| 118 should_emit_login_prompt_visible_(true) { | 119 should_emit_login_prompt_visible_(true) { |
| 119 | 120 |
| 120 registrar_.Add(this, | 121 registrar_.Add(this, |
| 121 chrome::NOTIFICATION_LOGIN_WEBUI_READY, | 122 chrome::NOTIFICATION_LOGIN_WEBUI_READY, |
| 122 content::NotificationService::AllSources()); | 123 content::NotificationService::AllSources()); |
| 123 registrar_.Add(this, | 124 registrar_.Add(this, |
| 124 chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED, | 125 chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED, |
| 125 content::NotificationService::AllSources()); | 126 content::NotificationService::AllSources()); |
| 126 registrar_.Add(this, | 127 registrar_.Add(this, |
| 127 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | 128 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 } | 273 } |
| 273 | 274 |
| 274 void WebUILoginView::OnTabMainFrameLoaded() { | 275 void WebUILoginView::OnTabMainFrameLoaded() { |
| 275 VLOG(1) << "WebUI login main frame loaded."; | 276 VLOG(1) << "WebUI login main frame loaded."; |
| 276 } | 277 } |
| 277 | 278 |
| 278 void WebUILoginView::OnTabMainFrameRender() { | 279 void WebUILoginView::OnTabMainFrameRender() { |
| 279 if (!login_page_is_loaded_) | 280 if (!login_page_is_loaded_) |
| 280 return; | 281 return; |
| 281 | 282 |
| 282 VLOG(1) << "WebUI login main frame rendered."; | 283 OnLoginPromptVisible(); |
| 283 tab_watcher_.reset(); | |
| 284 | |
| 285 if (should_emit_login_prompt_visible_) { | |
| 286 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | |
| 287 EmitLoginPromptVisible(); | |
| 288 } | |
| 289 | |
| 290 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); | |
| 291 // Notify OOBE that the login frame has been rendered. Currently | |
| 292 // this is used to start camera presence check. | |
| 293 oobe_ui->OnLoginPromptVisible(); | |
| 294 } | 284 } |
| 295 | 285 |
| 296 void WebUILoginView::Observe(int type, | 286 void WebUILoginView::Observe(int type, |
| 297 const content::NotificationSource& source, | 287 const content::NotificationSource& source, |
| 298 const content::NotificationDetails& details) { | 288 const content::NotificationDetails& details) { |
| 299 switch (type) { | 289 switch (type) { |
| 300 case chrome::NOTIFICATION_LOGIN_WEBUI_READY: | 290 case chrome::NOTIFICATION_LOGIN_WEBUI_READY: |
| 301 case chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED: | 291 case chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED: |
| 302 case chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN: | 292 case chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN: |
| 303 case chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN: | 293 case chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN: |
| 294 VLOG(1) << "===================== WebUI login ready notification"; | |
| 304 login_page_is_loaded_ = true; | 295 login_page_is_loaded_ = true; |
| 296 // In case of accelerated compositing being enabled at sign in screen, | |
| 297 // no more OnTabMainFrameRender() calls are being made after | |
| 298 // OnTabMainFrameLoaded() or after any of these notifications is received. | |
| 299 // So mark sign in screen as visible now. | |
| 300 // TODO(nkostylev): Improve OOBE case as with accelerated compositing | |
| 301 // using NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN is not correct cause | |
| 302 // it fires login-prompt-visible before login-prompt-ready. | |
| 303 if (IsAcceleratedCompositingEnabled()) | |
| 304 OnLoginPromptVisible(); | |
| 305 break; | 305 break; |
| 306 default: | 306 default: |
| 307 NOTREACHED() << "Unexpected notification " << type; | 307 NOTREACHED() << "Unexpected notification " << type; |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 // WebUILoginView private: ----------------------------------------------------- | 311 // WebUILoginView private: ----------------------------------------------------- |
| 312 | 312 |
| 313 bool WebUILoginView::HandleContextMenu( | 313 bool WebUILoginView::HandleContextMenu( |
| 314 const content::ContextMenuParams& params) { | 314 const content::ContextMenuParams& params) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 342 ash::SystemTray* tray = ash::Shell::GetInstance()->tray(); | 342 ash::SystemTray* tray = ash::Shell::GetInstance()->tray(); |
| 343 if (tray && tray->GetWidget()->IsVisible()) { | 343 if (tray && tray->GetWidget()->IsVisible()) { |
| 344 tray->SetNextFocusableView(this); | 344 tray->SetNextFocusableView(this); |
| 345 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : | 345 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : |
| 346 ash::Shell::FORWARD); | 346 ash::Shell::FORWARD); |
| 347 } | 347 } |
| 348 | 348 |
| 349 return true; | 349 return true; |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool WebUILoginView::IsAcceleratedCompositingEnabled() { | |
| 353 // TODO(nkostylev): Temporary check, should be modified once | |
| 354 // http://crbug.com/116800 is fixed and if this switch is removed. | |
| 355 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 356 return command_line.HasSwitch(switches::kAllowWebUICompositing); | |
|
Daniel Erat
2012/05/28 15:20:53
is there any risk that this might not get updated
Nikita (slow)
2012/05/28 15:55:05
I've actually thought that when accelerated compos
| |
| 357 } | |
| 358 | |
| 359 void WebUILoginView::OnLoginPromptVisible() { | |
| 360 if (login_prompt_visible_notified_) | |
| 361 return; | |
| 362 | |
| 363 login_prompt_visible_notified_ = true; | |
| 364 tab_watcher_.reset(); | |
| 365 | |
| 366 if (should_emit_login_prompt_visible_) { | |
| 367 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | |
| 368 EmitLoginPromptVisible(); | |
| 369 } | |
| 370 | |
| 371 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); | |
| 372 // Notify OOBE that the login frame has been rendered. Currently | |
| 373 // this is used to start camera presence check. | |
| 374 oobe_ui->OnLoginPromptVisible(); | |
| 375 } | |
| 376 | |
| 352 void WebUILoginView::ReturnFocus(bool reverse) { | 377 void WebUILoginView::ReturnFocus(bool reverse) { |
| 353 // Return the focus to the web contents. | 378 // Return the focus to the web contents. |
| 354 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 379 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
| 355 GetWidget()->Activate(); | 380 GetWidget()->Activate(); |
| 356 } | 381 } |
| 357 | 382 |
| 358 } // namespace chromeos | 383 } // namespace chromeos |
| OLD | NEW |