Commit f7f31484 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Add revoke reason kUserDisabledSettingsToggle

When the user disables the unified consent toggle in settings,
a metric is recorded.
This metric is added to UnifiedConsent.RevokeReason.

Bug: 868892
Change-Id: Iff196b3428b130ea4b3d71a50c2b861f5da48966
Reviewed-on: https://chromium-review.googlesource.com/1240278Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593585}
parent d951a8b3
...@@ -215,6 +215,13 @@ cr.define('settings', function() { ...@@ -215,6 +215,13 @@ cr.define('settings', function() {
* Opens the Google Activity Controls url in a new tab. * Opens the Google Activity Controls url in a new tab.
*/ */
openActivityControlsUrl() {} openActivityControlsUrl() {}
/**
* Function to invoke when the unified consent toggle state changes, to
* notify the C++ layer.
* @param {boolean} toggleChecked
*/
unifiedConsentToggleChanged(toggleChecked) {}
} }
/** /**
...@@ -302,6 +309,11 @@ cr.define('settings', function() { ...@@ -302,6 +309,11 @@ cr.define('settings', function() {
chrome.metricsPrivate.recordUserAction( chrome.metricsPrivate.recordUserAction(
'Signin_AccountSettings_GoogleActivityControlsClicked'); 'Signin_AccountSettings_GoogleActivityControlsClicked');
} }
/** @override */
unifiedConsentToggleChanged(toggleChecked) {
chrome.send('UnifiedConsentToggleChanged', [toggleChecked]);
}
} }
cr.addSingletonGetter(SyncBrowserProxyImpl); cr.addSingletonGetter(SyncBrowserProxyImpl);
......
...@@ -321,7 +321,10 @@ Polymer({ ...@@ -321,7 +321,10 @@ Polymer({
* @private * @private
*/ */
onUnifiedConsentToggleChange_: function() { onUnifiedConsentToggleChange_: function() {
if (!this.$$('#unifiedConsentToggle').checked) { const checked = this.$$('#unifiedConsentToggle').checked;
this.browserProxy_.unifiedConsentToggleChanged(checked);
if (!checked) {
this.syncSectionOpened_ = !this.syncSectionDisabled_; this.syncSectionOpened_ = !this.syncSectionDisabled_;
this.personalizeSectionOpened_ = true; this.personalizeSectionOpened_ = true;
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "components/sync/base/passphrase_enums.h" #include "components/sync/base/passphrase_enums.h"
#include "components/sync/base/sync_prefs.h" #include "components/sync/base/sync_prefs.h"
#include "components/unified_consent/feature.h" #include "components/unified_consent/feature.h"
#include "components/unified_consent/unified_consent_metrics.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
...@@ -243,6 +244,10 @@ void PeopleHandler::RegisterMessages() { ...@@ -243,6 +244,10 @@ void PeopleHandler::RegisterMessages() {
"SyncSetupManageOtherPeople", "SyncSetupManageOtherPeople",
base::BindRepeating(&PeopleHandler::HandleManageOtherPeople, base::BindRepeating(&PeopleHandler::HandleManageOtherPeople,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"UnifiedConsentToggleChanged",
base::BindRepeating(&PeopleHandler::OnUnifiedConsentToggleChanged,
base::Unretained(this)));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"AttemptUserExit", "AttemptUserExit",
...@@ -786,6 +791,15 @@ void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { ...@@ -786,6 +791,15 @@ void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) {
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
} }
void PeopleHandler::OnUnifiedConsentToggleChanged(const base::ListValue* args) {
bool is_toggle_checked = args->GetList()[0].GetBool();
if (!is_toggle_checked) {
unified_consent::metrics::RecordUnifiedConsentRevoked(
unified_consent::metrics::UnifiedConsentRevokeReason::
kUserDisabledSettingsToggle);
}
}
void PeopleHandler::CloseSyncSetup() { void PeopleHandler::CloseSyncSetup() {
// Stop a timer to handle timeout in waiting for checking network connection. // Stop a timer to handle timeout in waiting for checking network connection.
engine_start_timer_.reset(); engine_start_timer_.reset();
......
...@@ -175,6 +175,7 @@ class PeopleHandler : public SettingsPageUIHandler, ...@@ -175,6 +175,7 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleSignout(const base::ListValue* args); void HandleSignout(const base::ListValue* args);
void HandleGetSyncStatus(const base::ListValue* args); void HandleGetSyncStatus(const base::ListValue* args);
void HandleManageOtherPeople(const base::ListValue* args); void HandleManageOtherPeople(const base::ListValue* args);
void OnUnifiedConsentToggleChanged(const base::ListValue* args);
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
// Displays the GAIA login form. // Displays the GAIA login form.
......
...@@ -271,6 +271,30 @@ cr.define('settings_people_page_sync_page', function() { ...@@ -271,6 +271,30 @@ cr.define('settings_people_page_sync_page', function() {
assertFalse(ironCollapse.hidden); assertFalse(ironCollapse.hidden);
}); });
test(
'UnifiedConsentToggleNotifiesHandler_UnifiedConsentEnabled',
function() {
const unifiedConsentToggle = syncPage.$$('#unifiedConsentToggle');
syncPage.syncStatus = {
signedIn: true,
disabled: false,
hasError: false,
statusAction: settings.StatusAction.NO_ACTION,
};
syncPage.unifiedConsentEnabled = true;
Polymer.dom.flush();
assertFalse(unifiedConsentToggle.hidden);
assertFalse(unifiedConsentToggle.checked);
unifiedConsentToggle.click();
return browserProxy.whenCalled('unifiedConsentToggleChanged')
.then(toggleChecked => {
assertTrue(toggleChecked);
});
});
test('SyncSectionLayout_UnifiedConsentEnabled_SignoutCollapse', function() { test('SyncSectionLayout_UnifiedConsentEnabled_SignoutCollapse', function() {
const ironCollapse = syncPage.$$('#sync-section'); const ironCollapse = syncPage.$$('#sync-section');
const syncSectionToggle = syncPage.$$('#sync-section-toggle'); const syncSectionToggle = syncPage.$$('#sync-section-toggle');
......
...@@ -17,6 +17,7 @@ class TestSyncBrowserProxy extends TestBrowserProxy { ...@@ -17,6 +17,7 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
'signOut', 'signOut',
'startSignIn', 'startSignIn',
'startSyncingWithEmail', 'startSyncingWithEmail',
'unifiedConsentToggleChanged',
]); ]);
/** @private {number} */ /** @private {number} */
...@@ -89,4 +90,9 @@ class TestSyncBrowserProxy extends TestBrowserProxy { ...@@ -89,4 +90,9 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
this.methodCalled('setSyncEncryption', syncPrefs); this.methodCalled('setSyncEncryption', syncPrefs);
return Promise.resolve(this.encryptionResponse); return Promise.resolve(this.encryptionResponse);
} }
/** @override */
unifiedConsentToggleChanged(toggleChecked) {
this.methodCalled('unifiedConsentToggleChanged', toggleChecked);
}
} }
...@@ -23,7 +23,8 @@ enum class UnifiedConsentRevokeReason : int { ...@@ -23,7 +23,8 @@ enum class UnifiedConsentRevokeReason : int {
kUserSignedOut = 0, kUserSignedOut = 0,
kServiceWasDisabled, kServiceWasDisabled,
kCustomPassphrase, kCustomPassphrase,
kMaxValue = kCustomPassphrase kUserDisabledSettingsToggle,
kMaxValue = kUserDisabledSettingsToggle
}; };
// Records histogram action for the unified consent bump. // Records histogram action for the unified consent bump.
......
...@@ -49164,6 +49164,7 @@ Full version information for the fingerprint enum values: ...@@ -49164,6 +49164,7 @@ Full version information for the fingerprint enum values:
<int value="0" label="User signed out of Chrome"/> <int value="0" label="User signed out of Chrome"/>
<int value="1" label="Service was disabled"/> <int value="1" label="Service was disabled"/>
<int value="2" label="Custom passphrase was detected"/> <int value="2" label="Custom passphrase was detected"/>
<int value="3" label="User disabled Unity settings toggle"/>
</enum> </enum>
<enum name="UnifiedConsentSyncAndGoogleServicesSettings"> <enum name="UnifiedConsentSyncAndGoogleServicesSettings">
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