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

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/preferences/ConnectionChangeReceiver.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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.preferences;
6
7 import android.content.BroadcastReceiver;
8 import android.content.Context;
9 import android.content.Intent;
10 import android.content.IntentFilter;
11 import android.net.ConnectivityManager;
12
13 import org.chromium.chrome.browser.precache.PrecacheLauncher;
14 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ;
15
16 /**
17 * When there is a change in the network connection,this will update the sharedp ref value whether
18 * to allow prefetch or not.
19 */
20 public class ConnectionChangeReceiver extends BroadcastReceiver {
21
22 private boolean mIsRegistered;
23
24 public void registerReceiver(Context context) {
25 mIsRegistered = true;
26 IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ ACTION);
27 context.registerReceiver(this, filter);
28 }
29
30 public void unregisterReceiver(Context context) {
31 mIsRegistered = false;
32 context.unregisterReceiver(this);
33 }
34
35 @Override
36 public void onReceive(Context context, Intent intent) {
37 // Only handle the action if we're currently registered. If we're not re gistered as a
38 // listener, then we might be paused and native may not be loaded which would crash.
39 if (mIsRegistered) {
40 PrecacheLauncher.updatePrecachingEnabled(
41 PrivacyPreferencesManager.getInstance(context),
42 context.getApplicationContext());
43 }
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698