Chromium Code Reviews| Index: chrome/browser/chromeos/login/ui/webui_login_view.cc |
| diff --git a/chrome/browser/chromeos/login/ui/webui_login_view.cc b/chrome/browser/chromeos/login/ui/webui_login_view.cc |
| index 1dcb1fc9f02695cbd462f1aaee87bd26c38f5cde..a739c6221af647651139055e9679bcf8359e824b 100644 |
| --- a/chrome/browser/chromeos/login/ui/webui_login_view.cc |
| +++ b/chrome/browser/chromeos/login/ui/webui_login_view.cc |
| @@ -54,6 +54,7 @@ |
| #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/size.h" |
| +#include "ui/keyboard/keyboard_controller.h" |
| #include "ui/views/controls/webview/webview.h" |
| #include "ui/views/widget/widget.h" |
| @@ -111,6 +112,12 @@ const char WebUILoginView::kViewClassName[] = |
| WebUILoginView::WebUILoginView(const WebViewSettings& settings) |
| : settings_(settings) { |
| + if (keyboard::KeyboardController::GetInstance()) |
| + keyboard::KeyboardController::GetInstance()->AddObserver(this); |
| + // TODO(crbug.com/648733): OnVirtualKeyboardStateChanged not supported in mash |
| + if (!ash_util::IsRunningInMash()) |
| + ash::Shell::Get()->AddShellObserver(this); |
| + |
| registrar_.Add(this, |
| chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| content::NotificationService::AllSources()); |
| @@ -171,6 +178,12 @@ WebUILoginView::~WebUILoginView() { |
| for (auto& observer : observer_list_) |
| observer.OnHostDestroying(); |
| + // TODO(crbug.com/648733): OnVirtualKeyboardStateChanged not supported in mash |
| + if (!ash_util::IsRunningInMash()) |
| + ash::Shell::Get()->RemoveShellObserver(this); |
| + if (keyboard::KeyboardController::GetInstance()) |
|
achuithb
2017/04/13 21:49:41
Don't we need a HasObserver test here? In case Add
achuithb
2017/04/13 21:51:28
Actually feel free to ignore this
|
| + keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
| + |
| if (!ash_util::IsRunningInMash() && |
| ash::Shell::Get()->HasPrimaryStatusArea()) { |
| ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr); |
| @@ -406,6 +419,42 @@ views::WebView* WebUILoginView::web_view() { |
| return webui_login_.get(); |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ash::ShellObserver: |
| + |
| +void WebUILoginView::OnVirtualKeyboardStateChanged(bool activated, |
| + ash::WmWindow* root_window) { |
| + auto* keyboard_controller = keyboard::KeyboardController::GetInstance(); |
| + if (keyboard_controller) { |
| + if (activated) { |
| + if (!keyboard_controller->HasObserver(this)) |
| + keyboard_controller->AddObserver(this); |
| + } else { |
| + keyboard_controller->RemoveObserver(this); |
| + } |
| + } |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// keyboard::KeyboardControllerObserver: |
| + |
| +void WebUILoginView::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { |
| + if (!GetOobeUI()) |
| + return; |
| + CoreOobeView* view = GetOobeUI()->GetCoreOobeView(); |
| + if (new_bounds.IsEmpty()) { |
| + // Keyboard has been hidden. |
| + view->ShowControlBar(true); |
|
xiyuan
2017/04/13 05:03:07
We should update LoginDisplayHostImpl [1] to conso
jdufault
2017/04/13 20:29:51
Done.
|
| + view->SetVirtualKeyboardShown(false); |
| + } else { |
| + // Keyboard has been shown. |
| + view->ShowControlBar(false); |
| + view->SetVirtualKeyboardShown(true); |
| + } |
| +} |
| + |
| +void WebUILoginView::OnKeyboardClosed() {} |
| + |
| // WebUILoginView private: ----------------------------------------------------- |
| bool WebUILoginView::HandleContextMenu( |