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

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

Issue 2328803002: Run Physical Web background subscription (Closed)
Patch Set: Update commit message Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.content.SharedPreferences; 7 import android.content.SharedPreferences;
8 import android.os.Build; 8 import android.os.Build;
9 9
10 import org.chromium.base.ContextUtils; 10 import org.chromium.base.ContextUtils;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 && locationUtils.isSystemLocationSettingEnabled()) { 63 && locationUtils.isSystemLocationSettingEnabled()) {
64 new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE, new R unnable() { 64 new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE, new R unnable() {
65 @Override 65 @Override
66 public void run() { 66 public void run() {
67 // We need to clear the list of nearby URLs so that they can be repopulated by 67 // We need to clear the list of nearby URLs so that they can be repopulated by
68 // the new subscription, but we don't know whether we are al ready subscribed, so 68 // the new subscription, but we don't know whether we are al ready subscribed, so
69 // we need to pass a callback so that we can clear as soon a s we are 69 // we need to pass a callback so that we can clear as soon a s we are
70 // resubscribed. 70 // resubscribed.
71 UrlManager.getInstance().clearNearbyUrls(); 71 UrlManager.getInstance().clearNearbyUrls();
72 } 72 }
73 }); 73 }).run();
74 } 74 }
75 } 75 }
76 76
77 /** 77 /**
78 * Stop the Physical Web feature. 78 * Stop the Physical Web feature.
79 */ 79 */
80 public static void stopPhysicalWeb() { 80 public static void stopPhysicalWeb() {
81 new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE, new Run nable() { 81 new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE, new Run nable() {
82 @Override 82 @Override
83 public void run() { 83 public void run() {
84 // This isn't absolutely necessary, but it's nice to clean up al l our shared prefs. 84 // This isn't absolutely necessary, but it's nice to clean up al l our shared prefs.
85 UrlManager.getInstance().clearAllUrls(); 85 UrlManager.getInstance().clearAllUrls();
86 } 86 }
87 }); 87 }).run();
88 } 88 }
89 89
90 /** 90 /**
91 * Returns true if we should fire notifications regardless of the existence of other Physical 91 * Returns true if we should fire notifications regardless of the existence of other Physical
92 * Web clients. 92 * Web clients.
93 * This method is for use when the native library is not available. 93 * This method is for use when the native library is not available.
94 */ 94 */
95 public static boolean shouldIgnoreOtherClients() { 95 public static boolean shouldIgnoreOtherClients() {
96 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_IGNORE_OTH ER_CLIENTS, false); 96 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_IGNORE_OTH ER_CLIENTS, false);
97 } 97 }
(...skipping 30 matching lines...) Expand all
128 ContextUtils.getAppSharedPreferences().edit() 128 ContextUtils.getAppSharedPreferences().edit()
129 .putBoolean(PREF_IGNORE_OTHER_CLIENTS, ignoreOtherClients) 129 .putBoolean(PREF_IGNORE_OTHER_CLIENTS, ignoreOtherClients)
130 .apply(); 130 .apply();
131 startPhysicalWeb(); 131 startPhysicalWeb();
132 PhysicalWebUma.uploadDeferredMetrics(); 132 PhysicalWebUma.uploadDeferredMetrics();
133 } else { 133 } else {
134 stopPhysicalWeb(); 134 stopPhysicalWeb();
135 } 135 }
136 } 136 }
137 } 137 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698