Chromium Code Reviews| 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/focus_cycler.h" | 7 #include "ash/focus_cycler.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
| 48 #include "content/public/browser/render_widget_host.h" | 48 #include "content/public/browser/render_widget_host.h" |
| 49 #include "content/public/browser/render_widget_host_view.h" | 49 #include "content/public/browser/render_widget_host_view.h" |
| 50 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/browser/web_ui.h" | 51 #include "content/public/browser/web_ui.h" |
| 52 #include "content/public/common/renderer_preferences.h" | 52 #include "content/public/common/renderer_preferences.h" |
| 53 #include "extensions/browser/view_type_utils.h" | 53 #include "extensions/browser/view_type_utils.h" |
| 54 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 54 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 55 #include "ui/gfx/geometry/rect.h" | 55 #include "ui/gfx/geometry/rect.h" |
| 56 #include "ui/gfx/geometry/size.h" | 56 #include "ui/gfx/geometry/size.h" |
| 57 #include "ui/keyboard/keyboard_controller.h" | |
| 57 #include "ui/views/controls/webview/webview.h" | 58 #include "ui/views/controls/webview/webview.h" |
| 58 #include "ui/views/widget/widget.h" | 59 #include "ui/views/widget/widget.h" |
| 59 | 60 |
| 60 using content::NativeWebKeyboardEvent; | 61 using content::NativeWebKeyboardEvent; |
| 61 using content::RenderViewHost; | 62 using content::RenderViewHost; |
| 62 using content::WebContents; | 63 using content::WebContents; |
| 63 using web_modal::WebContentsModalDialogManager; | 64 using web_modal::WebContentsModalDialogManager; |
| 64 | 65 |
| 65 namespace { | 66 namespace { |
| 66 | 67 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 namespace chromeos { | 105 namespace chromeos { |
| 105 | 106 |
| 106 // static | 107 // static |
| 107 const char WebUILoginView::kViewClassName[] = | 108 const char WebUILoginView::kViewClassName[] = |
| 108 "browser/chromeos/login/WebUILoginView"; | 109 "browser/chromeos/login/WebUILoginView"; |
| 109 | 110 |
| 110 // WebUILoginView public: ------------------------------------------------------ | 111 // WebUILoginView public: ------------------------------------------------------ |
| 111 | 112 |
| 112 WebUILoginView::WebUILoginView(const WebViewSettings& settings) | 113 WebUILoginView::WebUILoginView(const WebViewSettings& settings) |
| 113 : settings_(settings) { | 114 : settings_(settings) { |
| 115 if (keyboard::KeyboardController::GetInstance()) { | |
| 116 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 117 is_observing_keyboard_ = true; | |
| 118 } | |
| 119 ash::Shell::Get()->AddShellObserver(this); | |
| 120 | |
| 114 registrar_.Add(this, | 121 registrar_.Add(this, |
| 115 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 122 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 116 content::NotificationService::AllSources()); | 123 content::NotificationService::AllSources()); |
| 117 registrar_.Add(this, | 124 registrar_.Add(this, |
| 118 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | 125 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
| 119 content::NotificationService::AllSources()); | 126 content::NotificationService::AllSources()); |
| 120 | 127 |
| 121 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = | 128 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = |
| 122 kAccelNameCancel; | 129 kAccelNameCancel; |
| 123 accel_map_[ui::Accelerator(ui::VKEY_E, | 130 accel_map_[ui::Accelerator(ui::VKEY_E, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 kAccelNameBootstrappingSlave; | 171 kAccelNameBootstrappingSlave; |
| 165 | 172 |
| 166 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 173 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
| 167 AddAccelerator(i->first); | 174 AddAccelerator(i->first); |
| 168 } | 175 } |
| 169 | 176 |
| 170 WebUILoginView::~WebUILoginView() { | 177 WebUILoginView::~WebUILoginView() { |
| 171 for (auto& observer : observer_list_) | 178 for (auto& observer : observer_list_) |
| 172 observer.OnHostDestroying(); | 179 observer.OnHostDestroying(); |
| 173 | 180 |
| 181 ash::Shell::Get()->RemoveShellObserver(this); | |
| 182 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | |
| 183 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 184 is_observing_keyboard_ = false; | |
| 185 } | |
| 186 | |
| 174 if (!ash_util::IsRunningInMash() && | 187 if (!ash_util::IsRunningInMash() && |
| 175 ash::Shell::Get()->HasPrimaryStatusArea()) { | 188 ash::Shell::Get()->HasPrimaryStatusArea()) { |
| 176 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr); | 189 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr); |
| 177 } else { | 190 } else { |
| 178 NOTIMPLEMENTED(); | 191 NOTIMPLEMENTED(); |
| 179 } | 192 } |
| 180 | 193 |
| 181 // Clear any delegates we have set on the WebView. | 194 // Clear any delegates we have set on the WebView. |
| 182 WebContents* web_contents = web_view()->GetWebContents(); | 195 WebContents* web_contents = web_view()->GetWebContents(); |
| 183 WebContentsModalDialogManager::FromWebContents(web_contents) | 196 WebContentsModalDialogManager::FromWebContents(web_contents) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 } | 412 } |
| 400 default: | 413 default: |
| 401 NOTREACHED() << "Unexpected notification " << type; | 414 NOTREACHED() << "Unexpected notification " << type; |
| 402 } | 415 } |
| 403 } | 416 } |
| 404 | 417 |
| 405 views::WebView* WebUILoginView::web_view() { | 418 views::WebView* WebUILoginView::web_view() { |
| 406 return webui_login_.get(); | 419 return webui_login_.get(); |
| 407 } | 420 } |
| 408 | 421 |
| 422 //////////////////////////////////////////////////////////////////////////////// | |
| 423 // ash::ShellObserver: | |
| 424 | |
| 425 void WebUILoginView::OnVirtualKeyboardStateChanged(bool activated, | |
| 426 ash::WmWindow* root_window) { | |
| 427 if (keyboard::KeyboardController::GetInstance()) { | |
|
achuithb
2017/04/12 19:00:26
Let's use a temp var for this?
jdufault
2017/04/13 00:34:42
Done.
| |
| 428 if (activated) { | |
| 429 if (!is_observing_keyboard_) { | |
| 430 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 431 is_observing_keyboard_ = true; | |
|
achuithb
2017/04/12 19:00:26
Is the purpose of is_observing_keyboard_ just to p
jdufault
2017/04/13 00:34:42
Done.
| |
| 432 } | |
| 433 } else { | |
| 434 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 435 is_observing_keyboard_ = false; | |
| 436 } | |
| 437 } | |
| 438 } | |
| 439 | |
| 440 //////////////////////////////////////////////////////////////////////////////// | |
| 441 // keyboard::KeyboardControllerObserver: | |
| 442 | |
| 443 void WebUILoginView::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { | |
| 444 if (new_bounds.IsEmpty()) { | |
| 445 // Keyboard has been hidden. | |
| 446 if (GetOobeUI()) { | |
| 447 GetOobeUI()->GetCoreOobeView()->ShowControlBar(true); | |
|
achuithb
2017/04/12 19:00:26
Use a temp var for this?
CoreOobeView* core_oobe_
jdufault
2017/04/13 00:34:42
Done.
| |
| 448 GetOobeUI()->GetCoreOobeView()->SetVirtualKeyboardShown(false); | |
| 449 } | |
| 450 } else { | |
| 451 // Keyboard has been shown. | |
| 452 if (GetOobeUI()) { | |
| 453 GetOobeUI()->GetCoreOobeView()->ShowControlBar(false); | |
| 454 GetOobeUI()->GetCoreOobeView()->SetVirtualKeyboardShown(true); | |
| 455 } | |
| 456 } | |
| 457 } | |
| 458 | |
| 459 void WebUILoginView::OnKeyboardClosed() {} | |
| 460 | |
| 409 // WebUILoginView private: ----------------------------------------------------- | 461 // WebUILoginView private: ----------------------------------------------------- |
| 410 | 462 |
| 411 bool WebUILoginView::HandleContextMenu( | 463 bool WebUILoginView::HandleContextMenu( |
| 412 const content::ContextMenuParams& params) { | 464 const content::ContextMenuParams& params) { |
| 413 // Do not show the context menu. | 465 // Do not show the context menu. |
| 414 #ifndef NDEBUG | 466 #ifndef NDEBUG |
| 415 return false; | 467 return false; |
| 416 #else | 468 #else |
| 417 return true; | 469 return true; |
| 418 #endif | 470 #endif |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 if (should_emit_login_prompt_visible_) { | 555 if (should_emit_login_prompt_visible_) { |
| 504 VLOG(1) << "Login WebUI >> login-prompt-visible"; | 556 VLOG(1) << "Login WebUI >> login-prompt-visible"; |
| 505 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 557 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 506 EmitLoginPromptVisible(); | 558 EmitLoginPromptVisible(); |
| 507 } | 559 } |
| 508 | 560 |
| 509 webui_visible_ = true; | 561 webui_visible_ = true; |
| 510 } | 562 } |
| 511 | 563 |
| 512 } // namespace chromeos | 564 } // namespace chromeos |
| OLD | NEW |