| 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); |
| 173 } | 175 } |
| 174 } | 176 } |
| 175 | 177 |
| 176 void WebUILoginView::Init() { | 178 void WebUILoginView::Init() { |
| 177 Profile* signin_profile = ProfileHelper::GetSigninProfile(); | 179 Profile* signin_profile = ProfileHelper::GetSigninProfile(); |
| 178 webui_login_ = new views::WebView(signin_profile); | 180 webui_login_ = new views::WebView(signin_profile); |
| 179 webui_login_->set_allow_accelerators(true); | 181 webui_login_->set_allow_accelerators(true); |
| 180 AddChildView(webui_login_); | 182 AddChildView(webui_login_); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 *network, NULL, GetNativeWindow()); | 302 *network, NULL, GetNativeWindow()); |
| 301 dialog->Show(); | 303 dialog->Show(); |
| 302 } | 304 } |
| 303 | 305 |
| 304 void WebUILoginView::OnPostponedShow() { | 306 void WebUILoginView::OnPostponedShow() { |
| 305 set_is_hidden(false); | 307 set_is_hidden(false); |
| 306 OnLoginPromptVisible(); | 308 OnLoginPromptVisible(); |
| 307 } | 309 } |
| 308 | 310 |
| 309 void WebUILoginView::SetStatusAreaVisible(bool visible) { | 311 void WebUILoginView::SetStatusAreaVisible(bool visible) { |
| 310 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 312 if (!chrome::IsRunningInMash() && |
| 313 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
| 311 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 314 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 312 tray->SetVisible(visible); | 315 tray->SetVisible(visible); |
| 313 if (visible) { | 316 if (visible) { |
| 314 // Tray may have been initialized being hidden. | 317 // Tray may have been initialized being hidden. |
| 315 tray->GetWidget()->Show(); | 318 tray->GetWidget()->Show(); |
| 316 } else { | 319 } else { |
| 317 tray->GetWidget()->Hide(); | 320 tray->GetWidget()->Hide(); |
| 318 } | 321 } |
| 319 } | 322 } |
| 320 } | 323 } |
| 321 | 324 |
| 322 void WebUILoginView::SetUIEnabled(bool enabled) { | 325 void WebUILoginView::SetUIEnabled(bool enabled) { |
| 323 forward_keyboard_event_ = enabled; | 326 forward_keyboard_event_ = enabled; |
| 327 if (chrome::IsRunningInMash()) |
| 328 return; |
| 324 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 329 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 325 | 330 |
| 326 // We disable the UI to prevent user from interracting with UI elements, | 331 // 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 | 332 // 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 | 333 // bubble is opened at this point, it remains opened and interactictive even |
| 329 // after SystemTray::SetEnabled(false) call, which can be dangerous | 334 // after SystemTray::SetEnabled(false) call, which can be dangerous |
| 330 // (http://crbug.com/497080). Close the menu to fix it. Calling | 335 // (http://crbug.com/497080). Close the menu to fix it. Calling |
| 331 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened | 336 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened |
| 332 // until the UI is enabled again. | 337 // until the UI is enabled again. |
| 333 if (!enabled && tray->HasSystemBubble()) | 338 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 { | 418 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { |
| 414 return true; | 419 return true; |
| 415 } | 420 } |
| 416 | 421 |
| 417 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { | 422 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { |
| 418 // In case of blocked UI (ex.: sign in is in progress) | 423 // In case of blocked UI (ex.: sign in is in progress) |
| 419 // we should not process focus change events. | 424 // we should not process focus change events. |
| 420 if (!forward_keyboard_event_) | 425 if (!forward_keyboard_event_) |
| 421 return false; | 426 return false; |
| 422 | 427 |
| 428 if (chrome::IsRunningInMash()) |
| 429 return true; |
| 430 |
| 423 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 431 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 424 if (tray && tray->GetWidget()->IsVisible()) { | 432 if (tray && tray->GetWidget()->IsVisible()) { |
| 425 tray->SetNextFocusableView(this); | 433 tray->SetNextFocusableView(this); |
| 426 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : | 434 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : |
| 427 ash::Shell::FORWARD); | 435 ash::Shell::FORWARD); |
| 428 } | 436 } |
| 429 | 437 |
| 430 return true; | 438 return true; |
| 431 } | 439 } |
| 432 | 440 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 if (should_emit_login_prompt_visible_) { | 504 if (should_emit_login_prompt_visible_) { |
| 497 VLOG(1) << "Login WebUI >> login-prompt-visible"; | 505 VLOG(1) << "Login WebUI >> login-prompt-visible"; |
| 498 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 506 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 499 EmitLoginPromptVisible(); | 507 EmitLoginPromptVisible(); |
| 500 } | 508 } |
| 501 | 509 |
| 502 webui_visible_ = true; | 510 webui_visible_ = true; |
| 503 } | 511 } |
| 504 | 512 |
| 505 } // namespace chromeos | 513 } // namespace chromeos |
| OLD | NEW |