Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/browser/chromeos/login/lock/webui_screen_locker.cc

Issue 2859363003: cros: Initial structure for views-based lock. (Closed)
Patch Set: Address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 ResetKeyboardOverscrollOverride(); 145 ResetKeyboardOverscrollOverride();
146 146
147 RequestPreload(); 147 RequestPreload();
148 } 148 }
149 149
150 void WebUIScreenLocker::LockScreen() { 150 void WebUIScreenLocker::LockScreen() {
151 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); 151 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
152 152
153 lock_time_ = base::TimeTicks::Now(); 153 lock_time_ = base::TimeTicks::Now();
154 lock_window_ = new LockWindow(this); 154 lock_window_ = new LockWindow();
155 lock_window_->AddObserver(this); 155 lock_window_->AddObserver(this);
156 156
157 Init(); 157 Init();
158 content::WebContentsObserver::Observe(web_view()->GetWebContents()); 158 content::WebContentsObserver::Observe(web_view()->GetWebContents());
159 159
160 lock_window_->SetContentsView(this); 160 lock_window_->SetContentsView(this);
161 lock_window_->SetBounds(bounds); 161 lock_window_->SetBounds(bounds);
162 lock_window_->Show(); 162 lock_window_->Show();
163 LoadURL(GURL(kLoginURL)); 163 LoadURL(GURL(kLoginURL));
164 OnLockWindowReady(); 164 OnLockWindowReady();
165 165
166 signin_screen_controller_.reset( 166 signin_screen_controller_.reset(
167 new SignInScreenController(GetOobeUI(), this)); 167 new SignInScreenController(GetOobeUI(), this));
168 168
169 login_display_.reset(new WebUILoginDisplay(this)); 169 login_display_.reset(new WebUILoginDisplay(this));
170 login_display_->set_background_bounds(bounds); 170 login_display_->set_background_bounds(bounds);
171 login_display_->set_parent_window(GetNativeWindow()); 171 login_display_->set_parent_window(GetNativeWindow());
172 login_display_->Init(screen_locker_->users(), false, true, false); 172 login_display_->Init(screen_locker_->users(), false, true, false);
173 173
174 GetOobeUI()->ShowSigninScreen( 174 GetOobeUI()->ShowSigninScreen(
175 LoginScreenContext(), login_display_.get(), login_display_.get()); 175 LoginScreenContext(), login_display_.get(), login_display_.get());
176 176
177 DisableKeyboardOverscroll(); 177 DisableKeyboardOverscroll();
178 } 178 }
179 179
180 void WebUIScreenLocker::SetInputEnabled(bool enabled) { 180 void WebUIScreenLocker::SetPasswordInputEnabled(bool enabled) {
181 login_display_->SetUIEnabled(enabled); 181 login_display_->SetUIEnabled(enabled);
182 } 182 }
183 183
184 void WebUIScreenLocker::ShowErrorMessage( 184 void WebUIScreenLocker::ShowErrorMessage(
185 int error_msg_id, 185 int error_msg_id,
186 HelpAppLauncher::HelpTopic help_topic_id) { 186 HelpAppLauncher::HelpTopic help_topic_id) {
187 login_display_->ShowError(error_msg_id, 187 login_display_->ShowError(error_msg_id,
188 0 /* login_attempts */, 188 0 /* login_attempts */,
189 help_topic_id); 189 help_topic_id);
190 } 190 }
191 191
192 void WebUIScreenLocker::AnimateAuthenticationSuccess() { 192 void WebUIScreenLocker::AnimateAuthenticationSuccess() {
193 GetWebUI()->CallJavascriptFunctionUnsafe( 193 GetWebUI()->CallJavascriptFunctionUnsafe(
194 "cr.ui.Oobe.animateAuthenticationSuccess"); 194 "cr.ui.Oobe.animateAuthenticationSuccess");
195 } 195 }
196 196
197 void WebUIScreenLocker::ClearErrors() { 197 void WebUIScreenLocker::ClearErrors() {
198 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.clearErrors"); 198 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.clearErrors");
199 } 199 }
200 200
201 void WebUIScreenLocker::ScreenLockReady() { 201 void WebUIScreenLocker::ScreenLockReady() {
202 UMA_HISTOGRAM_TIMES("LockScreen.LockReady", 202 UMA_HISTOGRAM_TIMES("LockScreen.LockReady",
203 base::TimeTicks::Now() - lock_time_); 203 base::TimeTicks::Now() - lock_time_);
204 screen_locker_->ScreenLockReady(); 204 screen_locker_->ScreenLockReady();
205 SetInputEnabled(true); 205 SetPasswordInputEnabled(true);
206 } 206 }
207 207
208 void WebUIScreenLocker::OnLockWindowReady() { 208 void WebUIScreenLocker::OnLockWindowReady() {
209 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); 209 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not");
210 lock_ready_ = true; 210 lock_ready_ = true;
211 if (webui_ready_) 211 if (webui_ready_)
212 ScreenLockReady(); 212 ScreenLockReady();
213 } 213 }
214 214
215 gfx::NativeWindow WebUIScreenLocker::GetNativeWindow() const { 215 gfx::NativeWindow WebUIScreenLocker::GetNativeWindow() const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 260
261 void WebUIScreenLocker::OnAshLockAnimationFinished() { 261 void WebUIScreenLocker::OnAshLockAnimationFinished() {
262 // Release capture if any. 262 // Release capture if any.
263 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow()) 263 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())
264 ->SetCapture(nullptr); 264 ->SetCapture(nullptr);
265 GetWebUI()->CallJavascriptFunctionUnsafe( 265 GetWebUI()->CallJavascriptFunctionUnsafe(
266 "cr.ui.Oobe.animateOnceFullyDisplayed"); 266 "cr.ui.Oobe.animateOnceFullyDisplayed");
267 } 267 }
268 268
269 void WebUIScreenLocker::SetFingerprintState(const AccountId& account_id, 269 void WebUIScreenLocker::SetFingerprintState(
270 FingerprintState state) { 270 const AccountId& account_id,
271 ScreenLocker::FingerprintState state) {
271 // TODO(xiaoyinh@): Modify JS side to consolidate removeUserPodFingerprintIcon 272 // TODO(xiaoyinh@): Modify JS side to consolidate removeUserPodFingerprintIcon
272 // and setUserPodFingerprintIcon into single JS function. 273 // and setUserPodFingerprintIcon into single JS function.
273 if (state == FingerprintState::kRemoved) { 274 if (state == ScreenLocker::FingerprintState::kRemoved) {
274 GetWebUI()->CallJavascriptFunctionUnsafe( 275 GetWebUI()->CallJavascriptFunctionUnsafe(
275 "login.AccountPickerScreen.removeUserPodFingerprintIcon", 276 "login.AccountPickerScreen.removeUserPodFingerprintIcon",
276 ::login::MakeValue(account_id)); 277 ::login::MakeValue(account_id));
277 return; 278 return;
278 } 279 }
279 280
280 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = 281 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
281 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); 282 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id);
282 if (!quick_unlock_storage || 283 if (!quick_unlock_storage ||
283 !quick_unlock_storage->IsFingerprintAuthenticationAvailable()) { 284 !quick_unlock_storage->IsFingerprintAuthenticationAvailable()) {
284 state = FingerprintState::kHidden; 285 state = ScreenLocker::FingerprintState::kHidden;
285 } 286 }
286 GetWebUI()->CallJavascriptFunctionUnsafe( 287 GetWebUI()->CallJavascriptFunctionUnsafe(
287 "login.AccountPickerScreen.setUserPodFingerprintIcon", 288 "login.AccountPickerScreen.setUserPodFingerprintIcon",
288 ::login::MakeValue(account_id), 289 ::login::MakeValue(account_id),
289 ::login::MakeValue(static_cast<int>(state))); 290 ::login::MakeValue(static_cast<int>(state)));
290 } 291 }
291 292
293 content::WebContents* WebUIScreenLocker::GetWebContents() {
294 return WebUILoginView::GetWebContents();
295 }
296
292 //////////////////////////////////////////////////////////////////////////////// 297 ////////////////////////////////////////////////////////////////////////////////
293 // WebUIScreenLocker, LoginDisplay::Delegate: 298 // WebUIScreenLocker, LoginDisplay::Delegate:
294 299
295 void WebUIScreenLocker::CancelPasswordChangedFlow() { 300 void WebUIScreenLocker::CancelPasswordChangedFlow() {
296 NOTREACHED(); 301 NOTREACHED();
297 } 302 }
298 303
299 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) { 304 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) {
300 NOTREACHED(); 305 NOTREACHED();
301 } 306 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 436 }
432 437
433 if (GetOobeUI()) { 438 if (GetOobeUI()) {
434 const gfx::Size& size = primary_display.size(); 439 const gfx::Size& size = primary_display.size();
435 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(), 440 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(),
436 size.height()); 441 size.height());
437 } 442 }
438 } 443 }
439 444
440 } // namespace chromeos 445 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698