| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui_login_view.h" | 5 #include "chrome/browser/chromeos/login/ui/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" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 19 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" | 19 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" |
| 20 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 20 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 22 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 22 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 24 #include "chrome/browser/media/media_stream_devices_controller.h" | 24 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 25 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 25 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 26 #include "chrome/browser/renderer_preferences_util.h" | 26 #include "chrome/browser/renderer_preferences_util.h" |
| 27 #include "chrome/browser/sessions/session_tab_helper.h" | 27 #include "chrome/browser/sessions/session_tab_helper.h" |
| 28 #include "chrome/browser/ui/ash/ash_util.h" |
| 28 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" | 29 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| 29 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 30 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 30 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
| 31 #include "chromeos/dbus/session_manager_client.h" | 32 #include "chromeos/dbus/session_manager_client.h" |
| 32 #include "chromeos/network/network_state.h" | 33 #include "chromeos/network/network_state.h" |
| 33 #include "chromeos/network/network_state_handler.h" | 34 #include "chromeos/network/network_state_handler.h" |
| 34 #include "components/password_manager/core/browser/password_manager.h" | 35 #include "components/password_manager/core/browser/password_manager.h" |
| 35 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 36 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/render_frame_host.h" | 38 #include "content/public/browser/render_frame_host.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 161 |
| 161 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 162 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
| 162 AddAccelerator(i->first); | 163 AddAccelerator(i->first); |
| 163 } | 164 } |
| 164 | 165 |
| 165 WebUILoginView::~WebUILoginView() { | 166 WebUILoginView::~WebUILoginView() { |
| 166 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, | 167 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, |
| 167 observer_list_, | 168 observer_list_, |
| 168 OnHostDestroying()); | 169 OnHostDestroying()); |
| 169 | 170 |
| 170 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 171 if (!chrome::IsRunningInMash() && |
| 172 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
| 171 ash::Shell::GetInstance()->GetPrimarySystemTray()-> | 173 ash::Shell::GetInstance()->GetPrimarySystemTray()-> |
| 172 SetNextFocusableView(NULL); | 174 SetNextFocusableView(NULL); |
| 175 } else { |
| 176 NOTIMPLEMENTED(); |
| 173 } | 177 } |
| 174 } | 178 } |
| 175 | 179 |
| 176 void WebUILoginView::Init() { | 180 void WebUILoginView::Init() { |
| 177 Profile* signin_profile = ProfileHelper::GetSigninProfile(); | 181 Profile* signin_profile = ProfileHelper::GetSigninProfile(); |
| 178 webui_login_ = new views::WebView(signin_profile); | 182 webui_login_ = new views::WebView(signin_profile); |
| 179 webui_login_->set_allow_accelerators(true); | 183 webui_login_->set_allow_accelerators(true); |
| 180 AddChildView(webui_login_); | 184 AddChildView(webui_login_); |
| 181 | 185 |
| 182 WebContents* web_contents = webui_login_->GetWebContents(); | 186 WebContents* web_contents = webui_login_->GetWebContents(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 *network, NULL, GetNativeWindow()); | 304 *network, NULL, GetNativeWindow()); |
| 301 dialog->Show(); | 305 dialog->Show(); |
| 302 } | 306 } |
| 303 | 307 |
| 304 void WebUILoginView::OnPostponedShow() { | 308 void WebUILoginView::OnPostponedShow() { |
| 305 set_is_hidden(false); | 309 set_is_hidden(false); |
| 306 OnLoginPromptVisible(); | 310 OnLoginPromptVisible(); |
| 307 } | 311 } |
| 308 | 312 |
| 309 void WebUILoginView::SetStatusAreaVisible(bool visible) { | 313 void WebUILoginView::SetStatusAreaVisible(bool visible) { |
| 310 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 314 if (!chrome::IsRunningInMash() && |
| 315 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
| 311 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 316 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 312 tray->SetVisible(visible); | 317 tray->SetVisible(visible); |
| 313 if (visible) { | 318 if (visible) { |
| 314 // Tray may have been initialized being hidden. | 319 // Tray may have been initialized being hidden. |
| 315 tray->GetWidget()->Show(); | 320 tray->GetWidget()->Show(); |
| 316 } else { | 321 } else { |
| 317 tray->GetWidget()->Hide(); | 322 tray->GetWidget()->Hide(); |
| 318 } | 323 } |
| 324 } else { |
| 325 NOTIMPLEMENTED(); |
| 319 } | 326 } |
| 320 } | 327 } |
| 321 | 328 |
| 322 void WebUILoginView::SetUIEnabled(bool enabled) { | 329 void WebUILoginView::SetUIEnabled(bool enabled) { |
| 323 forward_keyboard_event_ = enabled; | 330 forward_keyboard_event_ = enabled; |
| 331 if (chrome::IsRunningInMash()) { |
| 332 NOTIMPLEMENTED(); |
| 333 return; |
| 334 } |
| 324 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 335 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 325 | 336 |
| 326 // We disable the UI to prevent user from interracting with UI elements, | 337 // We disable the UI to prevent user from interracting with UI elements, |
| 327 // particullary with the system tray menu. However, in case if the system tray | 338 // particullary with the system tray menu. However, in case if the system tray |
| 328 // bubble is opened at this point, it remains opened and interactictive even | 339 // bubble is opened at this point, it remains opened and interactictive even |
| 329 // after SystemTray::SetEnabled(false) call, which can be dangerous | 340 // after SystemTray::SetEnabled(false) call, which can be dangerous |
| 330 // (http://crbug.com/497080). Close the menu to fix it. Calling | 341 // (http://crbug.com/497080). Close the menu to fix it. Calling |
| 331 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened | 342 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened |
| 332 // until the UI is enabled again. | 343 // until the UI is enabled again. |
| 333 if (!enabled && tray->HasSystemBubble()) | 344 if (!enabled && tray->HasSystemBubble()) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { | 424 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { |
| 414 return true; | 425 return true; |
| 415 } | 426 } |
| 416 | 427 |
| 417 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { | 428 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { |
| 418 // In case of blocked UI (ex.: sign in is in progress) | 429 // In case of blocked UI (ex.: sign in is in progress) |
| 419 // we should not process focus change events. | 430 // we should not process focus change events. |
| 420 if (!forward_keyboard_event_) | 431 if (!forward_keyboard_event_) |
| 421 return false; | 432 return false; |
| 422 | 433 |
| 434 // Focus is accepted, but the Ash system tray is not available in Mash, so |
| 435 // exit early. |
| 436 if (chrome::IsRunningInMash()) |
| 437 return true; |
| 438 |
| 423 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 439 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 424 if (tray && tray->GetWidget()->IsVisible()) { | 440 if (tray && tray->GetWidget()->IsVisible()) { |
| 425 tray->SetNextFocusableView(this); | 441 tray->SetNextFocusableView(this); |
| 426 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : | 442 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : |
| 427 ash::Shell::FORWARD); | 443 ash::Shell::FORWARD); |
| 428 } | 444 } |
| 429 | 445 |
| 430 return true; | 446 return true; |
| 431 } | 447 } |
| 432 | 448 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 if (should_emit_login_prompt_visible_) { | 508 if (should_emit_login_prompt_visible_) { |
| 493 VLOG(1) << "Login WebUI >> login-prompt-visible"; | 509 VLOG(1) << "Login WebUI >> login-prompt-visible"; |
| 494 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 510 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 495 EmitLoginPromptVisible(); | 511 EmitLoginPromptVisible(); |
| 496 } | 512 } |
| 497 | 513 |
| 498 webui_visible_ = true; | 514 webui_visible_ = true; |
| 499 } | 515 } |
| 500 | 516 |
| 501 } // namespace chromeos | 517 } // namespace chromeos |
| OLD | NEW |