Commit ea6d9bad authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Add a function to turn sync on from single account promos.

This CL attempts to simplify a bit the the call to enable sync
from the native promos that are single account.

Bug: 1140978
Change-Id: Ie085da9775a3c81b9457b077ef283ca0b4f77576
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490107
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819831}
parent 30dc7319
......@@ -199,7 +199,15 @@ void ShowSigninErrorLearnMorePage(Profile* profile) {
Navigate(&params);
}
void EnableSyncFromPromo(Browser* browser,
void EnableSyncFromSingleAccountPromo(
Browser* browser,
const AccountInfo& account,
signin_metrics::AccessPoint access_point) {
EnableSyncFromMultiAccountPromo(browser, account, access_point,
/*is_default_promo_account=*/true);
}
void EnableSyncFromMultiAccountPromo(Browser* browser,
const AccountInfo& account,
signin_metrics::AccessPoint access_point,
bool is_default_promo_account) {
......
......@@ -47,9 +47,18 @@ void ShowSigninErrorLearnMorePage(Profile* profile);
// then it presents the Chrome sign-in page with |account.emil| prefilled.
// * If token service has a valid refresh token for |account|, then it
// enables sync for |account|.
void EnableSyncFromSingleAccountPromo(Browser* browser,
const AccountInfo& account,
signin_metrics::AccessPoint access_point);
// This function is used to enable sync for a given account. It has the same
// behavior as |EnableSyncFromSingleAccountPromo()| except that it also logs
// some additional information if the action is started from a promo that
// supports selecting the account that may be used for sync.
//
// |is_default_promo_account| is true if |account| corresponds to the default
// account in the promo. It is ignored if |account| is empty.
void EnableSyncFromPromo(Browser* browser,
void EnableSyncFromMultiAccountPromo(Browser* browser,
const AccountInfo& account,
signin_metrics::AccessPoint access_point,
bool is_default_promo_account);
......
......@@ -353,8 +353,8 @@ void SaveCardBubbleControllerImpl::OnSyncPromoAccepted(
DCHECK(current_bubble_type_ == BubbleType::SIGN_IN_PROMO ||
current_bubble_type_ == BubbleType::MANAGE_CARDS);
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
signin_ui_util::EnableSyncFromPromo(browser, account, access_point,
/*is_default_promo_account=*/true);
signin_ui_util::EnableSyncFromSingleAccountPromo(browser, account,
access_point);
}
void SaveCardBubbleControllerImpl::OnSaveButton(
......
......@@ -28,10 +28,9 @@ BookmarkBubbleSignInDelegate::~BookmarkBubbleSignInDelegate() {
void BookmarkBubbleSignInDelegate::OnEnableSync(const AccountInfo& account) {
EnsureBrowser();
signin_ui_util::EnableSyncFromPromo(
signin_ui_util::EnableSyncFromSingleAccountPromo(
browser_, account,
signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE,
/*is_default_promo_account=*/true);
signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE);
// TODO(msarda): Close the bookmarks bubble once the enable sync flow has
// started.
......
......@@ -625,10 +625,9 @@ void ManagePasswordsUIController::NavigateToPasswordCheckup(
void ManagePasswordsUIController::EnableSync(const AccountInfo& account) {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
signin_ui_util::EnableSyncFromPromo(
signin_ui_util::EnableSyncFromSingleAccountPromo(
browser, account,
signin_metrics::AccessPoint::ACCESS_POINT_PASSWORD_BUBBLE,
/*is_default_promo_account=*/true);
signin_metrics::AccessPoint::ACCESS_POINT_PASSWORD_BUBBLE);
}
void ManagePasswordsUIController::OnDialogHidden() {
......
......@@ -254,10 +254,9 @@ void ExtensionInstalledBubbleView::Init() {
}
void ExtensionInstalledBubbleView::OnEnableSync(const AccountInfo& account) {
signin_ui_util::EnableSyncFromPromo(
signin_ui_util::EnableSyncFromSingleAccountPromo(
browser_, account,
signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE,
/*is_default_promo_account=*/true);
signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE);
GetWidget()->Close();
}
......
......@@ -361,10 +361,9 @@ void ProfileMenuView::OnSigninAccountButtonClicked(AccountInfo account) {
if (!perform_menu_actions())
return;
Hide();
signin_ui_util::EnableSyncFromPromo(
signin_ui_util::EnableSyncFromSingleAccountPromo(
browser(), account,
signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN,
true /* is_default_promo_account */);
signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
}
#if !defined(OS_CHROMEOS)
......
......@@ -515,7 +515,7 @@ void PeopleHandler::HandleStartSyncingWithEmail(const base::ListValue* args) {
->FindExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress(
email->GetString());
signin_ui_util::EnableSyncFromPromo(
signin_ui_util::EnableSyncFromMultiAccountPromo(
browser,
maybe_account.has_value() ? maybe_account.value() : AccountInfo(),
signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment