| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, | 67 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
| 68 signin_metrics::HISTOGRAM_MAX); | 68 signin_metrics::HISTOGRAM_MAX); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Returns true if |profile| is a system profile or created from one. | 71 // Returns true if |profile| is a system profile or created from one. |
| 72 bool IsSystemProfile(Profile* profile) { | 72 bool IsSystemProfile(Profile* profile) { |
| 73 return profile->GetOriginalProfile()->IsSystemProfile(); | 73 return profile->GetOriginalProfile()->IsSystemProfile(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void RedirectToNtpOrAppsPage(content::WebContents* contents, | 76 void RedirectToNtpOrAppsPage(content::WebContents* contents, |
| 77 signin_metrics::Source source) { | 77 signin_metrics::AccessPoint access_point) { |
| 78 // Do nothing if a navigation is pending, since this call can be triggered | 78 // Do nothing if a navigation is pending, since this call can be triggered |
| 79 // from DidStartLoading. This avoids deleting the pending entry while we are | 79 // from DidStartLoading. This avoids deleting the pending entry while we are |
| 80 // still navigating to it. See crbug/346632. | 80 // still navigating to it. See crbug/346632. |
| 81 if (contents->GetController().GetPendingEntry()) | 81 if (contents->GetController().GetPendingEntry()) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 VLOG(1) << "RedirectToNtpOrAppsPage"; | 84 VLOG(1) << "RedirectToNtpOrAppsPage"; |
| 85 // Redirect to NTP/Apps page and display a confirmation bubble | 85 // Redirect to NTP/Apps page and display a confirmation bubble |
| 86 GURL url(source == signin_metrics::SOURCE_APPS_PAGE_LINK ? | 86 GURL url(access_point == signin_metrics::ACCESS_POINT_APPS_PAGE_LINK |
| 87 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); | 87 ? chrome::kChromeUIAppsURL |
| 88 : chrome::kChromeUINewTabURL); |
| 88 content::OpenURLParams params(url, | 89 content::OpenURLParams params(url, |
| 89 content::Referrer(), | 90 content::Referrer(), |
| 90 CURRENT_TAB, | 91 CURRENT_TAB, |
| 91 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 92 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 92 false); | 93 false); |
| 93 contents->OpenURL(params); | 94 contents->OpenURL(params); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void RedirectToNtpOrAppsPageIfNecessary(content::WebContents* contents, | 97 void RedirectToNtpOrAppsPageIfNecessary( |
| 97 signin_metrics::Source source) { | 98 content::WebContents* contents, |
| 98 if (source != signin_metrics::SOURCE_SETTINGS) | 99 signin_metrics::AccessPoint access_point) { |
| 99 RedirectToNtpOrAppsPage(contents, source); | 100 if (access_point != signin_metrics::ACCESS_POINT_SETTINGS) |
| 101 RedirectToNtpOrAppsPage(contents, access_point); |
| 100 } | 102 } |
| 101 | 103 |
| 102 class ConfirmEmailDialogDelegate : public TabModalConfirmDialogDelegate { | 104 class ConfirmEmailDialogDelegate : public TabModalConfirmDialogDelegate { |
| 103 public: | 105 public: |
| 104 // Callback indicating action performed by the user. | 106 // Callback indicating action performed by the user. |
| 105 typedef base::Callback<void(InlineSigninHelper::Action)> Callback; | 107 typedef base::Callback<void(InlineSigninHelper::Action)> Callback; |
| 106 | 108 |
| 107 // Ask the user for confirmation before starting to sync. | 109 // Ask the user for confirmation before starting to sync. |
| 108 static void AskForConfirmation(content::WebContents* contents, | 110 static void AskForConfirmation(content::WebContents* contents, |
| 109 const std::string& last_email, | 111 const std::string& last_email, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 267 |
| 266 AboutSigninInternals* about_signin_internals = | 268 AboutSigninInternals* about_signin_internals = |
| 267 AboutSigninInternalsFactory::GetForProfile(profile_); | 269 AboutSigninInternalsFactory::GetForProfile(profile_); |
| 268 about_signin_internals->OnRefreshTokenReceived("Successful"); | 270 about_signin_internals->OnRefreshTokenReceived("Successful"); |
| 269 | 271 |
| 270 // Prime the account tracker with this combination of gaia id/display email. | 272 // Prime the account tracker with this combination of gaia id/display email. |
| 271 std::string account_id = | 273 std::string account_id = |
| 272 AccountTrackerServiceFactory::GetForProfile(profile_) | 274 AccountTrackerServiceFactory::GetForProfile(profile_) |
| 273 ->SeedAccountInfo(gaia_id_, email_); | 275 ->SeedAccountInfo(gaia_id_, email_); |
| 274 | 276 |
| 275 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url_); | 277 signin_metrics::AccessPoint access_point = |
| 278 signin::GetAccessPointForPromoURL(current_url_); |
| 279 signin_metrics::Reason reason = |
| 280 signin::GetSigninReasonForPromoURL(current_url_); |
| 276 | 281 |
| 277 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); | 282 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); |
| 278 std::string primary_email = | 283 std::string primary_email = |
| 279 signin_manager->GetAuthenticatedAccountInfo().email; | 284 signin_manager->GetAuthenticatedAccountInfo().email; |
| 280 if (gaia::AreEmailsSame(email_, primary_email) && | 285 if (gaia::AreEmailsSame(email_, primary_email) && |
| 281 source == signin_metrics::SOURCE_REAUTH && | 286 (reason == signin_metrics::REASON_REAUTHENTICATION || |
| 282 switches::IsNewProfileManagement() && | 287 reason == signin_metrics::REASON_UNLOCK) && |
| 283 !password_.empty() && | 288 switches::IsNewProfileManagement() && !password_.empty() && |
| 284 profiles::IsLockAvailable(profile_)) { | 289 profiles::IsLockAvailable(profile_)) { |
| 285 LocalAuth::SetLocalAuthCredentials(profile_, password_); | 290 LocalAuth::SetLocalAuthCredentials(profile_, password_); |
| 286 } | 291 } |
| 287 | 292 |
| 288 if (source == signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || | 293 if (reason == signin_metrics::REASON_REAUTHENTICATION || |
| 289 source == signin_metrics::SOURCE_REAUTH) { | 294 reason == signin_metrics::REASON_UNLOCK || |
| 295 reason == signin_metrics::REASON_ADD_SECONDARY_ACCOUNT) { |
| 290 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> | 296 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> |
| 291 UpdateCredentials(account_id, result.refresh_token); | 297 UpdateCredentials(account_id, result.refresh_token); |
| 292 | 298 |
| 293 if (signin::IsAutoCloseEnabledInURL(current_url_)) { | 299 if (signin::IsAutoCloseEnabledInURL(current_url_)) { |
| 294 // Close the gaia sign in tab via a task to make sure we aren't in the | 300 // Close the gaia sign in tab via a task to make sure we aren't in the |
| 295 // middle of any webui handler code. | 301 // middle of any webui handler code. |
| 296 base::ThreadTaskRunnerHandle::Get()->PostTask( | 302 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 297 FROM_HERE, | 303 FROM_HERE, |
| 298 base::Bind(&InlineLoginHandlerImpl::CloseTab, handler_, | 304 base::Bind(&InlineLoginHandlerImpl::CloseTab, handler_, |
| 299 signin::ShouldShowAccountManagement(current_url_))); | 305 signin::ShouldShowAccountManagement(current_url_))); |
| 300 } | 306 } |
| 301 | 307 |
| 302 if (source == signin_metrics::SOURCE_REAUTH) | 308 if (reason == signin_metrics::REASON_REAUTHENTICATION || |
| 309 reason == signin_metrics::REASON_UNLOCK) { |
| 303 signin_manager->MergeSigninCredentialIntoCookieJar(); | 310 signin_manager->MergeSigninCredentialIntoCookieJar(); |
| 311 } |
| 304 } else { | 312 } else { |
| 305 ProfileSyncService* sync_service = | 313 ProfileSyncService* sync_service = |
| 306 ProfileSyncServiceFactory::GetForProfile(profile_); | 314 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 307 SigninErrorController* error_controller = | 315 SigninErrorController* error_controller = |
| 308 SigninErrorControllerFactory::GetForProfile(profile_); | 316 SigninErrorControllerFactory::GetForProfile(profile_); |
| 309 | 317 |
| 310 OneClickSigninSyncStarter::StartSyncMode start_mode = | 318 OneClickSigninSyncStarter::StartSyncMode start_mode = |
| 311 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST; | 319 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST; |
| 312 if (source == signin_metrics::SOURCE_SETTINGS || choose_what_to_sync_) { | 320 if (access_point == signin_metrics::ACCESS_POINT_SETTINGS || |
| 321 choose_what_to_sync_) { |
| 313 bool show_settings_without_configure = | 322 bool show_settings_without_configure = |
| 314 error_controller->HasError() && | 323 error_controller->HasError() && |
| 315 sync_service && | 324 sync_service && |
| 316 sync_service->HasSyncSetupCompleted(); | 325 sync_service->HasSyncSetupCompleted(); |
| 317 start_mode = show_settings_without_configure ? | 326 start_mode = show_settings_without_configure ? |
| 318 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : | 327 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : |
| 319 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST; | 328 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST; |
| 320 } | 329 } |
| 321 | 330 |
| 322 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = | 331 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = |
| 323 confirm_untrusted_signin_ ? | 332 confirm_untrusted_signin_ ? |
| 324 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN : | 333 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN : |
| 325 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; | 334 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; |
| 326 | 335 |
| 327 bool start_signin = !HandleCrossAccountError(result.refresh_token, source, | 336 bool start_signin = !HandleCrossAccountError( |
| 328 confirmation_required, start_mode); | 337 result.refresh_token, confirmation_required, start_mode); |
| 329 if (start_signin) { | 338 if (start_signin) { |
| 330 CreateSyncStarter(browser, | 339 CreateSyncStarter(browser, |
| 331 contents, | 340 contents, |
| 332 signin::GetNextPageURLForPromoURL(current_url_), | 341 signin::GetNextPageURLForPromoURL(current_url_), |
| 333 result.refresh_token, | 342 result.refresh_token, |
| 334 start_mode, | 343 start_mode, |
| 335 confirmation_required); | 344 confirmation_required); |
| 336 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 345 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 337 } | 346 } |
| 338 } | 347 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 351 gaia_id_, email_, password_, refresh_token, | 360 gaia_id_, email_, password_, refresh_token, |
| 352 start_mode, | 361 start_mode, |
| 353 contents, | 362 contents, |
| 354 confirmation_required, | 363 confirmation_required, |
| 355 url, | 364 url, |
| 356 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); | 365 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); |
| 357 } | 366 } |
| 358 | 367 |
| 359 bool InlineSigninHelper::HandleCrossAccountError( | 368 bool InlineSigninHelper::HandleCrossAccountError( |
| 360 const std::string& refresh_token, | 369 const std::string& refresh_token, |
| 361 signin_metrics::Source source, | |
| 362 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, | 370 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, |
| 363 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 371 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 364 std::string last_email = | 372 std::string last_email = |
| 365 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 373 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 366 | 374 |
| 367 if (last_email.empty() || gaia::AreEmailsSame(last_email, email_)) | 375 if (last_email.empty() || gaia::AreEmailsSame(last_email, email_)) |
| 368 return false; | 376 return false; |
| 369 | 377 |
| 370 Browser* browser = chrome::FindLastActiveWithProfile( | 378 Browser* browser = chrome::FindLastActiveWithProfile( |
| 371 profile_, chrome::GetActiveDesktop()); | 379 profile_, chrome::GetActiveDesktop()); |
| 372 content::WebContents* web_contents = | 380 content::WebContents* web_contents = |
| 373 browser->tab_strip_model()->GetActiveWebContents(); | 381 browser->tab_strip_model()->GetActiveWebContents(); |
| 374 | 382 |
| 375 ConfirmEmailDialogDelegate::AskForConfirmation( | 383 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 376 web_contents, | 384 web_contents, |
| 377 last_email, | 385 last_email, |
| 378 email_, | 386 email_, |
| 379 base::Bind(&InlineSigninHelper::ConfirmEmailAction, | 387 base::Bind(&InlineSigninHelper::ConfirmEmailAction, |
| 380 base::Unretained(this), | 388 base::Unretained(this), |
| 381 web_contents, | 389 web_contents, |
| 382 refresh_token, | 390 refresh_token, |
| 383 source, | |
| 384 confirmation_required, | 391 confirmation_required, |
| 385 start_mode)); | 392 start_mode)); |
| 386 return true; | 393 return true; |
| 387 } | 394 } |
| 388 | 395 |
| 389 void InlineSigninHelper::ConfirmEmailAction( | 396 void InlineSigninHelper::ConfirmEmailAction( |
| 390 content::WebContents* web_contents, | 397 content::WebContents* web_contents, |
| 391 const std::string& refresh_token, | 398 const std::string& refresh_token, |
| 392 signin_metrics::Source source, | |
| 393 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, | 399 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, |
| 394 OneClickSigninSyncStarter::StartSyncMode start_mode, | 400 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 395 InlineSigninHelper::Action action) { | 401 InlineSigninHelper::Action action) { |
| 396 Browser* browser = chrome::FindLastActiveWithProfile( | 402 Browser* browser = chrome::FindLastActiveWithProfile( |
| 397 profile_, chrome::GetActiveDesktop()); | 403 profile_, chrome::GetActiveDesktop()); |
| 398 switch (action) { | 404 switch (action) { |
| 399 case InlineSigninHelper::CREATE_NEW_USER: | 405 case InlineSigninHelper::CREATE_NEW_USER: |
| 400 if (handler_) { | 406 if (handler_) { |
| 401 handler_->SyncStarterCallback( | 407 handler_->SyncStarterCallback( |
| 402 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 408 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 params.SetString("service", "chromiumsync"); | 558 params.SetString("service", "chromiumsync"); |
| 553 | 559 |
| 554 // If this was called from the user manager to reauthenticate the profile, | 560 // If this was called from the user manager to reauthenticate the profile, |
| 555 // make sure the webui is aware. | 561 // make sure the webui is aware. |
| 556 Profile* profile = Profile::FromWebUI(web_ui()); | 562 Profile* profile = Profile::FromWebUI(web_ui()); |
| 557 if (IsSystemProfile(profile)) | 563 if (IsSystemProfile(profile)) |
| 558 params.SetBoolean("dontResizeNonEmbeddedPages", true); | 564 params.SetBoolean("dontResizeNonEmbeddedPages", true); |
| 559 | 565 |
| 560 content::WebContents* contents = web_ui()->GetWebContents(); | 566 content::WebContents* contents = web_ui()->GetWebContents(); |
| 561 const GURL& current_url = contents->GetURL(); | 567 const GURL& current_url = contents->GetURL(); |
| 562 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url); | 568 signin_metrics::Reason reason = |
| 569 signin::GetSigninReasonForPromoURL(current_url); |
| 563 | 570 |
| 564 std::string is_constrained; | 571 std::string is_constrained; |
| 565 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); | 572 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); |
| 566 | 573 |
| 567 // Use new embedded flow if in constrained window. | 574 // Use new embedded flow if in constrained window. |
| 568 if (is_constrained == "1") { | 575 if (is_constrained == "1") { |
| 569 const bool is_new_gaia_flow = switches::UsePasswordSeparatedSigninFlow(); | 576 const bool is_new_gaia_flow = switches::UsePasswordSeparatedSigninFlow(); |
| 570 const GURL& url = is_new_gaia_flow | 577 const GURL& url = is_new_gaia_flow |
| 571 ? GaiaUrls::GetInstance()->embedded_signin_url() | 578 ? GaiaUrls::GetInstance()->embedded_signin_url() |
| 572 : GaiaUrls::GetInstance()->password_combined_embedded_signin_url(); | 579 : GaiaUrls::GetInstance()->password_combined_embedded_signin_url(); |
| 573 params.SetBoolean("isNewGaiaFlow", is_new_gaia_flow); | 580 params.SetBoolean("isNewGaiaFlow", is_new_gaia_flow); |
| 574 params.SetString("clientId", | 581 params.SetString("clientId", |
| 575 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); | 582 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); |
| 576 params.SetString("gaiaPath", url.path().substr(1)); | 583 params.SetString("gaiaPath", url.path().substr(1)); |
| 577 | 584 |
| 578 std::string flow; | 585 std::string flow; |
| 579 switch (source) { | 586 switch (reason) { |
| 580 case signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: | 587 case signin_metrics::REASON_ADD_SECONDARY_ACCOUNT: |
| 581 flow = "addaccount"; | 588 flow = "addaccount"; |
| 582 break; | 589 break; |
| 583 case signin_metrics::SOURCE_REAUTH: | 590 case signin_metrics::REASON_REAUTHENTICATION: |
| 591 case signin_metrics::REASON_UNLOCK: |
| 584 flow = "reauth"; | 592 flow = "reauth"; |
| 585 break; | 593 break; |
| 586 default: | 594 default: |
| 587 flow = "signin"; | 595 flow = "signin"; |
| 588 break; | 596 break; |
| 589 } | 597 } |
| 590 params.SetString("flow", flow); | 598 params.SetString("flow", flow); |
| 591 } | 599 } |
| 592 | 600 |
| 593 content::WebContentsObserver::Observe(contents); | 601 content::WebContentsObserver::Observe(contents); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (!gaia::AreEmailsSame(params.email, default_email)) { | 740 if (!gaia::AreEmailsSame(params.email, default_email)) { |
| 733 if (params.handler) { | 741 if (params.handler) { |
| 734 params.handler->HandleLoginError( | 742 params.handler->HandleLoginError( |
| 735 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, | 743 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, |
| 736 base::UTF8ToUTF16(default_email))); | 744 base::UTF8ToUTF16(default_email))); |
| 737 } | 745 } |
| 738 return; | 746 return; |
| 739 } | 747 } |
| 740 } | 748 } |
| 741 | 749 |
| 742 signin_metrics::Source source = signin::GetSourceForPromoURL(params.url); | 750 signin_metrics::AccessPoint access_point = |
| 751 signin::GetAccessPointForPromoURL(params.url); |
| 752 signin_metrics::Reason reason = |
| 753 signin::GetSigninReasonForPromoURL(params.url); |
| 743 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); | 754 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
| 744 bool switch_to_advanced = | 755 bool switch_to_advanced = |
| 745 params.choose_what_to_sync && (source != signin_metrics::SOURCE_SETTINGS); | 756 params.choose_what_to_sync && |
| 757 (access_point != signin_metrics::ACCESS_POINT_SETTINGS); |
| 746 LogHistogramValue( | 758 LogHistogramValue( |
| 747 switch_to_advanced ? signin_metrics::HISTOGRAM_WITH_ADVANCED : | 759 switch_to_advanced ? signin_metrics::HISTOGRAM_WITH_ADVANCED : |
| 748 signin_metrics::HISTOGRAM_WITH_DEFAULTS); | 760 signin_metrics::HISTOGRAM_WITH_DEFAULTS); |
| 749 | 761 |
| 750 CanOfferFor can_offer_for = CAN_OFFER_FOR_ALL; | 762 CanOfferFor can_offer_for = CAN_OFFER_FOR_ALL; |
| 751 switch (source) { | 763 switch (reason) { |
| 752 case signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: | 764 case signin_metrics::REASON_ADD_SECONDARY_ACCOUNT: |
| 753 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; | 765 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; |
| 754 break; | 766 break; |
| 755 case signin_metrics::SOURCE_REAUTH: { | 767 case signin_metrics::REASON_REAUTHENTICATION: |
| 768 case signin_metrics::REASON_UNLOCK: { |
| 756 std::string primary_username = | 769 std::string primary_username = |
| 757 SigninManagerFactory::GetForProfile(profile) | 770 SigninManagerFactory::GetForProfile(profile) |
| 758 ->GetAuthenticatedAccountInfo() | 771 ->GetAuthenticatedAccountInfo() |
| 759 .email; | 772 .email; |
| 760 if (!gaia::AreEmailsSame(default_email, primary_username)) | 773 if (!gaia::AreEmailsSame(default_email, primary_username)) |
| 761 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; | 774 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; |
| 762 break; | 775 break; |
| 763 } | 776 } |
| 764 default: | 777 default: |
| 765 // No need to change |can_offer_for|. | 778 // No need to change |can_offer_for|. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 content::WebContents* contents = web_ui()->GetWebContents(); | 854 content::WebContents* contents = web_ui()->GetWebContents(); |
| 842 | 855 |
| 843 if (contents->GetController().GetPendingEntry()) { | 856 if (contents->GetController().GetPendingEntry()) { |
| 844 // Do nothing if a navigation is pending, since this call can be triggered | 857 // Do nothing if a navigation is pending, since this call can be triggered |
| 845 // from DidStartLoading. This avoids deleting the pending entry while we are | 858 // from DidStartLoading. This avoids deleting the pending entry while we are |
| 846 // still navigating to it. See crbug/346632. | 859 // still navigating to it. See crbug/346632. |
| 847 return; | 860 return; |
| 848 } | 861 } |
| 849 | 862 |
| 850 const GURL& current_url = contents->GetLastCommittedURL(); | 863 const GURL& current_url = contents->GetLastCommittedURL(); |
| 851 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url); | 864 signin_metrics::AccessPoint access_point = |
| 865 signin::GetAccessPointForPromoURL(current_url); |
| 852 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); | 866 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); |
| 853 | 867 |
| 854 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) { | 868 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) { |
| 855 RedirectToNtpOrAppsPage(contents, source); | 869 RedirectToNtpOrAppsPage(contents, access_point); |
| 856 } else if (auto_close) { | 870 } else if (auto_close) { |
| 857 base::ThreadTaskRunnerHandle::Get()->PostTask( | 871 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 858 FROM_HERE, | 872 FROM_HERE, |
| 859 base::Bind(&InlineLoginHandlerImpl::CloseTab, | 873 base::Bind(&InlineLoginHandlerImpl::CloseTab, |
| 860 weak_factory_.GetWeakPtr(), | 874 weak_factory_.GetWeakPtr(), |
| 861 signin::ShouldShowAccountManagement(current_url))); | 875 signin::ShouldShowAccountManagement(current_url))); |
| 862 } else { | 876 } else { |
| 863 RedirectToNtpOrAppsPageIfNecessary(contents, source); | 877 RedirectToNtpOrAppsPageIfNecessary(contents, access_point); |
| 864 } | 878 } |
| 865 } | 879 } |
| 866 | 880 |
| 867 void InlineLoginHandlerImpl::CloseTab(bool show_account_management) { | 881 void InlineLoginHandlerImpl::CloseTab(bool show_account_management) { |
| 868 content::WebContents* tab = web_ui()->GetWebContents(); | 882 content::WebContents* tab = web_ui()->GetWebContents(); |
| 869 Browser* browser = chrome::FindBrowserWithWebContents(tab); | 883 Browser* browser = chrome::FindBrowserWithWebContents(tab); |
| 870 if (browser) { | 884 if (browser) { |
| 871 TabStripModel* tab_strip_model = browser->tab_strip_model(); | 885 TabStripModel* tab_strip_model = browser->tab_strip_model(); |
| 872 if (tab_strip_model) { | 886 if (tab_strip_model) { |
| 873 int index = tab_strip_model->GetIndexOfWebContents(tab); | 887 int index = tab_strip_model->GetIndexOfWebContents(tab); |
| 874 if (index != TabStripModel::kNoTab) { | 888 if (index != TabStripModel::kNoTab) { |
| 875 tab_strip_model->ExecuteContextMenuCommand( | 889 tab_strip_model->ExecuteContextMenuCommand( |
| 876 index, TabStripModel::CommandCloseTab); | 890 index, TabStripModel::CommandCloseTab); |
| 877 } | 891 } |
| 878 } | 892 } |
| 879 | 893 |
| 880 if (show_account_management) { | 894 if (show_account_management) { |
| 881 browser->window()->ShowAvatarBubbleFromAvatarButton( | 895 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 882 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 896 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
| 883 signin::ManageAccountsParams()); | 897 signin::ManageAccountsParams(), |
| 898 signin_metrics::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); |
| 884 } | 899 } |
| 885 } | 900 } |
| 886 } | 901 } |
| OLD | NEW |