Commit 5bef0726 authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Convert feedback to use consent aware identity API

SplitSettingsSync will allow the user to opt-out of browser sync.
However, IdentityAccessor::GetPrimaryAccountInfo() defaults to
ConsentLevel::kSync, so it returns an empty struct if the user has not
consented to the browser sync feature.

Feedback isn't tied to browser sync. It has its own consent text in
the feedback dialog.

Switch to using the "unconsented" primary account. On Chrome OS this
account always exists for the logged-in user account, whether or not
the user consented to browser sync.

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

Bug: 1042400, 1046746
Test: Send feedback, report shows up in dashboard
Change-Id: I3f515046994dbb13e826b4c0d62e765ac7025857
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053128Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741204}
parent 7ecd1065
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/ui/simple_message_box.h" #include "chrome/browser/ui/simple_message_box.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/feedback/system_logs/system_logs_fetcher.h" #include "components/feedback/system_logs/system_logs_fetcher.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 "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -239,8 +240,12 @@ std::string ChromeFeedbackPrivateDelegate::GetSignedInUserEmail( ...@@ -239,8 +240,12 @@ std::string ChromeFeedbackPrivateDelegate::GetSignedInUserEmail(
content::BrowserContext* context) const { content::BrowserContext* context) const {
auto* identity_manager = IdentityManagerFactory::GetForProfile( auto* identity_manager = IdentityManagerFactory::GetForProfile(
Profile::FromBrowserContext(context)); Profile::FromBrowserContext(context));
return identity_manager ? identity_manager->GetPrimaryAccountInfo().email if (!identity_manager)
: std::string(); return std::string();
// Browser sync consent is not required to use feedback.
return identity_manager
->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired)
.email;
} }
void ChromeFeedbackPrivateDelegate::NotifyFeedbackDelayed() const { void ChromeFeedbackPrivateDelegate::NotifyFeedbackDelayed() const {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "components/feedback/feedback_report.h" #include "components/feedback/feedback_report.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 "components/signin/public/identity_manager/primary_account_access_token_fetcher.h" #include "components/signin/public/identity_manager/primary_account_access_token_fetcher.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -75,14 +76,18 @@ void FeedbackUploaderChrome::StartDispatchingReport() { ...@@ -75,14 +76,18 @@ void FeedbackUploaderChrome::StartDispatchingReport() {
signin::IdentityManager* identity_manager = signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile); IdentityManagerFactory::GetForProfile(profile);
if (identity_manager && identity_manager->HasPrimaryAccount()) { // Sync consent is not required to send feedback because the feedback dialog
// has its own privacy notice.
if (identity_manager &&
identity_manager->HasPrimaryAccount(signin::ConsentLevel::kNotRequired)) {
identity::ScopeSet scopes; identity::ScopeSet scopes;
scopes.insert("https://www.googleapis.com/auth/supportcontent"); scopes.insert("https://www.googleapis.com/auth/supportcontent");
token_fetcher_ = std::make_unique<signin::PrimaryAccountAccessTokenFetcher>( token_fetcher_ = std::make_unique<signin::PrimaryAccountAccessTokenFetcher>(
"feedback_uploader_chrome", identity_manager, scopes, "feedback_uploader_chrome", identity_manager, scopes,
base::BindOnce(&FeedbackUploaderChrome::AccessTokenAvailable, base::BindOnce(&FeedbackUploaderChrome::AccessTokenAvailable,
base::Unretained(this)), base::Unretained(this)),
signin::PrimaryAccountAccessTokenFetcher::Mode::kImmediate); signin::PrimaryAccountAccessTokenFetcher::Mode::kImmediate,
signin::ConsentLevel::kNotRequired);
return; return;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "extensions/browser/api/feedback_private/feedback_private_api.h" #include "extensions/browser/api/feedback_private/feedback_private_api.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -29,6 +30,17 @@ namespace chrome { ...@@ -29,6 +30,17 @@ namespace chrome {
namespace { namespace {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Returns whether the user has an internal Google account (e.g. @google.com).
bool IsGoogleInternalAccount(Profile* profile) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
if (!identity_manager) // Non-GAIA account, e.g. guest mode.
return false;
// Browser sync consent is not required to use feedback.
CoreAccountInfo account_info = identity_manager->GetPrimaryAccountInfo(
signin::ConsentLevel::kNotRequired);
return gaia::IsGoogleInternalAccountEmail(account_info.email);
}
// Returns if the feedback page is considered to be triggered from user // Returns if the feedback page is considered to be triggered from user
// interaction. // interaction.
bool IsFromUserInteraction(FeedbackSource source) { bool IsFromUserInteraction(FeedbackSource source) {
...@@ -94,10 +106,7 @@ void ShowFeedbackPage(const GURL& page_url, ...@@ -94,10 +106,7 @@ void ShowFeedbackPage(const GURL& page_url,
bool include_bluetooth_logs = false; bool include_bluetooth_logs = false;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile); if (IsGoogleInternalAccount(profile)) {
if (identity_manager &&
gaia::IsGoogleInternalAccountEmail(
identity_manager->GetPrimaryAccountInfo().email)) {
flow = feedback_private::FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL; flow = feedback_private::FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL;
include_bluetooth_logs = IsFromUserInteraction(source); include_bluetooth_logs = IsFromUserInteraction(source);
} }
......
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