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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java

Issue 1882333002: Simplify Physical Web hook in Chromium startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/DeferredStartupHandler.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
index 0ae107c5951519fa916c3040c093cdb50a91cfb2..67a74ed6a4ff96d361bbf7a21ce1c7de33f338b2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
@@ -55,17 +55,6 @@ public class PhysicalWeb {
}
/**
- * Evaluate whether the Physical Web should be enabled when the application starts.
- *
- * @param context An instance of android.content.Context
- * @return true if the Physical Web should be started at launch
- */
- public static boolean shouldStartOnLaunch(Context context) {
- return featureIsEnabled()
- && (isPhysicalWebPreferenceEnabled(context) || isOnboarding(context));
- }
-
- /**
* Start the Physical Web feature.
* At the moment, this only enables URL discovery over BLE.
* @param application An instance of {@link ChromeApplication}, used to get the
@@ -89,15 +78,6 @@ public class PhysicalWeb {
}
/**
- * Upload the collected UMA stats.
- * This method should be called only when the native library is loaded.
- * @param context A valid instance of Context.
- */
- public static void uploadDeferredMetrics(final Context context) {
- PhysicalWebUma.uploadDeferredMetrics(context);
- }
-
- /**
* Increments a value tracking how many times we've shown the Physical Web
* opt-in notification.
*
@@ -123,6 +103,22 @@ public class PhysicalWeb {
return sharedPreferences.getInt(PREF_PHYSICAL_WEB_NOTIFY_COUNT, 0);
}
+ /**
+ * Perform various Physical Web operations that should happen on startup.
+ * @param application An instance of {@link ChromeApplication}.
+ */
+ public static void onChromeStart(ChromeApplication application) {
Yaron 2016/04/14 01:35:55 I'd love to see this dependency on ChromeApplicati
cco3 2016/04/15 22:10:27 Some of these calls rely on ChromeApplication.crea
+ // The PhysicalWebUma calls in this method should be called only when the native library is
+ // loaded. This is always the case on chrome startup.
+ if (featureIsEnabled()
+ && (isPhysicalWebPreferenceEnabled(application) || isOnboarding(application))) {
+ startPhysicalWeb(application);
+ PhysicalWebUma.uploadDeferredMetrics(application);
+ } else {
+ stopPhysicalWeb(application);
+ }
+ }
+
private static void clearUrlsAsync(final Context context) {
Runnable task = new Runnable() {
@Override
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/DeferredStartupHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698