Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1741)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java

Issue 2790183002: Add UMA for the content suggestions settings (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java
index aa07ccc7da530071aff67eeecc81bd42fe6f0e01..4b2acd8c4472b684a7250d082cf8e315f2821f36 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/ContentSuggestionsPreferences.java
@@ -12,10 +12,12 @@
import android.view.MenuInflater;
import android.view.MenuItem;
+import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge;
import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.suggestions.ContentSuggestionsUma;
/**
* Settings fragment that allows the user to configure content suggestions.
@@ -26,6 +28,7 @@
private static final String PREF_CAVEATS = "suggestions_caveats";
private static final String PREF_LEARN_MORE = "suggestions_learn_more";
+ private boolean mWasEnabledAtCreation;
private boolean mIsEnabled;
// Preferences, modified as the state of the screen changes.
@@ -42,9 +45,9 @@ public void onCreate(Bundle savedInstanceState) {
setHasOptionsMenu(true);
finishSwitchInitialisation();
- boolean isEnabled = SnippetsBridge.isRemoteSuggestionsServiceEnabled();
- mIsEnabled = !isEnabled; // Opposite so that we trigger side effects below.
- updatePreferences(isEnabled);
+ mWasEnabledAtCreation = SnippetsBridge.isRemoteSuggestionsServiceEnabled();
+ mIsEnabled = !mWasEnabledAtCreation; // Opposite so that we trigger side effects below.
+ updatePreferences(mWasEnabledAtCreation);
}
@Override
@@ -67,6 +70,21 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ int statusChange;
+ if (mWasEnabledAtCreation) {
+ statusChange = mIsEnabled ? ContentSuggestionsUma.PREFERENCE_TOGGLE_ON_TO_ON
+ : ContentSuggestionsUma.PREFERENCE_TOGGLE_ON_TO_OFF;
+ } else {
+ statusChange = mIsEnabled ? ContentSuggestionsUma.PREFERENCE_TOGGLE_OFF_TO_ON
+ : ContentSuggestionsUma.PREFERENCE_TOGGLE_OFF_TO_OFF;
+ }
+ ContentSuggestionsUma.remoteSuggestionsPreferencesUIAction(statusChange);
+ }
+
/**
* Switches preference screens depending on whether the remote suggestions are enabled/disabled.
* @param isEnabled Indicates whether the remote suggestions are enabled.
@@ -88,10 +106,12 @@ public void updatePreferences(boolean isEnabled) {
private void setNotificationsPrefState(boolean visible) {
if (visible) {
+ RecordUserAction.record("ContentSuggestions.RemoteSuggestionsPreferenceOn");
if (findPreference(PREF_NOTIFICATIONS_SWITCH) != null) return;
getPreferenceScreen().addPreference(mNotificationsSwitch);
mNotificationsSwitch.setChecked(true); // TODO(dgn): initialise properly.
} else {
+ RecordUserAction.record("ContentSuggestions.RemoteSuggestionsPreferenceOff");
getPreferenceScreen().removePreference(mNotificationsSwitch);
}
}

Powered by Google App Engine
This is Rietveld 408576698