Commit 6ada5346 authored by Markus Heintz's avatar Markus Heintz Committed by Commit Bot

[unity] Record Unified consent when the feature is enabled.

Bug: 850161
Change-Id: I1fdb08aa752c5297e59245065830955447e01cf1
Reviewed-on: https://chromium-review.googlesource.com/1127163
Commit-Queue: Markus Heintz <markusheintz@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575598}
parent 4c7b65f6
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h" #include "chrome/browser/ui/signin_view_controller_delegate.h"
...@@ -31,11 +32,13 @@ const int kProfileImageSize = 128; ...@@ -31,11 +32,13 @@ const int kProfileImageSize = 128;
SyncConfirmationHandler::SyncConfirmationHandler( SyncConfirmationHandler::SyncConfirmationHandler(
Browser* browser, Browser* browser,
const std::unordered_map<std::string, int>& string_to_grd_id_map) const std::unordered_map<std::string, int>& string_to_grd_id_map,
consent_auditor::Feature consent_feature)
: profile_(browser->profile()), : profile_(browser->profile()),
browser_(browser), browser_(browser),
did_user_explicitly_interact(false), did_user_explicitly_interact(false),
string_to_grd_id_map_(string_to_grd_id_map) { string_to_grd_id_map_(string_to_grd_id_map),
consent_feature_(consent_feature) {
DCHECK(profile_); DCHECK(profile_);
DCHECK(browser_); DCHECK(browser_);
BrowserList::AddObserver(this); BrowserList::AddObserver(this);
...@@ -119,8 +122,8 @@ void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) { ...@@ -119,8 +122,8 @@ void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) {
ConsentAuditorFactory::GetForProfile(profile_)->RecordGaiaConsent( ConsentAuditorFactory::GetForProfile(profile_)->RecordGaiaConsent(
SigninManagerFactory::GetForProfile(profile_) SigninManagerFactory::GetForProfile(profile_)
->GetAuthenticatedAccountId(), ->GetAuthenticatedAccountId(),
consent_auditor::Feature::CHROME_SYNC, consent_text_ids, consent_feature_, consent_text_ids, consent_confirmation_id,
consent_confirmation_id, consent_auditor::ConsentStatus::GIVEN); consent_auditor::ConsentStatus::GIVEN);
} }
void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h" #include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "components/consent_auditor/consent_auditor.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "content/public/browser/web_ui_message_handler.h" #include "content/public/browser/web_ui_message_handler.h"
...@@ -27,7 +28,8 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler, ...@@ -27,7 +28,8 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler,
// mapped to their GRD IDs. // mapped to their GRD IDs.
explicit SyncConfirmationHandler( explicit SyncConfirmationHandler(
Browser* browser, Browser* browser,
const std::unordered_map<std::string, int>& string_to_grd_id_map); const std::unordered_map<std::string, int>& string_to_grd_id_map,
consent_auditor::Feature consent_feature);
~SyncConfirmationHandler() override; ~SyncConfirmationHandler() override;
// content::WebUIMessageHandler: // content::WebUIMessageHandler:
...@@ -93,6 +95,9 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler, ...@@ -93,6 +95,9 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler,
// and their respective GRD IDs. // and their respective GRD IDs.
std::unordered_map<std::string, int> string_to_grd_id_map_; std::unordered_map<std::string, int> string_to_grd_id_map_;
// Contains the features to use when the user consent decision is recorded.
consent_auditor::Feature consent_feature_;
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandler); DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandler);
}; };
......
...@@ -50,7 +50,9 @@ class TestingSyncConfirmationHandler : public SyncConfirmationHandler { ...@@ -50,7 +50,9 @@ class TestingSyncConfirmationHandler : public SyncConfirmationHandler {
Browser* browser, Browser* browser,
content::WebUI* web_ui, content::WebUI* web_ui,
std::unordered_map<std::string, int> string_to_grd_id_map) std::unordered_map<std::string, int> string_to_grd_id_map)
: SyncConfirmationHandler(browser, string_to_grd_id_map) { : SyncConfirmationHandler(browser,
string_to_grd_id_map,
consent_auditor::Feature::CHROME_SYNC) {
set_web_ui(web_ui); set_web_ui(web_ui);
} }
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
: SigninWebDialogUI(web_ui) { : SigninWebDialogUI(web_ui),
consent_feature_(consent_auditor::Feature::CHROME_SYNC) {
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
bool is_sync_allowed = profile->IsSyncAllowed(); bool is_sync_allowed = profile->IsSyncAllowed();
bool is_unified_consent_enabled = IsUnifiedConsentEnabled(profile); bool is_unified_consent_enabled = IsUnifiedConsentEnabled(profile);
...@@ -108,6 +109,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) ...@@ -108,6 +109,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
title_ids = IDS_SYNC_CONFIRMATION_UNITY_TITLE; title_ids = IDS_SYNC_CONFIRMATION_UNITY_TITLE;
confirm_button_ids = IDS_SYNC_CONFIRMATION_DICE_CONFIRM_BUTTON_LABEL; confirm_button_ids = IDS_SYNC_CONFIRMATION_DICE_CONFIRM_BUTTON_LABEL;
undo_button_ids = IDS_CANCEL; undo_button_ids = IDS_CANCEL;
consent_feature_ = consent_auditor::Feature::CHROME_UNIFIED_CONSENT;
} else { } else {
source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS); source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS);
...@@ -133,6 +135,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) ...@@ -133,6 +135,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
: IDS_SYNC_CONFIRMATION_TITLE; : IDS_SYNC_CONFIRMATION_TITLE;
confirm_button_ids = IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL; confirm_button_ids = IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL;
undo_button_ids = IDS_SYNC_CONFIRMATION_UNDO_BUTTON_LABEL; undo_button_ids = IDS_SYNC_CONFIRMATION_UNDO_BUTTON_LABEL;
consent_feature_ = consent_auditor::Feature::CHROME_SYNC;
if (!is_sync_allowed) { if (!is_sync_allowed) {
title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE; title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE;
confirm_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL; confirm_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL;
...@@ -160,7 +163,7 @@ SyncConfirmationUI::~SyncConfirmationUI() {} ...@@ -160,7 +163,7 @@ SyncConfirmationUI::~SyncConfirmationUI() {}
void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) { void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) {
web_ui()->AddMessageHandler(std::make_unique<SyncConfirmationHandler>( web_ui()->AddMessageHandler(std::make_unique<SyncConfirmationHandler>(
browser, js_localized_string_to_ids_map_)); browser, js_localized_string_to_ids_map_, consent_feature_));
} }
void SyncConfirmationUI::AddStringResource(content::WebUIDataSource* source, void SyncConfirmationUI::AddStringResource(content::WebUIDataSource* source,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/webui/signin/signin_web_dialog_ui.h" #include "chrome/browser/ui/webui/signin/signin_web_dialog_ui.h"
#include "components/consent_auditor/consent_auditor.h"
namespace content { namespace content {
class WebUIDataSource; class WebUIDataSource;
...@@ -43,6 +44,8 @@ class SyncConfirmationUI : public SigninWebDialogUI { ...@@ -43,6 +44,8 @@ class SyncConfirmationUI : public SigninWebDialogUI {
std::unordered_map<std::string, int> js_localized_string_to_ids_map_; std::unordered_map<std::string, int> js_localized_string_to_ids_map_;
consent_auditor::Feature consent_feature_;
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationUI); DISALLOW_COPY_AND_ASSIGN(SyncConfirmationUI);
}; };
......
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