Chromium Code Reviews| 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/inline_login_handler_impl.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CloseModalSigninIfNeeded(InlineLoginHandlerImpl* handler) { | 229 void CloseModalSigninIfNeeded(InlineLoginHandlerImpl* handler) { |
| 230 if (handler && switches::UsePasswordSeparatedSigninFlow()) { | 230 if (handler && switches::UsePasswordSeparatedSigninFlow()) { |
| 231 Browser* browser = handler->GetDesktopBrowser(); | 231 Browser* browser = handler->GetDesktopBrowser(); |
| 232 if (browser) | 232 if (browser) |
| 233 browser->CloseModalSigninWindow(); | 233 browser->CloseModalSigninWindow(); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 void HideUserManager(const base::FilePath profile_path, | |
|
anthonyvd
2016/11/04 21:31:02
This function does a lot more than just closing th
zmin
2016/11/04 22:11:53
How about UnlockProfileAndHideLoginUI?
I also rem
| |
| 238 InlineLoginHandlerImpl* handler, | |
| 239 Profile* profile, | |
| 240 Profile::CreateStatus status) { | |
| 241 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 242 if (profile_manager) { | |
| 243 ProfileAttributesEntry* entry; | |
| 244 if (profile_manager->GetProfileAttributesStorage() | |
| 245 .GetProfileAttributesWithPath(profile_path, &entry)) { | |
| 246 entry->SetIsSigninRequired(false); | |
| 247 } | |
| 248 } | |
| 249 if (handler) | |
| 250 handler->web_ui()->CallJavascriptFunctionUnsafe("inline.login.closeDialog"); | |
| 251 UserManager::Hide(); | |
| 252 } | |
| 253 | |
| 254 bool IsCrossAccountError(Profile* profile, | |
| 255 const std::string& email, | |
| 256 const std::string& gaia_id) { | |
| 257 InvestigatorDependencyProvider provider(profile); | |
| 258 InvestigatedScenario scenario = | |
| 259 SigninInvestigator(email, gaia_id, &provider).Investigate(); | |
| 260 | |
| 261 return scenario == InvestigatedScenario::DIFFERENT_ACCOUNT; | |
| 262 } | |
| 263 | |
| 237 } // namespace | 264 } // namespace |
| 238 | 265 |
| 239 InlineSigninHelper::InlineSigninHelper( | 266 InlineSigninHelper::InlineSigninHelper( |
| 240 base::WeakPtr<InlineLoginHandlerImpl> handler, | 267 base::WeakPtr<InlineLoginHandlerImpl> handler, |
| 241 net::URLRequestContextGetter* getter, | 268 net::URLRequestContextGetter* getter, |
| 242 Profile* profile, | 269 Profile* profile, |
| 270 Profile::CreateStatus create_status, | |
| 243 const GURL& current_url, | 271 const GURL& current_url, |
| 244 const std::string& email, | 272 const std::string& email, |
| 245 const std::string& gaia_id, | 273 const std::string& gaia_id, |
| 246 const std::string& password, | 274 const std::string& password, |
| 247 const std::string& session_index, | 275 const std::string& session_index, |
| 248 const std::string& auth_code, | 276 const std::string& auth_code, |
| 249 const std::string& signin_scoped_device_id, | 277 const std::string& signin_scoped_device_id, |
| 250 bool choose_what_to_sync, | 278 bool choose_what_to_sync, |
| 251 bool confirm_untrusted_signin) | 279 bool confirm_untrusted_signin) |
| 252 : gaia_auth_fetcher_(this, GaiaConstants::kChromeSource, getter), | 280 : gaia_auth_fetcher_(this, GaiaConstants::kChromeSource, getter), |
| 253 handler_(handler), | 281 handler_(handler), |
| 254 profile_(profile), | 282 profile_(profile), |
| 283 create_status_(create_status), | |
| 255 current_url_(current_url), | 284 current_url_(current_url), |
| 256 email_(email), | 285 email_(email), |
| 257 gaia_id_(gaia_id), | 286 gaia_id_(gaia_id), |
| 258 password_(password), | 287 password_(password), |
| 259 session_index_(session_index), | 288 session_index_(session_index), |
| 260 auth_code_(auth_code), | 289 auth_code_(auth_code), |
| 261 choose_what_to_sync_(choose_what_to_sync), | 290 choose_what_to_sync_(choose_what_to_sync), |
| 262 confirm_untrusted_signin_(confirm_untrusted_signin) { | 291 confirm_untrusted_signin_(confirm_untrusted_signin) { |
| 263 DCHECK(profile_); | 292 DCHECK(profile_); |
| 264 DCHECK(!email_.empty()); | 293 DCHECK(!email_.empty()); |
| 265 if (!auth_code_.empty()) { | 294 if (!auth_code_.empty()) { |
| 266 gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId( | 295 gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId( |
| 267 auth_code, signin_scoped_device_id); | 296 auth_code, signin_scoped_device_id); |
| 268 } else { | 297 } else { |
| 269 DCHECK(!session_index_.empty()); | 298 DCHECK(!session_index_.empty()); |
| 270 gaia_auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithDeviceId( | 299 gaia_auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithDeviceId( |
| 271 session_index_, signin_scoped_device_id); | 300 session_index_, signin_scoped_device_id); |
| 272 } | 301 } |
| 273 } | 302 } |
| 274 | 303 |
| 275 InlineSigninHelper::~InlineSigninHelper() {} | 304 InlineSigninHelper::~InlineSigninHelper() {} |
| 276 | 305 |
| 277 void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { | 306 void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { |
| 307 if (signin::IsForceSigninEnabled()) { | |
| 308 // With force sign in enabled, the browser window won't be opened until now. | |
| 309 profiles::OpenBrowserWindowForProfile( | |
| 310 base::Bind(&InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened, | |
| 311 base::Unretained(this), result), | |
| 312 true, false, profile_, create_status_); | |
| 313 } else { | |
| 314 OnClientOAuthSuccessAndBrowserOpened(result, profile_, create_status_); | |
| 315 } | |
| 316 } | |
| 317 | |
| 318 void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened( | |
| 319 const ClientOAuthResult& result, | |
| 320 Profile* profile, | |
| 321 Profile::CreateStatus status) { | |
| 322 HideUserManager(profile_->GetPath(), handler_.get(), profile, status); | |
| 278 content::WebContents* contents = NULL; | 323 content::WebContents* contents = NULL; |
| 279 Browser* browser = NULL; | 324 Browser* browser = NULL; |
| 280 if (handler_) { | 325 if (handler_) { |
| 281 contents = handler_->web_ui()->GetWebContents(); | 326 contents = handler_->web_ui()->GetWebContents(); |
| 282 browser = handler_->GetDesktopBrowser(); | 327 browser = handler_->GetDesktopBrowser(); |
| 283 } | 328 } |
| 284 | 329 |
| 285 AboutSigninInternals* about_signin_internals = | 330 AboutSigninInternals* about_signin_internals = |
| 286 AboutSigninInternalsFactory::GetForProfile(profile_); | 331 AboutSigninInternalsFactory::GetForProfile(profile_); |
| 287 about_signin_internals->OnRefreshTokenReceived("Successful"); | 332 about_signin_internals->OnRefreshTokenReceived("Successful"); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 new OneClickSigninSyncStarter( | 419 new OneClickSigninSyncStarter( |
| 375 profile_, browser, gaia_id_, email_, password_, refresh_token, start_mode, | 420 profile_, browser, gaia_id_, email_, password_, refresh_token, start_mode, |
| 376 contents, confirmation_required, current_url, continue_url, | 421 contents, confirmation_required, current_url, continue_url, |
| 377 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); | 422 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); |
| 378 } | 423 } |
| 379 | 424 |
| 380 bool InlineSigninHelper::HandleCrossAccountError( | 425 bool InlineSigninHelper::HandleCrossAccountError( |
| 381 const std::string& refresh_token, | 426 const std::string& refresh_token, |
| 382 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, | 427 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, |
| 383 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 428 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 429 // With force sign in enabled, cross account sign in will be rejected in the | |
| 430 // early stage so there is no need to show the warning page here. | |
| 431 if (signin::IsForceSigninEnabled()) | |
| 432 return false; | |
| 433 | |
| 384 std::string last_email = | 434 std::string last_email = |
| 385 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 435 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 386 | 436 |
| 387 InvestigatorDependencyProvider provider(profile_); | |
| 388 InvestigatedScenario scenario = | |
| 389 SigninInvestigator(email_, gaia_id_, &provider).Investigate(); | |
| 390 | |
| 391 // TODO(skym): Warn for high risk upgrade scenario, crbug.com/572754. | 437 // TODO(skym): Warn for high risk upgrade scenario, crbug.com/572754. |
| 392 if (scenario != InvestigatedScenario::DIFFERENT_ACCOUNT) { | 438 if (!IsCrossAccountError(profile_, email_, gaia_id_)) |
| 393 return false; | 439 return false; |
| 394 } | |
| 395 | 440 |
| 396 Browser* browser = chrome::FindLastActiveWithProfile(profile_); | 441 Browser* browser = chrome::FindLastActiveWithProfile(profile_); |
| 397 content::WebContents* web_contents = | 442 content::WebContents* web_contents = |
| 398 browser->tab_strip_model()->GetActiveWebContents(); | 443 browser->tab_strip_model()->GetActiveWebContents(); |
| 399 | 444 |
| 400 ConfirmEmailDialogDelegate::AskForConfirmation( | 445 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 401 web_contents, | 446 web_contents, |
| 402 last_email, | 447 last_email, |
| 403 email_, | 448 email_, |
| 404 base::Bind(&InlineSigninHelper::ConfirmEmailAction, | 449 base::Bind(&InlineSigninHelper::ConfirmEmailAction, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 gaia::AreEmailsSame(email, profile_email)) { | 612 gaia::AreEmailsSame(email, profile_email)) { |
| 568 if (error_message) { | 613 if (error_message) { |
| 569 error_message->assign( | 614 error_message->assign( |
| 570 l10n_util::GetStringUTF8(IDS_SYNC_USER_NAME_IN_USE_ERROR)); | 615 l10n_util::GetStringUTF8(IDS_SYNC_USER_NAME_IN_USE_ERROR)); |
| 571 } | 616 } |
| 572 return false; | 617 return false; |
| 573 } | 618 } |
| 574 } | 619 } |
| 575 } | 620 } |
| 576 } | 621 } |
| 622 | |
| 623 // With force sign in enabled, cross account sign in is not allowed. | |
| 624 if (signin::IsForceSigninEnabled() && | |
| 625 IsCrossAccountError(profile, email, gaia_id)) { | |
| 626 if (error_message) { | |
| 627 std::string last_email = | |
| 628 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | |
| 629 error_message->assign(l10n_util::GetStringFUTF8( | |
| 630 IDS_SYNC_USED_PROFILE_ERROR, base::UTF8ToUTF16(last_email))); | |
| 631 } | |
| 632 return false; | |
| 633 } | |
| 577 } | 634 } |
| 578 | 635 |
| 579 return true; | 636 return true; |
| 580 } | 637 } |
| 581 | 638 |
| 582 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { | 639 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { |
| 583 params.SetString("service", "chromiumsync"); | 640 params.SetString("service", "chromiumsync"); |
| 584 | 641 |
| 585 // If this was called from the user manager to reauthenticate the profile, | 642 // If this was called from the user manager to reauthenticate the profile, |
| 586 // make sure the webui is aware. | 643 // make sure the webui is aware. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); | 741 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); |
| 685 | 742 |
| 686 // If this was called from the user manager to reauthenticate the profile, | 743 // If this was called from the user manager to reauthenticate the profile, |
| 687 // the current profile is the system profile. In this case, use the email to | 744 // the current profile is the system profile. In this case, use the email to |
| 688 // find the right profile to reauthenticate. Otherwise the profile can be | 745 // find the right profile to reauthenticate. Otherwise the profile can be |
| 689 // taken from web_ui(). | 746 // taken from web_ui(). |
| 690 Profile* profile = Profile::FromWebUI(web_ui()); | 747 Profile* profile = Profile::FromWebUI(web_ui()); |
| 691 if (IsSystemProfile(profile)) { | 748 if (IsSystemProfile(profile)) { |
| 692 ProfileManager* manager = g_browser_process->profile_manager(); | 749 ProfileManager* manager = g_browser_process->profile_manager(); |
| 693 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); | 750 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); |
| 751 if (path.empty()) { | |
| 752 path = UserManager::GetSigninProfilePath(); | |
| 753 } | |
| 694 if (!path.empty()) { | 754 if (!path.empty()) { |
| 695 signin_metrics::Reason reason = | 755 signin_metrics::Reason reason = |
| 696 signin::GetSigninReasonForPromoURL(current_url); | 756 signin::GetSigninReasonForPromoURL(current_url); |
| 697 // If we are only reauthenticating a profile in the user manager (and not | 757 // If we are only reauthenticating a profile in the user manager (and not |
| 698 // unlocking it), load the profile and finish the login. | 758 // unlocking it), load the profile and finish the login. |
| 699 if (reason == signin_metrics::Reason::REASON_REAUTHENTICATION) { | 759 if (reason == signin_metrics::Reason::REASON_REAUTHENTICATION) { |
| 700 FinishCompleteLoginParams params( | 760 FinishCompleteLoginParams params( |
| 701 this, partition, current_url, base::FilePath(), | 761 this, partition, current_url, base::FilePath(), |
| 702 confirm_untrusted_signin_, email, gaia_id, password, session_index, | 762 confirm_untrusted_signin_, email, gaia_id, password, session_index, |
| 703 auth_code, choose_what_to_sync); | 763 auth_code, choose_what_to_sync); |
| 704 ProfileManager::CreateCallback callback = | 764 ProfileManager::CreateCallback callback = |
| 705 base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); | 765 base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); |
| 706 profiles::LoadProfileAsync(path, callback); | 766 profiles::LoadProfileAsync(path, callback); |
| 707 } else { | 767 } else { |
| 708 // Otherwise, switch to the profile and finish the login. Pass the | 768 // Otherwise, switch to the profile and finish the login. Pass the |
| 709 // profile path so it can be marked as unlocked. Don't pass a handler | 769 // profile path so it can be marked as unlocked. Don't pass a handler |
| 710 // pointer since it will be destroyed before the callback runs. | 770 // pointer since it will be destroyed before the callback runs. |
| 711 FinishCompleteLoginParams params(nullptr, partition, current_url, path, | 771 bool is_force_signin_enabled = signin::IsForceSigninEnabled(); |
| 772 InlineLoginHandlerImpl* handler = nullptr; | |
| 773 if (is_force_signin_enabled) | |
| 774 handler = this; | |
| 775 FinishCompleteLoginParams params(handler, partition, current_url, path, | |
| 712 confirm_untrusted_signin_, email, | 776 confirm_untrusted_signin_, email, |
| 713 gaia_id, password, session_index, | 777 gaia_id, password, session_index, |
| 714 auth_code, choose_what_to_sync); | 778 auth_code, choose_what_to_sync); |
| 715 ProfileManager::CreateCallback callback = | 779 ProfileManager::CreateCallback callback = |
| 716 base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); | 780 base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); |
| 717 profiles::SwitchToProfile(path, true, callback, | 781 if (is_force_signin_enabled) { |
| 718 ProfileMetrics::SWITCH_PROFILE_UNLOCK); | 782 // Browser window will be opened after ClientOAuthSuccess. |
| 783 profiles::LoadProfileAsync(path, callback); | |
| 784 } else { | |
| 785 profiles::SwitchToProfile(path, true, callback, | |
| 786 ProfileMetrics::SWITCH_PROFILE_UNLOCK); | |
| 787 } | |
| 719 } | 788 } |
| 720 } | 789 } |
| 721 } else { | 790 } else { |
| 722 FinishCompleteLogin( | 791 FinishCompleteLogin( |
| 723 FinishCompleteLoginParams(this, partition, current_url, | 792 FinishCompleteLoginParams(this, partition, current_url, |
| 724 base::FilePath(), confirm_untrusted_signin_, | 793 base::FilePath(), confirm_untrusted_signin_, |
| 725 email, gaia_id, password, session_index, | 794 email, gaia_id, password, session_index, |
| 726 auth_code, choose_what_to_sync), | 795 auth_code, choose_what_to_sync), |
| 727 profile, | 796 profile, |
| 728 Profile::CREATE_STATUS_CREATED); | 797 Profile::CREATE_STATUS_CREATED); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 Profile::CreateStatus status) { | 835 Profile::CreateStatus status) { |
| 767 // When doing a SAML sign in, this email check may result in a false | 836 // When doing a SAML sign in, this email check may result in a false |
| 768 // positive. This happens when the user types one email address in the | 837 // positive. This happens when the user types one email address in the |
| 769 // gaia sign in page, but signs in to a different account in the SAML sign in | 838 // gaia sign in page, but signs in to a different account in the SAML sign in |
| 770 // page. | 839 // page. |
| 771 std::string default_email; | 840 std::string default_email; |
| 772 std::string validate_email; | 841 std::string validate_email; |
| 773 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) && | 842 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) && |
| 774 net::GetValueForKeyInQuery(params.url, "validateEmail", | 843 net::GetValueForKeyInQuery(params.url, "validateEmail", |
| 775 &validate_email) && | 844 &validate_email) && |
| 776 validate_email == "1") { | 845 validate_email == "1" && !default_email.empty()) { |
| 777 if (!gaia::AreEmailsSame(params.email, default_email)) { | 846 if (!gaia::AreEmailsSame(params.email, default_email)) { |
| 778 if (params.handler) { | 847 if (params.handler) { |
| 779 params.handler->HandleLoginError( | 848 params.handler->HandleLoginError( |
| 780 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, | 849 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, |
| 781 base::UTF8ToUTF16(default_email)), | 850 base::UTF8ToUTF16(default_email)), |
| 782 base::UTF8ToUTF16(params.email)); | 851 base::UTF8ToUTF16(params.email)); |
| 783 } | 852 } |
| 784 return; | 853 return; |
| 785 } | 854 } |
| 786 } | 855 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 | 903 |
| 835 SigninClient* signin_client = | 904 SigninClient* signin_client = |
| 836 ChromeSigninClientFactory::GetForProfile(profile); | 905 ChromeSigninClientFactory::GetForProfile(profile); |
| 837 std::string signin_scoped_device_id = | 906 std::string signin_scoped_device_id = |
| 838 signin_client->GetSigninScopedDeviceId(); | 907 signin_client->GetSigninScopedDeviceId(); |
| 839 base::WeakPtr<InlineLoginHandlerImpl> handler_weak_ptr; | 908 base::WeakPtr<InlineLoginHandlerImpl> handler_weak_ptr; |
| 840 if (params.handler) | 909 if (params.handler) |
| 841 handler_weak_ptr = params.handler->GetWeakPtr(); | 910 handler_weak_ptr = params.handler->GetWeakPtr(); |
| 842 | 911 |
| 843 // InlineSigninHelper will delete itself. | 912 // InlineSigninHelper will delete itself. |
| 844 new InlineSigninHelper(handler_weak_ptr, | 913 new InlineSigninHelper( |
| 845 params.partition->GetURLRequestContext(), profile, | 914 handler_weak_ptr, params.partition->GetURLRequestContext(), profile, |
| 846 params.url, | 915 status, params.url, params.email, params.gaia_id, params.password, |
| 847 params.email, params.gaia_id, params.password, | 916 params.session_index, params.auth_code, signin_scoped_device_id, |
| 848 params.session_index, params.auth_code, | 917 params.choose_what_to_sync, params.confirm_untrusted_signin); |
| 849 signin_scoped_device_id, | |
| 850 params.choose_what_to_sync, | |
| 851 params.confirm_untrusted_signin); | |
| 852 | 918 |
| 853 // If opened from user manager to unlock a profile, make sure the user manager | 919 // If opened from user manager to unlock a profile, make sure the user manager |
| 854 // is closed and that the profile is marked as unlocked. | 920 // is closed and that the profile is marked as unlocked. |
| 855 if (!params.profile_path.empty()) { | 921 if (!params.profile_path.empty() && !signin::IsForceSigninEnabled()) { |
| 856 UserManager::Hide(); | 922 HideUserManager(params.profile_path, params.handler, profile, status); |
| 857 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 858 if (profile_manager) { | |
| 859 ProfileAttributesEntry* entry; | |
| 860 if (profile_manager->GetProfileAttributesStorage() | |
| 861 .GetProfileAttributesWithPath(params.profile_path, &entry)) { | |
| 862 entry->SetIsSigninRequired(false); | |
| 863 } | |
| 864 } | |
| 865 } | 923 } |
| 866 | |
| 867 if (params.handler) | |
| 868 params.handler->web_ui()->CallJavascriptFunctionUnsafe( | |
| 869 "inline.login.closeDialog"); | |
| 870 } | 924 } |
| 871 | 925 |
| 872 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg, | 926 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg, |
| 873 const base::string16& email) { | 927 const base::string16& email) { |
| 874 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 928 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
| 875 Browser* browser = GetDesktopBrowser(); | 929 Browser* browser = GetDesktopBrowser(); |
| 876 Profile* profile = Profile::FromWebUI(web_ui()); | 930 Profile* profile = Profile::FromWebUI(web_ui()); |
| 877 | 931 |
| 932 if (IsSystemProfile(profile)) | |
| 933 profile = g_browser_process->profile_manager()->GetProfileByPath( | |
| 934 UserManager::GetSigninProfilePath()); | |
| 878 CloseModalSigninIfNeeded(this); | 935 CloseModalSigninIfNeeded(this); |
| 879 if (browser && !error_msg.empty()) { | 936 if (!error_msg.empty()) { |
| 880 LoginUIServiceFactory::GetForProfile(profile)->DisplayLoginResult( | 937 LoginUIServiceFactory::GetForProfile(profile)->DisplayLoginResult( |
| 881 browser, base::UTF8ToUTF16(error_msg), email); | 938 browser, base::UTF8ToUTF16(error_msg), email); |
| 882 } | 939 } |
| 883 } | 940 } |
| 884 | 941 |
| 885 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { | 942 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { |
| 886 Browser* browser = chrome::FindBrowserWithWebContents( | 943 Browser* browser = chrome::FindBrowserWithWebContents( |
| 887 web_ui()->GetWebContents()); | 944 web_ui()->GetWebContents()); |
| 888 if (!browser) | 945 if (!browser) |
| 889 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); | 946 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 } | 990 } |
| 934 | 991 |
| 935 if (show_account_management) { | 992 if (show_account_management) { |
| 936 browser->window()->ShowAvatarBubbleFromAvatarButton( | 993 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 937 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 994 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
| 938 signin::ManageAccountsParams(), | 995 signin::ManageAccountsParams(), |
| 939 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); | 996 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); |
| 940 } | 997 } |
| 941 } | 998 } |
| 942 } | 999 } |
| OLD | NEW |