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

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 1494153002: This CL replaces e-mail with AccountId in easy signin code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bugfix in original easy unlock code' Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/webui/signin/user_manager_screen_handler.h" 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
33 #include "chrome/browser/ui/browser_list_observer.h" 33 #include "chrome/browser/ui/browser_list_observer.h"
34 #include "chrome/browser/ui/chrome_pages.h" 34 #include "chrome/browser/ui/chrome_pages.h"
35 #include "chrome/browser/ui/singleton_tabs.h" 35 #include "chrome/browser/ui/singleton_tabs.h"
36 #include "chrome/browser/ui/user_manager.h" 36 #include "chrome/browser/ui/user_manager.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "chrome/grit/chromium_strings.h" 39 #include "chrome/grit/chromium_strings.h"
40 #include "chrome/grit/generated_resources.h" 40 #include "chrome/grit/generated_resources.h"
41 #include "components/proximity_auth/screenlock_bridge.h" 41 #include "components/proximity_auth/screenlock_bridge.h"
42 #include "components/signin/core/account_id/account_id.h"
42 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
44 #include "content/public/browser/web_ui.h" 45 #include "content/public/browser/web_ui.h"
45 #include "google_apis/gaia/gaia_auth_fetcher.h" 46 #include "google_apis/gaia/gaia_auth_fetcher.h"
46 #include "google_apis/gaia/gaia_constants.h" 47 #include "google_apis/gaia/gaia_constants.h"
47 #include "third_party/skia/include/core/SkBitmap.h" 48 #include "third_party/skia/include/core/SkBitmap.h"
48 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
49 #include "ui/base/resource/resource_bundle.h" 50 #include "ui/base/resource/resource_bundle.h"
50 #include "ui/base/webui/web_ui_util.h" 51 #include "ui/base/webui/web_ui_util.h"
51 #include "ui/gfx/image/image.h" 52 #include "ui/gfx/image/image.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 307 }
307 308
308 void UserManagerScreenHandler::ShowBannerMessage( 309 void UserManagerScreenHandler::ShowBannerMessage(
309 const base::string16& message) { 310 const base::string16& message) {
310 web_ui()->CallJavascriptFunction( 311 web_ui()->CallJavascriptFunction(
311 "login.AccountPickerScreen.showBannerMessage", 312 "login.AccountPickerScreen.showBannerMessage",
312 base::StringValue(message)); 313 base::StringValue(message));
313 } 314 }
314 315
315 void UserManagerScreenHandler::ShowUserPodCustomIcon( 316 void UserManagerScreenHandler::ShowUserPodCustomIcon(
316 const std::string& user_email, 317 const AccountId& account_id,
317 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& 318 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
318 icon_options) { 319 icon_options) {
319 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); 320 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue();
320 if (!icon || icon->empty()) 321 if (!icon || icon->empty())
321 return; 322 return;
322 web_ui()->CallJavascriptFunction( 323 web_ui()->CallJavascriptFunction(
323 "login.AccountPickerScreen.showUserPodCustomIcon", 324 "login.AccountPickerScreen.showUserPodCustomIcon",
324 base::StringValue(user_email), 325 base::StringValue(account_id.GetUserEmail()), *icon);
325 *icon);
326 } 326 }
327 327
328 void UserManagerScreenHandler::HideUserPodCustomIcon( 328 void UserManagerScreenHandler::HideUserPodCustomIcon(
329 const std::string& user_email) { 329 const AccountId& account_id) {
330 web_ui()->CallJavascriptFunction( 330 web_ui()->CallJavascriptFunction(
331 "login.AccountPickerScreen.hideUserPodCustomIcon", 331 "login.AccountPickerScreen.hideUserPodCustomIcon",
332 base::StringValue(user_email)); 332 base::StringValue(account_id.GetUserEmail()));
333 } 333 }
334 334
335 void UserManagerScreenHandler::EnableInput() { 335 void UserManagerScreenHandler::EnableInput() {
336 // Nothing here because UI is not disabled when starting to authenticate. 336 // Nothing here because UI is not disabled when starting to authenticate.
337 } 337 }
338 338
339 void UserManagerScreenHandler::SetAuthType( 339 void UserManagerScreenHandler::SetAuthType(
340 const std::string& user_email, 340 const AccountId& account_id,
341 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, 341 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
342 const base::string16& auth_value) { 342 const base::string16& auth_value) {
343 if (GetAuthType(user_email) == 343 if (GetAuthType(account_id) ==
344 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) 344 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD)
345 return; 345 return;
346 346
347 user_auth_type_map_[user_email] = auth_type; 347 user_auth_type_map_[account_id.GetUserEmail()] = auth_type;
348 web_ui()->CallJavascriptFunction( 348 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.setAuthType",
349 "login.AccountPickerScreen.setAuthType", 349 base::StringValue(account_id.GetUserEmail()),
350 base::StringValue(user_email), 350 base::FundamentalValue(auth_type),
351 base::FundamentalValue(auth_type), 351 base::StringValue(auth_value));
352 base::StringValue(auth_value));
353 } 352 }
354 353
355 proximity_auth::ScreenlockBridge::LockHandler::AuthType 354 proximity_auth::ScreenlockBridge::LockHandler::AuthType
356 UserManagerScreenHandler::GetAuthType(const std::string& user_email) const { 355 UserManagerScreenHandler::GetAuthType(const AccountId& account_id) const {
357 UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email); 356 const auto it = user_auth_type_map_.find(account_id.GetUserEmail());
358 if (it == user_auth_type_map_.end()) 357 if (it == user_auth_type_map_.end())
359 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; 358 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
360 return it->second; 359 return it->second;
361 } 360 }
362 361
363 proximity_auth::ScreenlockBridge::LockHandler::ScreenType 362 proximity_auth::ScreenlockBridge::LockHandler::ScreenType
364 UserManagerScreenHandler::GetScreenType() const { 363 UserManagerScreenHandler::GetScreenType() const {
365 return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN; 364 return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN;
366 } 365 }
367 366
368 void UserManagerScreenHandler::Unlock(const std::string& user_email) { 367 void UserManagerScreenHandler::Unlock(const AccountId& account_id) {
369 base::FilePath path = 368 const base::FilePath path = profiles::GetPathOfProfileWithEmail(
370 profiles::GetPathOfProfileWithEmail(g_browser_process->profile_manager(), 369 g_browser_process->profile_manager(), account_id.GetUserEmail());
371 user_email);
372 if (!path.empty()) { 370 if (!path.empty()) {
373 authenticating_profile_path_ = path; 371 authenticating_profile_path_ = path;
374 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); 372 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL);
375 } 373 }
376 } 374 }
377 375
378 void UserManagerScreenHandler::AttemptEasySignin( 376 void UserManagerScreenHandler::AttemptEasySignin(const AccountId& account_id,
379 const std::string& user_email, 377 const std::string& secret,
380 const std::string& secret, 378 const std::string& key_label) {
381 const std::string& key_label) {
382 NOTREACHED(); 379 NOTREACHED();
383 } 380 }
384 381
385 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { 382 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
386 // If the URL has a hash parameter, store it for later. 383 // If the URL has a hash parameter, store it for later.
387 args->GetString(0, &url_hash_); 384 args->GetString(0, &url_hash_);
388 385
389 SendUserList(); 386 SendUserList();
390 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", 387 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen",
391 base::FundamentalValue(IsGuestModeEnabled()), 388 base::FundamentalValue(IsGuestModeEnabled()),
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 false, /* reuse any existing windows */ 540 false, /* reuse any existing windows */
544 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, 541 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
545 weak_ptr_factory_.GetWeakPtr()), 542 weak_ptr_factory_.GetWeakPtr()),
546 ProfileMetrics::SWITCH_PROFILE_MANAGER); 543 ProfileMetrics::SWITCH_PROFILE_MANAGER);
547 } 544 }
548 545
549 void UserManagerScreenHandler::HandleAttemptUnlock( 546 void UserManagerScreenHandler::HandleAttemptUnlock(
550 const base::ListValue* args) { 547 const base::ListValue* args) {
551 std::string email; 548 std::string email;
552 CHECK(args->GetString(0, &email)); 549 CHECK(args->GetString(0, &email));
553 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); 550 GetScreenlockRouter(email)
551 ->OnAuthAttempted(GetAuthType(AccountId::FromUserEmail(email)), "");
554 } 552 }
555 553
556 void UserManagerScreenHandler::HandleHardlockUserPod( 554 void UserManagerScreenHandler::HandleHardlockUserPod(
557 const base::ListValue* args) { 555 const base::ListValue* args) {
558 std::string email; 556 std::string email;
559 CHECK(args->GetString(0, &email)); 557 CHECK(args->GetString(0, &email));
558 const AccountId account_id = AccountId::FromUserEmail(email);
560 SetAuthType( 559 SetAuthType(
561 email, 560 account_id,
562 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, 561 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
563 base::string16()); 562 base::string16());
564 HideUserPodCustomIcon(email); 563 HideUserPodCustomIcon(account_id);
565 } 564 }
566 565
567 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( 566 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
568 const base::ListValue* args) { 567 const base::ListValue* args) {
569 const base::Value* profile_path_value; 568 const base::Value* profile_path_value;
570 569
571 if (!args->Get(0, &profile_path_value)) 570 if (!args->Get(0, &profile_path_value))
572 return; 571 return;
573 572
574 base::FilePath profile_path; 573 base::FilePath profile_path;
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 Profile* profile, Profile::CreateStatus profile_create_status) { 972 Profile* profile, Profile::CreateStatus profile_create_status) {
974 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 973 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
975 if (browser && browser->window()) { 974 if (browser && browser->window()) {
976 OnBrowserWindowReady(browser); 975 OnBrowserWindowReady(browser);
977 } else { 976 } else {
978 registrar_.Add(this, 977 registrar_.Add(this,
979 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 978 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
980 content::NotificationService::AllSources()); 979 content::NotificationService::AllSources());
981 } 980 }
982 } 981 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/user_manager_screen_handler.h ('k') | chromeos/login/auth/login_performer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698