| 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/lock/webui_screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/lock_state_controller.h" | 8 #include "ash/wm/lock_state_controller.h" |
| 9 #include "ash/wm/lock_state_observer.h" | 9 #include "ash/wm/lock_state_observer.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // WebUIScreenLocker implementation. | 60 // WebUIScreenLocker implementation. |
| 61 | 61 |
| 62 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 62 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
| 63 : ScreenLockerDelegate(screen_locker), | 63 : ScreenLockerDelegate(screen_locker), |
| 64 lock_ready_(false), | 64 lock_ready_(false), |
| 65 webui_ready_(false), | 65 webui_ready_(false), |
| 66 network_state_helper_(new login::NetworkStateHelper), | 66 network_state_helper_(new login::NetworkStateHelper), |
| 67 is_observing_keyboard_(false), | 67 is_observing_keyboard_(false), |
| 68 weak_factory_(this) { | 68 weak_factory_(this) { |
| 69 set_should_emit_login_prompt_visible(false); | 69 set_should_emit_login_prompt_visible(false); |
| 70 #if !defined(USE_ATHENA) |
| 70 ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this); | 71 ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
| 72 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); |
| 73 #endif |
| 71 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 74 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 72 | 75 |
| 73 if (keyboard::KeyboardController::GetInstance()) { | 76 if (keyboard::KeyboardController::GetInstance()) { |
| 74 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 77 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
| 75 is_observing_keyboard_ = true; | 78 is_observing_keyboard_ = true; |
| 76 } | 79 } |
| 77 | |
| 78 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); | |
| 79 } | 80 } |
| 80 | 81 |
| 81 void WebUIScreenLocker::LockScreen() { | 82 void WebUIScreenLocker::LockScreen() { |
| 82 gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds()); | 83 gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds()); |
| 83 | 84 |
| 84 lock_time_ = base::TimeTicks::Now(); | 85 lock_time_ = base::TimeTicks::Now(); |
| 85 LockWindow* lock_window = LockWindow::Create(); | 86 LockWindow* lock_window = LockWindow::Create(); |
| 86 lock_window->set_observer(this); | 87 lock_window->set_observer(this); |
| 87 lock_window->set_initially_focused_view(this); | 88 lock_window->set_initially_focused_view(this); |
| 88 lock_window_ = lock_window->GetWidget(); | 89 lock_window_ = lock_window->GetWidget(); |
| 89 lock_window_->AddObserver(this); | 90 lock_window_->AddObserver(this); |
| 90 WebUILoginView::Init(); | 91 WebUILoginView::Init(); |
| 91 lock_window_->SetContentsView(this); | 92 lock_window_->SetContentsView(this); |
| 93 lock_window_->SetBounds(bounds); |
| 92 lock_window_->Show(); | 94 lock_window_->Show(); |
| 93 LoadURL(GURL(kLoginURL)); | 95 LoadURL(GURL(kLoginURL)); |
| 94 lock_window->Grab(); | 96 lock_window->Grab(); |
| 95 | 97 |
| 96 login_display_.reset(new WebUILoginDisplay(this)); | 98 login_display_.reset(new WebUILoginDisplay(this)); |
| 97 login_display_->set_background_bounds(bounds); | 99 login_display_->set_background_bounds(bounds); |
| 98 login_display_->set_parent_window(GetNativeWindow()); | 100 login_display_->set_parent_window(GetNativeWindow()); |
| 99 login_display_->Init(screen_locker()->users(), false, true, false); | 101 login_display_->Init(screen_locker()->users(), false, true, false); |
| 100 | 102 |
| 101 GetOobeUI()->ShowSigninScreen( | 103 GetOobeUI()->ShowSigninScreen( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 151 |
| 150 void WebUIScreenLocker::FocusUserPod() { | 152 void WebUIScreenLocker::FocusUserPod() { |
| 151 if (!webui_ready_) | 153 if (!webui_ready_) |
| 152 return; | 154 return; |
| 153 webui_login_->RequestFocus(); | 155 webui_login_->RequestFocus(); |
| 154 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.forceLockedUserPodFocus"); | 156 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.forceLockedUserPodFocus"); |
| 155 } | 157 } |
| 156 | 158 |
| 157 WebUIScreenLocker::~WebUIScreenLocker() { | 159 WebUIScreenLocker::~WebUIScreenLocker() { |
| 158 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 160 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 161 #if !defined(USE_ATHENA) |
| 159 ash::Shell::GetInstance()-> | 162 ash::Shell::GetInstance()-> |
| 160 lock_state_controller()->RemoveObserver(this); | 163 lock_state_controller()->RemoveObserver(this); |
| 164 |
| 165 ash::Shell::GetInstance()->delegate()-> |
| 166 RemoveVirtualKeyboardStateObserver(this); |
| 167 #endif |
| 161 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. | 168 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. |
| 162 if (lock_window_) { | 169 if (lock_window_) { |
| 163 lock_window_->RemoveObserver(this); | 170 lock_window_->RemoveObserver(this); |
| 164 lock_window_->Close(); | 171 lock_window_->Close(); |
| 165 } | 172 } |
| 166 // If LockScreen() was called, we need to clear the signin screen handler | 173 // If LockScreen() was called, we need to clear the signin screen handler |
| 167 // delegate set in ShowSigninScreen so that it no longer points to us. | 174 // delegate set in ShowSigninScreen so that it no longer points to us. |
| 168 if (login_display_.get()) { | 175 if (login_display_.get()) { |
| 169 static_cast<OobeUI*>(GetWebUI()->GetController())-> | 176 static_cast<OobeUI*>(GetWebUI()->GetController())-> |
| 170 ResetSigninScreenHandlerDelegate(); | 177 ResetSigninScreenHandlerDelegate(); |
| 171 } | 178 } |
| 172 | 179 |
| 173 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | 180 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { |
| 174 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 181 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
| 175 is_observing_keyboard_ = false; | 182 is_observing_keyboard_ = false; |
| 176 } | 183 } |
| 177 | 184 |
| 178 ash::Shell::GetInstance()->delegate()-> | |
| 179 RemoveVirtualKeyboardStateObserver(this); | |
| 180 | |
| 181 if (login::LoginScrollIntoViewEnabled()) | 185 if (login::LoginScrollIntoViewEnabled()) |
| 182 ResetKeyboardOverscrollOverride(); | 186 ResetKeyboardOverscrollOverride(); |
| 183 } | 187 } |
| 184 | 188 |
| 185 void WebUIScreenLocker::OnLockWebUIReady() { | 189 void WebUIScreenLocker::OnLockWebUIReady() { |
| 186 VLOG(1) << "WebUI ready; lock window is " | 190 VLOG(1) << "WebUI ready; lock window is " |
| 187 << (lock_ready_ ? "too" : "not"); | 191 << (lock_ready_ ? "too" : "not"); |
| 188 webui_ready_ = true; | 192 webui_ready_ = true; |
| 189 if (lock_ready_) | 193 if (lock_ready_) |
| 190 ScreenLockReady(); | 194 ScreenLockReady(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); | 382 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); |
| 379 if (login::LoginScrollIntoViewEnabled()) | 383 if (login::LoginScrollIntoViewEnabled()) |
| 380 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); | 384 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); |
| 381 } | 385 } |
| 382 } | 386 } |
| 383 | 387 |
| 384 keyboard_bounds_ = new_bounds; | 388 keyboard_bounds_ = new_bounds; |
| 385 } | 389 } |
| 386 | 390 |
| 387 } // namespace chromeos | 391 } // namespace chromeos |
| OLD | NEW |