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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/rlz/RevenueStats.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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_staging/src/org/chromium/chrome/browser/rlz/RevenueStats.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/rlz/RevenueStats.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/rlz/RevenueStats.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8e340ee818f9e0428b16604d48ada15bae31ff9
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/rlz/RevenueStats.java
@@ -0,0 +1,87 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.rlz;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+
+import org.chromium.base.ApplicationStatus;
+import org.chromium.base.JNINamespace;
+import org.chromium.chrome.browser.ChromeMobileApplication;
+import org.chromium.chrome.browser.Tab;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Utility class for managing revenue sharing information.
+ */
+@JNINamespace("chrome::android")
+public class RevenueStats {
+ private static final String PREF_RLZ_NOTIFIED = "rlz_first_search_notified";
+
+ // Use an AtomicReference since getInstance() can be called from multiple threads.
+ private static AtomicReference<RevenueStats> sInstance = new AtomicReference<RevenueStats>();
+
+ /**
+ * Returns the singleton instance of ExternalAuthUtils, creating it if needed.
+ */
+ public static RevenueStats getInstance() {
+ if (sInstance.get() == null) {
+ ChromeMobileApplication application =
+ (ChromeMobileApplication) ApplicationStatus.getApplicationContext();
+ sInstance.compareAndSet(null, application.createRevenueStatsInstance());
+ }
+ return sInstance.get();
+ }
+
+ /**
+ * Notifies tab creation event.
+ */
+ public void tabCreated(Tab chromeTab) {}
+
+ /**
+ * Retrieves the client ID string.
+ */
+ public String retrieveClientId() {
+ return null;
+ }
+
+ /**
+ * Returns whether the RLZ provider has been notified that the first search has occurred.
+ */
+ protected static boolean getRlzNotified(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
+ PREF_RLZ_NOTIFIED, false);
+ }
+
+ /**
+ * Stores whether the RLZ provider has been notified that the first search has occurred as
+ * shared preference.
+ */
+ protected static void setRlzNotified(Context context, boolean notified) {
+ SharedPreferences.Editor sharedPreferencesEditor =
+ PreferenceManager.getDefaultSharedPreferences(context).edit();
+ sharedPreferencesEditor.putBoolean(PREF_RLZ_NOTIFIED, notified);
+ sharedPreferencesEditor.apply();
+ }
+
+ /**
+ * Sets search client id.
+ */
+ protected static void setSearchClient(String client) {
+ nativeSetSearchClient(client);
+ }
+
+ /**
+ * Sets rlz value.
+ */
+ protected static void setRlzParameterValue(String rlz) {
+ nativeSetRlzParameterValue(rlz);
+ }
+
+ private static native void nativeSetSearchClient(String client);
+ private static native void nativeSetRlzParameterValue(String rlz);
+}

Powered by Google App Engine
This is Rietveld 408576698