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

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

Issue 1473543002: Implement newly designed sign-in related histograms for desktop platorms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/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
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
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::LogSigninAccessPoint(access_point, true);
280
281 signin_metrics::Reason reason =
282 signin::GetSigninReasonForPromoURL(current_url_);
283 signin_metrics::LogSigninReason(reason);
Roger Tawa OOO till Jul 10th 2015/12/02 20:33:49 By this point, gaia sign in completed successfully
gogerald1 2015/12/03 17:49:03 Do it in one_click_signin_sync_starter
276 284
277 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); 285 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_);
278 std::string primary_email = 286 std::string primary_email =
279 signin_manager->GetAuthenticatedAccountInfo().email; 287 signin_manager->GetAuthenticatedAccountInfo().email;
280 if (gaia::AreEmailsSame(email_, primary_email) && 288 if (gaia::AreEmailsSame(email_, primary_email) &&
281 source == signin_metrics::SOURCE_REAUTH && 289 (reason == signin_metrics::REASON_REAUTHENTICATION ||
282 switches::IsNewProfileManagement() && 290 reason == signin_metrics::REASON_UNLOCK) &&
283 !password_.empty() && 291 switches::IsNewProfileManagement() && !password_.empty() &&
284 profiles::IsLockAvailable(profile_)) { 292 profiles::IsLockAvailable(profile_)) {
285 LocalAuth::SetLocalAuthCredentials(profile_, password_); 293 LocalAuth::SetLocalAuthCredentials(profile_, password_);
286 } 294 }
287 295
288 if (source == signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || 296 if (reason == signin_metrics::REASON_REAUTHENTICATION ||
289 source == signin_metrics::SOURCE_REAUTH) { 297 reason == signin_metrics::REASON_UNLOCK ||
298 reason == signin_metrics::REASON_ADD_SECONDARY_ACCOUNT) {
290 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> 299 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
291 UpdateCredentials(account_id, result.refresh_token); 300 UpdateCredentials(account_id, result.refresh_token);
292 301
293 if (signin::IsAutoCloseEnabledInURL(current_url_)) { 302 if (signin::IsAutoCloseEnabledInURL(current_url_)) {
294 // Close the gaia sign in tab via a task to make sure we aren't in the 303 // Close the gaia sign in tab via a task to make sure we aren't in the
295 // middle of any webui handler code. 304 // middle of any webui handler code.
296 base::ThreadTaskRunnerHandle::Get()->PostTask( 305 base::ThreadTaskRunnerHandle::Get()->PostTask(
297 FROM_HERE, 306 FROM_HERE,
298 base::Bind(&InlineLoginHandlerImpl::CloseTab, handler_, 307 base::Bind(&InlineLoginHandlerImpl::CloseTab, handler_,
299 signin::ShouldShowAccountManagement(current_url_))); 308 signin::ShouldShowAccountManagement(current_url_)));
300 } 309 }
301 310
302 if (source == signin_metrics::SOURCE_REAUTH) 311 if (reason == signin_metrics::REASON_REAUTHENTICATION ||
312 reason == signin_metrics::REASON_UNLOCK)
Roger Tawa OOO till Jul 10th 2015/12/02 20:33:48 Need { and } for if.
gogerald1 2015/12/03 17:49:03 Done.
303 signin_manager->MergeSigninCredentialIntoCookieJar(); 313 signin_manager->MergeSigninCredentialIntoCookieJar();
304 } else { 314 } else {
305 ProfileSyncService* sync_service = 315 ProfileSyncService* sync_service =
306 ProfileSyncServiceFactory::GetForProfile(profile_); 316 ProfileSyncServiceFactory::GetForProfile(profile_);
307 SigninErrorController* error_controller = 317 SigninErrorController* error_controller =
308 SigninErrorControllerFactory::GetForProfile(profile_); 318 SigninErrorControllerFactory::GetForProfile(profile_);
309 319
310 OneClickSigninSyncStarter::StartSyncMode start_mode = 320 OneClickSigninSyncStarter::StartSyncMode start_mode =
311 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST; 321 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST;
312 if (source == signin_metrics::SOURCE_SETTINGS || choose_what_to_sync_) { 322 if (access_point == signin_metrics::ACCESS_POINT_SETTINGS ||
323 choose_what_to_sync_) {
313 bool show_settings_without_configure = 324 bool show_settings_without_configure =
314 error_controller->HasError() && 325 error_controller->HasError() &&
315 sync_service && 326 sync_service &&
316 sync_service->HasSyncSetupCompleted(); 327 sync_service->HasSyncSetupCompleted();
317 start_mode = show_settings_without_configure ? 328 start_mode = show_settings_without_configure ?
318 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : 329 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE :
319 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST; 330 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST;
320 } 331 }
321 332
322 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = 333 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required =
323 confirm_untrusted_signin_ ? 334 confirm_untrusted_signin_ ?
324 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN : 335 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN :
325 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; 336 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
326 337
327 bool start_signin = !HandleCrossAccountError(result.refresh_token, source, 338 bool start_signin = !HandleCrossAccountError(
328 confirmation_required, start_mode); 339 result.refresh_token, confirmation_required, start_mode);
329 if (start_signin) { 340 if (start_signin) {
330 CreateSyncStarter(browser, 341 CreateSyncStarter(browser,
331 contents, 342 contents,
332 signin::GetNextPageURLForPromoURL(current_url_), 343 signin::GetNextPageURLForPromoURL(current_url_),
333 result.refresh_token, 344 result.refresh_token,
334 start_mode, 345 start_mode,
335 confirmation_required); 346 confirmation_required);
336 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 347 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
337 } 348 }
338 } 349 }
(...skipping 12 matching lines...) Expand all
351 gaia_id_, email_, password_, refresh_token, 362 gaia_id_, email_, password_, refresh_token,
352 start_mode, 363 start_mode,
353 contents, 364 contents,
354 confirmation_required, 365 confirmation_required,
355 url, 366 url,
356 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); 367 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_));
357 } 368 }
358 369
359 bool InlineSigninHelper::HandleCrossAccountError( 370 bool InlineSigninHelper::HandleCrossAccountError(
360 const std::string& refresh_token, 371 const std::string& refresh_token,
361 signin_metrics::Source source,
362 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, 372 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required,
363 OneClickSigninSyncStarter::StartSyncMode start_mode) { 373 OneClickSigninSyncStarter::StartSyncMode start_mode) {
364 std::string last_email = 374 std::string last_email =
365 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); 375 profile_->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
366 376
367 if (last_email.empty() || gaia::AreEmailsSame(last_email, email_)) 377 if (last_email.empty() || gaia::AreEmailsSame(last_email, email_))
368 return false; 378 return false;
369 379
370 Browser* browser = chrome::FindLastActiveWithProfile( 380 Browser* browser = chrome::FindLastActiveWithProfile(
371 profile_, chrome::GetActiveDesktop()); 381 profile_, chrome::GetActiveDesktop());
372 content::WebContents* web_contents = 382 content::WebContents* web_contents =
373 browser->tab_strip_model()->GetActiveWebContents(); 383 browser->tab_strip_model()->GetActiveWebContents();
374 384
375 ConfirmEmailDialogDelegate::AskForConfirmation( 385 ConfirmEmailDialogDelegate::AskForConfirmation(
376 web_contents, 386 web_contents,
377 last_email, 387 last_email,
378 email_, 388 email_,
379 base::Bind(&InlineSigninHelper::ConfirmEmailAction, 389 base::Bind(&InlineSigninHelper::ConfirmEmailAction,
380 base::Unretained(this), 390 base::Unretained(this),
381 web_contents, 391 web_contents,
382 refresh_token, 392 refresh_token,
383 source,
384 confirmation_required, 393 confirmation_required,
385 start_mode)); 394 start_mode));
386 return true; 395 return true;
387 } 396 }
388 397
389 void InlineSigninHelper::ConfirmEmailAction( 398 void InlineSigninHelper::ConfirmEmailAction(
390 content::WebContents* web_contents, 399 content::WebContents* web_contents,
391 const std::string& refresh_token, 400 const std::string& refresh_token,
392 signin_metrics::Source source,
393 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, 401 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required,
394 OneClickSigninSyncStarter::StartSyncMode start_mode, 402 OneClickSigninSyncStarter::StartSyncMode start_mode,
395 InlineSigninHelper::Action action) { 403 InlineSigninHelper::Action action) {
396 Browser* browser = chrome::FindLastActiveWithProfile( 404 Browser* browser = chrome::FindLastActiveWithProfile(
397 profile_, chrome::GetActiveDesktop()); 405 profile_, chrome::GetActiveDesktop());
398 switch (action) { 406 switch (action) {
399 case InlineSigninHelper::CREATE_NEW_USER: 407 case InlineSigninHelper::CREATE_NEW_USER:
400 if (handler_) { 408 if (handler_) {
401 handler_->SyncStarterCallback( 409 handler_->SyncStarterCallback(
402 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 410 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 params.SetString("service", "chromiumsync"); 560 params.SetString("service", "chromiumsync");
553 561
554 // If this was called from the user manager to reauthenticate the profile, 562 // If this was called from the user manager to reauthenticate the profile,
555 // make sure the webui is aware. 563 // make sure the webui is aware.
556 Profile* profile = Profile::FromWebUI(web_ui()); 564 Profile* profile = Profile::FromWebUI(web_ui());
557 if (IsSystemProfile(profile)) 565 if (IsSystemProfile(profile))
558 params.SetBoolean("dontResizeNonEmbeddedPages", true); 566 params.SetBoolean("dontResizeNonEmbeddedPages", true);
559 567
560 content::WebContents* contents = web_ui()->GetWebContents(); 568 content::WebContents* contents = web_ui()->GetWebContents();
561 const GURL& current_url = contents->GetURL(); 569 const GURL& current_url = contents->GetURL();
562 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url); 570 signin_metrics::Reason reason =
571 signin::GetSigninReasonForPromoURL(current_url);
563 572
564 std::string is_constrained; 573 std::string is_constrained;
565 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); 574 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
566 575
567 // Use new embedded flow if in constrained window. 576 // Use new embedded flow if in constrained window.
568 if (is_constrained == "1") { 577 if (is_constrained == "1") {
569 const bool is_new_gaia_flow = switches::UsePasswordSeparatedSigninFlow(); 578 const bool is_new_gaia_flow = switches::UsePasswordSeparatedSigninFlow();
570 const GURL& url = is_new_gaia_flow 579 const GURL& url = is_new_gaia_flow
571 ? GaiaUrls::GetInstance()->embedded_signin_url() 580 ? GaiaUrls::GetInstance()->embedded_signin_url()
572 : GaiaUrls::GetInstance()->password_combined_embedded_signin_url(); 581 : GaiaUrls::GetInstance()->password_combined_embedded_signin_url();
573 params.SetBoolean("isNewGaiaFlow", is_new_gaia_flow); 582 params.SetBoolean("isNewGaiaFlow", is_new_gaia_flow);
574 params.SetString("clientId", 583 params.SetString("clientId",
575 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); 584 GaiaUrls::GetInstance()->oauth2_chrome_client_id());
576 params.SetString("gaiaPath", url.path().substr(1)); 585 params.SetString("gaiaPath", url.path().substr(1));
577 586
578 std::string flow; 587 std::string flow;
579 switch (source) { 588 switch (reason) {
580 case signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: 589 case signin_metrics::REASON_ADD_SECONDARY_ACCOUNT:
581 flow = "addaccount"; 590 flow = "addaccount";
582 break; 591 break;
583 case signin_metrics::SOURCE_REAUTH: 592 case signin_metrics::REASON_REAUTHENTICATION:
593 case signin_metrics::REASON_UNLOCK:
584 flow = "reauth"; 594 flow = "reauth";
585 break; 595 break;
586 default: 596 default:
587 flow = "signin"; 597 flow = "signin";
588 break; 598 break;
589 } 599 }
590 params.SetString("flow", flow); 600 params.SetString("flow", flow);
591 } 601 }
592 602
593 content::WebContentsObserver::Observe(contents); 603 content::WebContentsObserver::Observe(contents);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 if (!gaia::AreEmailsSame(params.email, default_email)) { 736 if (!gaia::AreEmailsSame(params.email, default_email)) {
727 if (params.handler) { 737 if (params.handler) {
728 params.handler->HandleLoginError( 738 params.handler->HandleLoginError(
729 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, 739 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL,
730 base::UTF8ToUTF16(default_email))); 740 base::UTF8ToUTF16(default_email)));
731 } 741 }
732 return; 742 return;
733 } 743 }
734 } 744 }
735 745
736 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);
737 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); 750 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED);
738 bool switch_to_advanced = 751 bool switch_to_advanced =
739 params.choose_what_to_sync && (source != signin_metrics::SOURCE_SETTINGS); 752 params.choose_what_to_sync &&
753 (access_point != signin_metrics::ACCESS_POINT_SETTINGS);
740 LogHistogramValue( 754 LogHistogramValue(
741 switch_to_advanced ? signin_metrics::HISTOGRAM_WITH_ADVANCED : 755 switch_to_advanced ? signin_metrics::HISTOGRAM_WITH_ADVANCED :
742 signin_metrics::HISTOGRAM_WITH_DEFAULTS); 756 signin_metrics::HISTOGRAM_WITH_DEFAULTS);
743 757
744 CanOfferFor can_offer_for = CAN_OFFER_FOR_ALL; 758 CanOfferFor can_offer_for = CAN_OFFER_FOR_ALL;
745 switch (source) { 759 switch (reason) {
746 case signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: 760 case signin_metrics::REASON_ADD_SECONDARY_ACCOUNT:
747 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; 761 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT;
748 break; 762 break;
749 case signin_metrics::SOURCE_REAUTH: { 763 case signin_metrics::REASON_REAUTHENTICATION:
764 case signin_metrics::REASON_UNLOCK: {
750 std::string primary_username = 765 std::string primary_username =
751 SigninManagerFactory::GetForProfile(profile) 766 SigninManagerFactory::GetForProfile(profile)
752 ->GetAuthenticatedAccountInfo() 767 ->GetAuthenticatedAccountInfo()
753 .email; 768 .email;
754 if (!gaia::AreEmailsSame(default_email, primary_username)) 769 if (!gaia::AreEmailsSame(default_email, primary_username))
755 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT; 770 can_offer_for = CAN_OFFER_FOR_SECONDARY_ACCOUNT;
756 break; 771 break;
757 } 772 }
758 default: 773 default:
759 // 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
835 content::WebContents* contents = web_ui()->GetWebContents(); 850 content::WebContents* contents = web_ui()->GetWebContents();
836 851
837 if (contents->GetController().GetPendingEntry()) { 852 if (contents->GetController().GetPendingEntry()) {
838 // 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
839 // from DidStartLoading. This avoids deleting the pending entry while we are 854 // from DidStartLoading. This avoids deleting the pending entry while we are
840 // still navigating to it. See crbug/346632. 855 // still navigating to it. See crbug/346632.
841 return; 856 return;
842 } 857 }
843 858
844 const GURL& current_url = contents->GetLastCommittedURL(); 859 const GURL& current_url = contents->GetLastCommittedURL();
845 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url); 860 signin_metrics::AccessPoint access_point =
861 signin::GetAccessPointForPromoURL(current_url);
846 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); 862 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url);
847 863
848 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) { 864 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) {
849 RedirectToNtpOrAppsPage(contents, source); 865 RedirectToNtpOrAppsPage(contents, access_point);
850 } else if (auto_close) { 866 } else if (auto_close) {
851 base::ThreadTaskRunnerHandle::Get()->PostTask( 867 base::ThreadTaskRunnerHandle::Get()->PostTask(
852 FROM_HERE, 868 FROM_HERE,
853 base::Bind(&InlineLoginHandlerImpl::CloseTab, 869 base::Bind(&InlineLoginHandlerImpl::CloseTab,
854 weak_factory_.GetWeakPtr(), 870 weak_factory_.GetWeakPtr(),
855 signin::ShouldShowAccountManagement(current_url))); 871 signin::ShouldShowAccountManagement(current_url)));
856 } else { 872 } else {
857 RedirectToNtpOrAppsPageIfNecessary(contents, source); 873 RedirectToNtpOrAppsPageIfNecessary(contents, access_point);
858 } 874 }
859 } 875 }
860 876
861 void InlineLoginHandlerImpl::CloseTab(bool show_account_management) { 877 void InlineLoginHandlerImpl::CloseTab(bool show_account_management) {
862 content::WebContents* tab = web_ui()->GetWebContents(); 878 content::WebContents* tab = web_ui()->GetWebContents();
863 Browser* browser = chrome::FindBrowserWithWebContents(tab); 879 Browser* browser = chrome::FindBrowserWithWebContents(tab);
864 if (browser) { 880 if (browser) {
865 TabStripModel* tab_strip_model = browser->tab_strip_model(); 881 TabStripModel* tab_strip_model = browser->tab_strip_model();
866 if (tab_strip_model) { 882 if (tab_strip_model) {
867 int index = tab_strip_model->GetIndexOfWebContents(tab); 883 int index = tab_strip_model->GetIndexOfWebContents(tab);
868 if (index != TabStripModel::kNoTab) { 884 if (index != TabStripModel::kNoTab) {
869 tab_strip_model->ExecuteContextMenuCommand( 885 tab_strip_model->ExecuteContextMenuCommand(
870 index, TabStripModel::CommandCloseTab); 886 index, TabStripModel::CommandCloseTab);
871 } 887 }
872 } 888 }
873 889
874 if (show_account_management) { 890 if (show_account_management) {
875 browser->window()->ShowAvatarBubbleFromAvatarButton( 891 browser->window()->ShowAvatarBubbleFromAvatarButton(
876 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, 892 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
877 signin::ManageAccountsParams()); 893 signin::ManageAccountsParams(),
894 signin_metrics::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
878 } 895 }
879 } 896 }
880 } 897 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698