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