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 } // namespace | 108 } // namespace |
109 | 109 |
110 namespace chromeos { | 110 namespace chromeos { |
111 | 111 |
112 // WebUILoginView public: ------------------------------------------------------ | 112 // WebUILoginView public: ------------------------------------------------------ |
113 | 113 |
114 WebUILoginView::WebUILoginView() | 114 WebUILoginView::WebUILoginView() |
115 : webui_login_(NULL), | 115 : webui_login_(NULL), |
116 login_window_(NULL), | 116 login_window_(NULL), |
117 host_window_frozen_(false), | 117 host_window_frozen_(false), |
| 118 is_hidden_(false), |
| 119 login_visible_notification_fired_(false), |
| 120 login_prompt_visible_handled_(false), |
118 should_emit_login_prompt_visible_(true) { | 121 should_emit_login_prompt_visible_(true) { |
119 registrar_.Add(this, | 122 registrar_.Add(this, |
120 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, | 123 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
121 content::NotificationService::AllSources()); | 124 content::NotificationService::AllSources()); |
122 | 125 |
123 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = | 126 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = |
124 kAccelNameCancel; | 127 kAccelNameCancel; |
125 accel_map_[ui::Accelerator(ui::VKEY_E, | 128 accel_map_[ui::Accelerator(ui::VKEY_E, |
126 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] = | 129 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] = |
127 kAccelNameEnrollment; | 130 kAccelNameEnrollment; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 content::WebContents* WebUILoginView::GetWebContents() { | 227 content::WebContents* WebUILoginView::GetWebContents() { |
225 return webui_login_->web_contents(); | 228 return webui_login_->web_contents(); |
226 } | 229 } |
227 | 230 |
228 void WebUILoginView::OpenProxySettings() { | 231 void WebUILoginView::OpenProxySettings() { |
229 ProxySettingsDialog* dialog = | 232 ProxySettingsDialog* dialog = |
230 new ProxySettingsDialog(NULL, GetNativeWindow()); | 233 new ProxySettingsDialog(NULL, GetNativeWindow()); |
231 dialog->Show(); | 234 dialog->Show(); |
232 } | 235 } |
233 | 236 |
| 237 void WebUILoginView::OnPostponedShow() { |
| 238 set_is_hidden(false); |
| 239 // If notification will happen later let it fire login-prompt-visible signal. |
| 240 if (login_visible_notification_fired_) |
| 241 OnLoginPromptVisible(); |
| 242 } |
| 243 |
234 void WebUILoginView::SetStatusAreaVisible(bool visible) { | 244 void WebUILoginView::SetStatusAreaVisible(bool visible) { |
235 ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray(); | 245 ash::SystemTray* tray = ash::Shell::GetInstance()->system_tray(); |
236 if (tray) { | 246 if (tray) { |
237 if (visible) { | 247 if (visible) { |
238 // Tray may have been initialized being hidden. | 248 // Tray may have been initialized being hidden. |
239 tray->SetVisible(visible); | 249 tray->SetVisible(visible); |
240 tray->GetWidget()->Show(); | 250 tray->GetWidget()->Show(); |
241 } else { | 251 } else { |
242 tray->GetWidget()->Hide(); | 252 tray->GetWidget()->Hide(); |
243 } | 253 } |
(...skipping 19 matching lines...) Expand all Loading... |
263 // Return the focus to the web contents. | 273 // Return the focus to the web contents. |
264 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 274 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
265 GetWidget()->Activate(); | 275 GetWidget()->Activate(); |
266 } | 276 } |
267 | 277 |
268 void WebUILoginView::Observe(int type, | 278 void WebUILoginView::Observe(int type, |
269 const content::NotificationSource& source, | 279 const content::NotificationSource& source, |
270 const content::NotificationDetails& details) { | 280 const content::NotificationDetails& details) { |
271 switch (type) { | 281 switch (type) { |
272 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: { | 282 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: { |
| 283 login_visible_notification_fired_ = true; |
273 OnLoginPromptVisible(); | 284 OnLoginPromptVisible(); |
274 registrar_.RemoveAll(); | 285 registrar_.RemoveAll(); |
275 break; | 286 break; |
276 } | 287 } |
277 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { | 288 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { |
278 RenderViewHost* render_view_host = | 289 RenderViewHost* render_view_host = |
279 content::Details<RenderViewHost>(details).ptr(); | 290 content::Details<RenderViewHost>(details).ptr(); |
280 new SnifferObserver(render_view_host, GetWebUI()); | 291 new SnifferObserver(render_view_host, GetWebUI()); |
281 break; | 292 break; |
282 } | 293 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 DCHECK(tab); | 346 DCHECK(tab); |
336 | 347 |
337 scoped_ptr<MediaStreamDevicesController> | 348 scoped_ptr<MediaStreamDevicesController> |
338 controller(new MediaStreamDevicesController( | 349 controller(new MediaStreamDevicesController( |
339 tab->profile(), request, callback)); | 350 tab->profile(), request, callback)); |
340 if (!controller->DismissInfoBarAndTakeActionOnSettings()) | 351 if (!controller->DismissInfoBarAndTakeActionOnSettings()) |
341 NOTREACHED() << "Media stream not allowed for WebUI"; | 352 NOTREACHED() << "Media stream not allowed for WebUI"; |
342 } | 353 } |
343 | 354 |
344 void WebUILoginView::OnLoginPromptVisible() { | 355 void WebUILoginView::OnLoginPromptVisible() { |
| 356 // If we're hidden than will generate this signal once we're shown. |
| 357 if (is_hidden_ || login_prompt_visible_handled_) |
| 358 return; |
| 359 |
345 if (should_emit_login_prompt_visible_) { | 360 if (should_emit_login_prompt_visible_) { |
346 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 361 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
347 EmitLoginPromptVisible(); | 362 EmitLoginPromptVisible(); |
348 } | 363 } |
| 364 login_prompt_visible_handled_ = true; |
349 | 365 |
350 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); | 366 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); |
351 // Notify OOBE that the login frame has been rendered. Currently | 367 // Notify OOBE that the login frame has been rendered. Currently |
352 // this is used to start camera presence check. | 368 // this is used to start camera presence check. |
353 oobe_ui->OnLoginPromptVisible(); | 369 oobe_ui->OnLoginPromptVisible(); |
354 | 370 |
355 // Let RenderWidgetHostViewAura::OnPaint() show white background when | 371 // Let RenderWidgetHostViewAura::OnPaint() show white background when |
356 // loading page and when backing store is not present. | 372 // loading page and when backing store is not present. |
357 aura::Env::GetInstance()->set_render_white_bg(true); | 373 aura::Env::GetInstance()->set_render_white_bg(true); |
358 } | 374 } |
359 | 375 |
360 void WebUILoginView::ReturnFocus(bool reverse) { | 376 void WebUILoginView::ReturnFocus(bool reverse) { |
361 // Return the focus to the web contents. | 377 // Return the focus to the web contents. |
362 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 378 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
363 GetWidget()->Activate(); | 379 GetWidget()->Activate(); |
364 } | 380 } |
365 | 381 |
366 } // namespace chromeos | 382 } // namespace chromeos |
OLD | NEW |