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,10 +199,18 @@ void ShowSigninErrorLearnMorePage(Profile* profile) { ...@@ -199,10 +199,18 @@ void ShowSigninErrorLearnMorePage(Profile* profile) {
Navigate(&params); Navigate(&params);
} }
void EnableSyncFromPromo(Browser* browser, void EnableSyncFromSingleAccountPromo(
const AccountInfo& account, Browser* browser,
signin_metrics::AccessPoint access_point, const AccountInfo& account,
bool is_default_promo_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) {
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
internal::EnableSyncFromPromo(browser, account, access_point, internal::EnableSyncFromPromo(browser, account, access_point,
is_default_promo_account, is_default_promo_account,
......
...@@ -47,12 +47,21 @@ void ShowSigninErrorLearnMorePage(Profile* profile); ...@@ -47,12 +47,21 @@ void ShowSigninErrorLearnMorePage(Profile* profile);
// then it presents the Chrome sign-in page with |account.emil| prefilled. // then it presents the Chrome sign-in page with |account.emil| prefilled.
// * If token service has a valid refresh token for |account|, then it // * If token service has a valid refresh token for |account|, then it
// enables sync for |account|. // 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 // |is_default_promo_account| is true if |account| corresponds to the default
// account in the promo. It is ignored if |account| is empty. // account in the promo. It is ignored if |account| is empty.
void EnableSyncFromPromo(Browser* browser, void EnableSyncFromMultiAccountPromo(Browser* browser,
const AccountInfo& account, const AccountInfo& account,
signin_metrics::AccessPoint access_point, signin_metrics::AccessPoint access_point,
bool is_default_promo_account); bool is_default_promo_account);
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
// Returns the list of all accounts that have a token. The unconsented primary // Returns the list of all accounts that have a token. The unconsented primary
......
...@@ -353,8 +353,8 @@ void SaveCardBubbleControllerImpl::OnSyncPromoAccepted( ...@@ -353,8 +353,8 @@ void SaveCardBubbleControllerImpl::OnSyncPromoAccepted(
DCHECK(current_bubble_type_ == BubbleType::SIGN_IN_PROMO || DCHECK(current_bubble_type_ == BubbleType::SIGN_IN_PROMO ||
current_bubble_type_ == BubbleType::MANAGE_CARDS); current_bubble_type_ == BubbleType::MANAGE_CARDS);
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
signin_ui_util::EnableSyncFromPromo(browser, account, access_point, signin_ui_util::EnableSyncFromSingleAccountPromo(browser, account,
/*is_default_promo_account=*/true); access_point);
} }
void SaveCardBubbleControllerImpl::OnSaveButton( void SaveCardBubbleControllerImpl::OnSaveButton(
......
...@@ -28,10 +28,9 @@ BookmarkBubbleSignInDelegate::~BookmarkBubbleSignInDelegate() { ...@@ -28,10 +28,9 @@ BookmarkBubbleSignInDelegate::~BookmarkBubbleSignInDelegate() {
void BookmarkBubbleSignInDelegate::OnEnableSync(const AccountInfo& account) { void BookmarkBubbleSignInDelegate::OnEnableSync(const AccountInfo& account) {
EnsureBrowser(); EnsureBrowser();
signin_ui_util::EnableSyncFromPromo( signin_ui_util::EnableSyncFromSingleAccountPromo(
browser_, account, browser_, account,
signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE, signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE);
/*is_default_promo_account=*/true);
// TODO(msarda): Close the bookmarks bubble once the enable sync flow has // TODO(msarda): Close the bookmarks bubble once the enable sync flow has
// started. // started.
......
...@@ -625,10 +625,9 @@ void ManagePasswordsUIController::NavigateToPasswordCheckup( ...@@ -625,10 +625,9 @@ void ManagePasswordsUIController::NavigateToPasswordCheckup(
void ManagePasswordsUIController::EnableSync(const AccountInfo& account) { void ManagePasswordsUIController::EnableSync(const AccountInfo& account) {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
signin_ui_util::EnableSyncFromPromo( signin_ui_util::EnableSyncFromSingleAccountPromo(
browser, account, browser, account,
signin_metrics::AccessPoint::ACCESS_POINT_PASSWORD_BUBBLE, signin_metrics::AccessPoint::ACCESS_POINT_PASSWORD_BUBBLE);
/*is_default_promo_account=*/true);
} }
void ManagePasswordsUIController::OnDialogHidden() { void ManagePasswordsUIController::OnDialogHidden() {
......
...@@ -254,10 +254,9 @@ void ExtensionInstalledBubbleView::Init() { ...@@ -254,10 +254,9 @@ void ExtensionInstalledBubbleView::Init() {
} }
void ExtensionInstalledBubbleView::OnEnableSync(const AccountInfo& account) { void ExtensionInstalledBubbleView::OnEnableSync(const AccountInfo& account) {
signin_ui_util::EnableSyncFromPromo( signin_ui_util::EnableSyncFromSingleAccountPromo(
browser_, account, browser_, account,
signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE, signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE);
/*is_default_promo_account=*/true);
GetWidget()->Close(); GetWidget()->Close();
} }
......
...@@ -361,10 +361,9 @@ void ProfileMenuView::OnSigninAccountButtonClicked(AccountInfo account) { ...@@ -361,10 +361,9 @@ void ProfileMenuView::OnSigninAccountButtonClicked(AccountInfo account) {
if (!perform_menu_actions()) if (!perform_menu_actions())
return; return;
Hide(); Hide();
signin_ui_util::EnableSyncFromPromo( signin_ui_util::EnableSyncFromSingleAccountPromo(
browser(), account, browser(), account,
signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN, signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
true /* is_default_promo_account */);
} }
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
......
...@@ -515,7 +515,7 @@ void PeopleHandler::HandleStartSyncingWithEmail(const base::ListValue* args) { ...@@ -515,7 +515,7 @@ void PeopleHandler::HandleStartSyncingWithEmail(const base::ListValue* args) {
->FindExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress( ->FindExtendedAccountInfoForAccountWithRefreshTokenByEmailAddress(
email->GetString()); email->GetString());
signin_ui_util::EnableSyncFromPromo( signin_ui_util::EnableSyncFromMultiAccountPromo(
browser, browser,
maybe_account.has_value() ? maybe_account.value() : AccountInfo(), maybe_account.has_value() ? maybe_account.value() : AccountInfo(),
signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS, 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