| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 UserAuthTypeMap::const_iterator it = |
| 357 user_auth_type_map_.find(account_id.GetUserEmail()); |
| 358 if (it == user_auth_type_map_.end()) | 358 if (it == user_auth_type_map_.end()) |
| 359 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 359 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
| 360 return it->second; | 360 return it->second; |
| 361 } | 361 } |
| 362 | 362 |
| 363 proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 363 proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
| 364 UserManagerScreenHandler::GetScreenType() const { | 364 UserManagerScreenHandler::GetScreenType() const { |
| 365 return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN; | 365 return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN; |
| 366 } | 366 } |
| 367 | 367 |
| 368 void UserManagerScreenHandler::Unlock(const std::string& user_email) { | 368 void UserManagerScreenHandler::Unlock(const AccountId& account_id) { |
| 369 base::FilePath path = | 369 const base::FilePath path = profiles::GetPathOfProfileWithEmail( |
| 370 profiles::GetPathOfProfileWithEmail(g_browser_process->profile_manager(), | 370 g_browser_process->profile_manager(), account_id.GetUserEmail()); |
| 371 user_email); | |
| 372 if (!path.empty()) { | 371 if (!path.empty()) { |
| 373 authenticating_profile_path_ = path; | 372 authenticating_profile_path_ = path; |
| 374 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); | 373 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); |
| 375 } | 374 } |
| 376 } | 375 } |
| 377 | 376 |
| 378 void UserManagerScreenHandler::AttemptEasySignin( | 377 void UserManagerScreenHandler::AttemptEasySignin(const AccountId& account_id, |
| 379 const std::string& user_email, | 378 const std::string& secret, |
| 380 const std::string& secret, | 379 const std::string& key_label) { |
| 381 const std::string& key_label) { | |
| 382 NOTREACHED(); | 380 NOTREACHED(); |
| 383 } | 381 } |
| 384 | 382 |
| 385 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 383 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
| 386 // If the URL has a hash parameter, store it for later. | 384 // If the URL has a hash parameter, store it for later. |
| 387 args->GetString(0, &url_hash_); | 385 args->GetString(0, &url_hash_); |
| 388 | 386 |
| 389 SendUserList(); | 387 SendUserList(); |
| 390 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", | 388 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", |
| 391 base::FundamentalValue(IsGuestModeEnabled()), | 389 base::FundamentalValue(IsGuestModeEnabled()), |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 false, /* reuse any existing windows */ | 541 false, /* reuse any existing windows */ |
| 544 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, | 542 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, |
| 545 weak_ptr_factory_.GetWeakPtr()), | 543 weak_ptr_factory_.GetWeakPtr()), |
| 546 ProfileMetrics::SWITCH_PROFILE_MANAGER); | 544 ProfileMetrics::SWITCH_PROFILE_MANAGER); |
| 547 } | 545 } |
| 548 | 546 |
| 549 void UserManagerScreenHandler::HandleAttemptUnlock( | 547 void UserManagerScreenHandler::HandleAttemptUnlock( |
| 550 const base::ListValue* args) { | 548 const base::ListValue* args) { |
| 551 std::string email; | 549 std::string email; |
| 552 CHECK(args->GetString(0, &email)); | 550 CHECK(args->GetString(0, &email)); |
| 553 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); | 551 GetScreenlockRouter(email) |
| 552 ->OnAuthAttempted(GetAuthType(AccountId::FromUserEmail(email)), ""); |
| 554 } | 553 } |
| 555 | 554 |
| 556 void UserManagerScreenHandler::HandleHardlockUserPod( | 555 void UserManagerScreenHandler::HandleHardlockUserPod( |
| 557 const base::ListValue* args) { | 556 const base::ListValue* args) { |
| 558 std::string email; | 557 std::string email; |
| 559 CHECK(args->GetString(0, &email)); | 558 CHECK(args->GetString(0, &email)); |
| 559 const AccountId account_id = AccountId::FromUserEmail(email); |
| 560 SetAuthType( | 560 SetAuthType( |
| 561 email, | 561 account_id, |
| 562 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 562 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
| 563 base::string16()); | 563 base::string16()); |
| 564 HideUserPodCustomIcon(email); | 564 HideUserPodCustomIcon(account_id); |
| 565 } | 565 } |
| 566 | 566 |
| 567 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( | 567 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( |
| 568 const base::ListValue* args) { | 568 const base::ListValue* args) { |
| 569 const base::Value* profile_path_value; | 569 const base::Value* profile_path_value; |
| 570 | 570 |
| 571 if (!args->Get(0, &profile_path_value)) | 571 if (!args->Get(0, &profile_path_value)) |
| 572 return; | 572 return; |
| 573 | 573 |
| 574 base::FilePath profile_path; | 574 base::FilePath profile_path; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 Profile* profile, Profile::CreateStatus profile_create_status) { | 973 Profile* profile, Profile::CreateStatus profile_create_status) { |
| 974 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); | 974 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); |
| 975 if (browser && browser->window()) { | 975 if (browser && browser->window()) { |
| 976 OnBrowserWindowReady(browser); | 976 OnBrowserWindowReady(browser); |
| 977 } else { | 977 } else { |
| 978 registrar_.Add(this, | 978 registrar_.Add(this, |
| 979 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 979 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 980 content::NotificationService::AllSources()); | 980 content::NotificationService::AllSources()); |
| 981 } | 981 } |
| 982 } | 982 } |
| OLD | NEW |