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() {
* Opens the Google Activity Controls url in a new tab.
*/
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() {
chrome.metricsPrivate.recordUserAction(
'Signin_AccountSettings_GoogleActivityControlsClicked');
}
/** @override */
unifiedConsentToggleChanged(toggleChecked) {
chrome.send('UnifiedConsentToggleChanged', [toggleChecked]);
}
}
cr.addSingletonGetter(SyncBrowserProxyImpl);
......
......@@ -321,7 +321,10 @@ Polymer({
* @private
*/
onUnifiedConsentToggleChange_: function() {
if (!this.$$('#unifiedConsentToggle').checked) {
const checked = this.$$('#unifiedConsentToggle').checked;
this.browserProxy_.unifiedConsentToggleChanged(checked);
if (!checked) {
this.syncSectionOpened_ = !this.syncSectionDisabled_;
this.personalizeSectionOpened_ = true;
}
......
......@@ -51,6 +51,7 @@
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/base/sync_prefs.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/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
......@@ -243,6 +244,10 @@ void PeopleHandler::RegisterMessages() {
"SyncSetupManageOtherPeople",
base::BindRepeating(&PeopleHandler::HandleManageOtherPeople,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"UnifiedConsentToggleChanged",
base::BindRepeating(&PeopleHandler::OnUnifiedConsentToggleChanged,
base::Unretained(this)));
#if defined(OS_CHROMEOS)
web_ui()->RegisterMessageCallback(
"AttemptUserExit",
......@@ -786,6 +791,15 @@ void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) {
#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() {
// Stop a timer to handle timeout in waiting for checking network connection.
engine_start_timer_.reset();
......
......@@ -175,6 +175,7 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleSignout(const base::ListValue* args);
void HandleGetSyncStatus(const base::ListValue* args);
void HandleManageOtherPeople(const base::ListValue* args);
void OnUnifiedConsentToggleChanged(const base::ListValue* args);
#if !defined(OS_CHROMEOS)
// Displays the GAIA login form.
......
......@@ -271,6 +271,30 @@ cr.define('settings_people_page_sync_page', function() {
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() {
const ironCollapse = syncPage.$$('#sync-section');
const syncSectionToggle = syncPage.$$('#sync-section-toggle');
......
......@@ -17,6 +17,7 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
'signOut',
'startSignIn',
'startSyncingWithEmail',
'unifiedConsentToggleChanged',
]);
/** @private {number} */
......@@ -89,4 +90,9 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
this.methodCalled('setSyncEncryption', syncPrefs);
return Promise.resolve(this.encryptionResponse);
}
/** @override */
unifiedConsentToggleChanged(toggleChecked) {
this.methodCalled('unifiedConsentToggleChanged', toggleChecked);
}
}
......@@ -23,7 +23,8 @@ enum class UnifiedConsentRevokeReason : int {
kUserSignedOut = 0,
kServiceWasDisabled,
kCustomPassphrase,
kMaxValue = kCustomPassphrase
kUserDisabledSettingsToggle,
kMaxValue = kUserDisabledSettingsToggle
};
// Records histogram action for the unified consent bump.
......
......@@ -49164,6 +49164,7 @@ Full version information for the fingerprint enum values:
<int value="0" label="User signed out of Chrome"/>
<int value="1" label="Service was disabled"/>
<int value="2" label="Custom passphrase was detected"/>
<int value="3" label="User disabled Unity settings toggle"/>
</enum>
<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