Index: chrome/browser/chromeos/login/lock/webui_screen_locker.cc |
diff --git a/chrome/browser/chromeos/login/lock/webui_screen_locker.cc b/chrome/browser/chromeos/login/lock/webui_screen_locker.cc |
index 950970c4a53e39e9b2b837c82fa5b8d229c97179..5bf1f24a3433e1327c37328f4d3dafadfdcd3940 100644 |
--- a/chrome/browser/chromeos/login/lock/webui_screen_locker.cc |
+++ b/chrome/browser/chromeos/login/lock/webui_screen_locker.cc |
@@ -33,6 +33,8 @@ |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/x/x11_util.h" |
#include "ui/gfx/screen.h" |
+#include "ui/keyboard/keyboard_controller.h" |
+#include "ui/keyboard/keyboard_util.h" |
#include "ui/views/controls/webview/webview.h" |
namespace { |
@@ -40,6 +42,18 @@ namespace { |
// URL which corresponds to the login WebUI. |
const char kLoginURL[] = "chrome://oobe/lock"; |
+// Disables virtual keyboard overscroll. Login UI will scroll user pods |
+// into view on JS side when virtual keyboard is shown. |
+void DisableKeyboardOverscroll() { |
+ keyboard::SetKeyboardOverscrollOverride( |
+ keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
+} |
+ |
+void ResetKeyboardOverscrollOverride() { |
+ keyboard::SetKeyboardOverscrollOverride( |
+ keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); |
+} |
+ |
} // namespace |
namespace chromeos { |
@@ -52,10 +66,18 @@ WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
lock_ready_(false), |
webui_ready_(false), |
network_state_helper_(new login::NetworkStateHelper), |
+ is_observing_keyboard_(false), |
weak_factory_(this) { |
set_should_emit_login_prompt_visible(false); |
ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
+ |
+ if (keyboard::KeyboardController::GetInstance()) { |
+ keyboard::KeyboardController::GetInstance()->AddObserver(this); |
+ is_observing_keyboard_ = true; |
+ } |
+ |
+ ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); |
} |
void WebUIScreenLocker::LockScreen() { |
@@ -77,12 +99,15 @@ void WebUIScreenLocker::LockScreen() { |
login_display_->set_parent_window(GetNativeWindow()); |
login_display_->Init(screen_locker()->users(), false, true, false); |
- static_cast<OobeUI*>(GetWebUI()->GetController())->ShowSigninScreen( |
+ GetOobeUI()->ShowSigninScreen( |
LoginScreenContext(), login_display_.get(), login_display_.get()); |
registrar_.Add(this, |
chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
content::NotificationService::AllSources()); |
+ |
+ if (login::LockScrollIntoViewEnabled()) |
+ DisableKeyboardOverscroll(); |
} |
void WebUIScreenLocker::ScreenLockReady() { |
@@ -145,6 +170,17 @@ WebUIScreenLocker::~WebUIScreenLocker() { |
static_cast<OobeUI*>(GetWebUI()->GetController())-> |
ResetSigninScreenHandlerDelegate(); |
} |
+ |
+ if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { |
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
+ is_observing_keyboard_ = false; |
+ } |
+ |
+ ash::Shell::GetInstance()->delegate()-> |
+ RemoveVirtualKeyboardStateObserver(this); |
+ |
+ if (login::LockScrollIntoViewEnabled()) |
+ ResetKeyboardOverscrollOverride(); |
} |
void WebUIScreenLocker::OnLockWebUIReady() { |
@@ -160,6 +196,10 @@ void WebUIScreenLocker::OnLockBackgroundDisplayed() { |
base::TimeTicks::Now() - lock_time_); |
} |
+OobeUI* WebUIScreenLocker::GetOobeUI() { |
+ return static_cast<OobeUI*>(GetWebUI()->GetController()); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WebUIScreenLocker, content::NotificationObserver implementation: |
@@ -322,4 +362,45 @@ void WebUIScreenLocker::RenderProcessGone(base::TerminationStatus status) { |
} |
} |
+//////////////////////////////////////////////////////////////////////////////// |
+// ash::KeyboardStateObserver overrides. |
+ |
+void WebUIScreenLocker::OnVirtualKeyboardStateChanged(bool activated) { |
+ if (keyboard::KeyboardController::GetInstance()) { |
+ if (activated) { |
+ if (!is_observing_keyboard_) { |
+ keyboard::KeyboardController::GetInstance()->AddObserver(this); |
+ is_observing_keyboard_ = true; |
+ } |
+ } else { |
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
+ is_observing_keyboard_ = false; |
+ } |
+ } |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// keyboard::KeyboardControllerObserver overrides. |
+ |
+void WebUIScreenLocker::OnKeyboardBoundsChanging( |
+ const gfx::Rect& new_bounds) { |
+ if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { |
+ // Keyboard has been hidden. |
+ if (GetOobeUI()) { |
+ GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); |
+ if (login::LockScrollIntoViewEnabled()) |
+ GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); |
+ } |
+ } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { |
+ // Keyboard has been shown. |
+ if (GetOobeUI()) { |
+ GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); |
+ if (login::LockScrollIntoViewEnabled()) |
+ GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); |
+ } |
+ } |
+ |
+ keyboard_bounds_ = new_bounds; |
+} |
+ |
} // namespace chromeos |