Commit 9843cc2b authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Identity: add ConsentLevel parameter to helper SignIn method in chrome_pages.

This is split from https://chromium-review.googlesource.com/c/chromium/src/+/2548699/
which needed to call the helper function but without sync.

Bug: None
Change-Id: Ife32574545aafd3d881f68c4d62ee664b3a5c432
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555802Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Auto-Submit: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830825}
parent 011a30c9
...@@ -247,7 +247,8 @@ void EnableSyncFromPromo( ...@@ -247,7 +247,8 @@ void EnableSyncFromPromo(
} }
if (account.IsEmpty()) { if (account.IsEmpty()) {
chrome::ShowBrowserSignin(browser, access_point); chrome::ShowBrowserSignin(browser, access_point,
signin::ConsentLevel::kSync);
return; return;
} }
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "chromeos/login/login_state/login_state.h" #include "chromeos/login/login_state/login_state.h"
#include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_node.h" #include "components/bookmarks/browser/bookmark_node.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
...@@ -479,7 +480,8 @@ GURL GetOSSettingsUrl(const std::string& sub_page) { ...@@ -479,7 +480,8 @@ GURL GetOSSettingsUrl(const std::string& sub_page) {
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
void ShowBrowserSignin(Browser* browser, void ShowBrowserSignin(Browser* browser,
signin_metrics::AccessPoint access_point) { signin_metrics::AccessPoint access_point,
signin::ConsentLevel consent_level) {
Profile* original_profile = browser->profile()->GetOriginalProfile(); Profile* original_profile = browser->profile()->GetOriginalProfile();
DCHECK(original_profile->GetPrefs()->GetBoolean(prefs::kSigninAllowed)); DCHECK(original_profile->GetPrefs()->GetBoolean(prefs::kSigninAllowed));
...@@ -490,11 +492,21 @@ void ShowBrowserSignin(Browser* browser, ...@@ -490,11 +492,21 @@ void ShowBrowserSignin(Browser* browser,
std::make_unique<ScopedTabbedBrowserDisplayer>(original_profile); std::make_unique<ScopedTabbedBrowserDisplayer>(original_profile);
browser = displayer->browser(); browser = displayer->browser();
profiles::BubbleViewMode bubble_view_mode = profiles::BubbleViewMode bubble_view_mode;
IdentityManagerFactory::GetForProfile(original_profile) if (IdentityManagerFactory::GetForProfile(original_profile)
->HasPrimaryAccount() ->HasPrimaryAccount()) {
? profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH bubble_view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
: profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN; } else {
switch (consent_level) {
case signin::ConsentLevel::kSync:
bubble_view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
break;
case signin::ConsentLevel::kNotRequired:
bubble_view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT;
break;
}
}
browser->signin_view_controller()->ShowSignin(bubble_view_mode, access_point); browser->signin_view_controller()->ShowSignin(bubble_view_mode, access_point);
} }
...@@ -506,7 +518,7 @@ void ShowBrowserSigninOrSettings(Browser* browser, ...@@ -506,7 +518,7 @@ void ShowBrowserSigninOrSettings(Browser* browser,
->HasPrimaryAccount()) ->HasPrimaryAccount())
ShowSettings(browser); ShowSettings(browser);
else else
ShowBrowserSignin(browser, access_point); ShowBrowserSignin(browser, access_point, signin::ConsentLevel::kSync);
} }
#endif #endif
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "chrome/browser/ui/webui/settings/chromeos/app_management/app_management_uma.h" #include "chrome/browser/ui/webui/settings/chromeos/app_management/app_management_uma.h"
#endif #endif
namespace signin {
enum class ConsentLevel;
} // namespace signin
class Browser; class Browser;
class Profile; class Profile;
...@@ -162,7 +166,8 @@ void ShowScanningApp(Profile* profile); ...@@ -162,7 +166,8 @@ void ShowScanningApp(Profile* profile);
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// Initiates signin in a new browser tab. // Initiates signin in a new browser tab.
void ShowBrowserSignin(Browser* browser, void ShowBrowserSignin(Browser* browser,
signin_metrics::AccessPoint access_point); signin_metrics::AccessPoint access_point,
signin::ConsentLevel consent_level);
// If the user is already signed in, shows the "Signin" portion of Settings, // If the user is already signed in, shows the "Signin" portion of Settings,
// otherwise initiates signin in a new browser tab. // otherwise initiates signin in a new browser tab.
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_metrics.h" #include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/base/signin_pref_names.h" #include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
...@@ -126,7 +127,7 @@ void AppLauncherLoginHandler::HandleShowSyncLoginUI( ...@@ -126,7 +127,7 @@ void AppLauncherLoginHandler::HandleShowSyncLoginUI(
web_contents->GetURL().spec() == chrome::kChromeUIAppsURL web_contents->GetURL().spec() == chrome::kChromeUIAppsURL
? signin_metrics::AccessPoint::ACCESS_POINT_APPS_PAGE_LINK ? signin_metrics::AccessPoint::ACCESS_POINT_APPS_PAGE_LINK
: signin_metrics::AccessPoint::ACCESS_POINT_NTP_LINK; : signin_metrics::AccessPoint::ACCESS_POINT_NTP_LINK;
chrome::ShowBrowserSignin(browser, access_point); chrome::ShowBrowserSignin(browser, access_point, signin::ConsentLevel::kSync);
RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
} }
#endif #endif
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h" #include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
...@@ -448,7 +449,7 @@ bool SignInWithUI(Browser* browser, ...@@ -448,7 +449,7 @@ bool SignInWithUI(Browser* browser,
signin_metrics::AccessPoint access_point = signin_metrics::AccessPoint access_point =
signin_metrics::AccessPoint::ACCESS_POINT_MENU; signin_metrics::AccessPoint::ACCESS_POINT_MENU;
chrome::ShowBrowserSignin(browser, access_point); chrome::ShowBrowserSignin(browser, access_point, signin::ConsentLevel::kSync);
content::WebContents* active_contents = content::WebContents* active_contents =
browser->tab_strip_model()->GetActiveWebContents(); browser->tab_strip_model()->GetActiveWebContents();
DCHECK(active_contents); DCHECK(active_contents);
......
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