Commit e913f61a authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Migrate //c/b/chromeos to consent aware identity API

Be explicit about whether or not browser sync consent is required
when looking up the IdentityManager primary account.

Updated:
* kiosk mode tests
* login / user session
* device local account tests
* plugin vm

See go/cros-primary-account and go/consent-aware-api-dd

Bug: 1042400, 1046746
Test: existing browser_tests
Change-Id: I0f272f7bbcc2a4b0378cdf0e3590491617fe62a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054275Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741217}
parent 0b470c09
...@@ -932,8 +932,8 @@ IN_PROC_BROWSER_TEST_F(KioskTest, NotSignedInWithGAIAAccount) { ...@@ -932,8 +932,8 @@ IN_PROC_BROWSER_TEST_F(KioskTest, NotSignedInWithGAIAAccount) {
Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
ASSERT_TRUE(app_profile); ASSERT_TRUE(app_profile);
EXPECT_FALSE( EXPECT_FALSE(IdentityManagerFactory::GetForProfile(app_profile)
IdentityManagerFactory::GetForProfile(app_profile)->HasPrimaryAccount()); ->HasPrimaryAccount(signin::ConsentLevel::kNotRequired));
} }
IN_PROC_BROWSER_TEST_F(KioskTest, PRE_LaunchAppNetworkDown) { IN_PROC_BROWSER_TEST_F(KioskTest, PRE_LaunchAppNetworkDown) {
...@@ -2290,8 +2290,8 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) { ...@@ -2290,8 +2290,8 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) {
// account. // account.
Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
ASSERT_TRUE(app_profile); ASSERT_TRUE(app_profile);
EXPECT_FALSE( EXPECT_FALSE(IdentityManagerFactory::GetForProfile(app_profile)
IdentityManagerFactory::GetForProfile(app_profile)->HasPrimaryAccount()); ->HasPrimaryAccount(signin::ConsentLevel::kNotRequired));
// Terminate the app. // Terminate the app.
window->GetBaseWindow()->Close(); window->GetBaseWindow()->Close();
......
...@@ -178,6 +178,8 @@ ...@@ -178,6 +178,8 @@
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
using signin::ConsentLevel;
namespace chromeos { namespace chromeos {
namespace { namespace {
...@@ -654,7 +656,7 @@ void UserSessionManager::RestoreAuthenticationSession(Profile* user_profile) { ...@@ -654,7 +656,7 @@ void UserSessionManager::RestoreAuthenticationSession(Profile* user_profile) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(user_profile); auto* identity_manager = IdentityManagerFactory::GetForProfile(user_profile);
const bool account_id_valid = const bool account_id_valid =
identity_manager && identity_manager &&
!identity_manager->GetPrimaryAccountId(signin::ConsentLevel::kNotRequired) !identity_manager->GetPrimaryAccountId(ConsentLevel::kNotRequired)
.empty(); .empty();
if (!account_id_valid) if (!account_id_valid)
LOG(ERROR) << "No account is associated with sign-in manager on restore."; LOG(ERROR) << "No account is associated with sign-in manager on restore.";
...@@ -966,7 +968,7 @@ void UserSessionManager::OnSessionRestoreStateChanged( ...@@ -966,7 +968,7 @@ void UserSessionManager::OnSessionRestoreStateChanged(
DCHECK( DCHECK(
!identity_manager->HasAccountWithRefreshTokenInPersistentErrorState( !identity_manager->HasAccountWithRefreshTokenInPersistentErrorState(
identity_manager identity_manager
->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired) ->GetPrimaryAccountInfo(ConsentLevel::kNotRequired)
.account_id)); .account_id));
} }
user_status = user_manager::User::OAUTH2_TOKEN_STATUS_VALID; user_status = user_manager::User::OAUTH2_TOKEN_STATUS_VALID;
...@@ -1424,24 +1426,24 @@ void UserSessionManager::InitProfilePreferences( ...@@ -1424,24 +1426,24 @@ void UserSessionManager::InitProfilePreferences(
DCHECK(account_info.has_value()); DCHECK(account_info.has_value());
if (features::IsSplitSettingsSyncEnabled()) { if (features::IsSplitSettingsSyncEnabled()) {
if (is_new_profile) { if (is_new_profile) {
if (!identity_manager->HasPrimaryAccount()) { if (!identity_manager->HasPrimaryAccount(ConsentLevel::kSync)) {
// Set the account without recording browser sync consent. // Set the account without recording browser sync consent.
identity_manager->GetPrimaryAccountMutator() identity_manager->GetPrimaryAccountMutator()
->SetUnconsentedPrimaryAccount(account_info->account_id); ->SetUnconsentedPrimaryAccount(account_info->account_id);
} }
} }
CHECK(identity_manager->HasUnconsentedPrimaryAccount()); CHECK(identity_manager->HasUnconsentedPrimaryAccount());
CHECK_EQ(identity_manager CHECK_EQ(
->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired) identity_manager->GetPrimaryAccountInfo(ConsentLevel::kNotRequired)
.gaia, .gaia,
gaia_id); gaia_id);
} else { } else {
// Set a primary account here because the profile might have been // Set a primary account here because the profile might have been
// created with the feature SplitSettingsSync enabled. Then the // created with the feature SplitSettingsSync enabled. Then the
// profile might only have an unconsented primary account. // profile might only have an unconsented primary account.
identity_manager->GetPrimaryAccountMutator()->SetPrimaryAccount( identity_manager->GetPrimaryAccountMutator()->SetPrimaryAccount(
account_info->account_id); account_info->account_id);
CHECK(identity_manager->HasPrimaryAccount()); CHECK(identity_manager->HasPrimaryAccount(ConsentLevel::kSync));
CHECK_EQ(identity_manager->GetPrimaryAccountInfo().gaia, gaia_id); CHECK_EQ(identity_manager->GetPrimaryAccountInfo().gaia, gaia_id);
} }
} else { } else {
...@@ -1455,8 +1457,8 @@ void UserSessionManager::InitProfilePreferences( ...@@ -1455,8 +1457,8 @@ void UserSessionManager::InitProfilePreferences(
gaia_id, user_context.GetAccountId().GetUserEmail()); gaia_id, user_context.GetAccountId().GetUserEmail());
} }
CoreAccountId account_id = identity_manager->GetPrimaryAccountId( CoreAccountId account_id =
signin::ConsentLevel::kNotRequired); identity_manager->GetPrimaryAccountId(ConsentLevel::kNotRequired);
VLOG(1) << "Seed IdentityManager with the authenticated account info, " VLOG(1) << "Seed IdentityManager with the authenticated account info, "
<< "success=" << !account_id.empty(); << "success=" << !account_id.empty();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/download/public/background_service/download_metadata.h" #include "components/download/public/background_service/download_metadata.h"
#include "components/drive/service/drive_api_service.h" #include "components/drive/service/drive_api_service.h"
#include "components/drive/service/drive_service_interface.h" #include "components/drive/service/drive_service_interface.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/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -139,7 +140,8 @@ PluginVmDriveImageDownloadService::PluginVmDriveImageDownloadService( ...@@ -139,7 +140,8 @@ PluginVmDriveImageDownloadService::PluginVmDriveImageDownloadService(
identity_manager, url_loader_factory, blocking_task_runner.get(), identity_manager, url_loader_factory, blocking_task_runner.get(),
base_url, base_thumbnail_url, std::string{}, base_url, base_thumbnail_url, std::string{},
kPluginVmNetworkTrafficAnnotation); kPluginVmNetworkTrafficAnnotation);
drive_service_->Initialize(identity_manager->GetPrimaryAccountId()); drive_service_->Initialize(identity_manager->GetPrimaryAccountId(
signin::ConsentLevel::kNotRequired));
} }
void PluginVmDriveImageDownloadService::StartDownload( void PluginVmDriveImageDownloadService::StartDownload(
......
...@@ -86,4 +86,5 @@ class PluginVmDriveImageDownloadService { ...@@ -86,4 +86,5 @@ class PluginVmDriveImageDownloadService {
}; };
} // namespace plugin_vm } // namespace plugin_vm
#endif // CHROME_BROWSER_CHROMEOS_PLUGIN_VM_PLUGIN_VM_DRIVE_IMAGE_DOWNLOAD_SERVICE_H_ #endif // CHROME_BROWSER_CHROMEOS_PLUGIN_VM_PLUGIN_VM_DRIVE_IMAGE_DOWNLOAD_SERVICE_H_
...@@ -1158,7 +1158,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { ...@@ -1158,7 +1158,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) {
Profile* profile = GetProfileForTest(); Profile* profile = GetProfileForTest();
ASSERT_TRUE(profile); ASSERT_TRUE(profile);
EXPECT_FALSE( EXPECT_FALSE(
IdentityManagerFactory::GetForProfile(profile)->HasPrimaryAccount()); IdentityManagerFactory::GetForProfile(profile)->HasPrimaryAccount(
signin::ConsentLevel::kNotRequired));
} }
IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, FullscreenAllowed) { IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, FullscreenAllowed) {
......
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