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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java

Issue 2756463004: [Cleanup] Remove the ability to disable Crash Reporting from the command line. (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 unified diff | Download patch
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.preferences.privacy; 5 package org.chromium.chrome.browser.preferences.privacy;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.SharedPreferences; 8 import android.content.SharedPreferences;
9 import android.net.ConnectivityManager; 9 import android.net.ConnectivityManager;
10 import android.net.NetworkInfo; 10 import android.net.NetworkInfo;
(...skipping 25 matching lines...) Expand all
36 private static final String PREF_PHYSICAL_WEB = "physical_web"; 36 private static final String PREF_PHYSICAL_WEB = "physical_web";
37 private static final int PHYSICAL_WEB_OFF = 0; 37 private static final int PHYSICAL_WEB_OFF = 0;
38 private static final int PHYSICAL_WEB_ON = 1; 38 private static final int PHYSICAL_WEB_ON = 1;
39 private static final int PHYSICAL_WEB_ONBOARDING = 2; 39 private static final int PHYSICAL_WEB_ONBOARDING = 2;
40 40
41 private static PrivacyPreferencesManager sInstance; 41 private static PrivacyPreferencesManager sInstance;
42 42
43 private final Context mContext; 43 private final Context mContext;
44 private final SharedPreferences mSharedPreferences; 44 private final SharedPreferences mSharedPreferences;
45 45
46 private boolean mCrashUploadingDisabledByCommandLine;
47
48 @VisibleForTesting 46 @VisibleForTesting
49 PrivacyPreferencesManager(Context context) { 47 PrivacyPreferencesManager(Context context) {
50 mContext = context; 48 mContext = context;
51 mSharedPreferences = ContextUtils.getAppSharedPreferences(); 49 mSharedPreferences = ContextUtils.getAppSharedPreferences();
52 50
53 // We default the command line flag to disable uploads unless altered on deferred startup
54 // to prevent unwanted uploads at startup. If the command line flag to e nable uploading is
55 // turned on, the other conditions (e.g. user/network preferences) for w hen to upload apply.
56 // This currently applies to only crash reporting and is ignored for met rics reporting.
57 mCrashUploadingDisabledByCommandLine = true;
58 migrateUsageAndCrashPreferences(); 51 migrateUsageAndCrashPreferences();
59 } 52 }
60 53
61 public static PrivacyPreferencesManager getInstance() { 54 public static PrivacyPreferencesManager getInstance() {
62 if (sInstance == null) { 55 if (sInstance == null) {
63 sInstance = new PrivacyPreferencesManager(ContextUtils.getApplicatio nContext()); 56 sInstance = new PrivacyPreferencesManager(ContextUtils.getApplicatio nContext());
64 } 57 }
65 return sInstance; 58 return sInstance;
66 } 59 }
67 60
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 * Checks whether uploading of crash dumps is permitted for the available ne twork(s). 271 * Checks whether uploading of crash dumps is permitted for the available ne twork(s).
279 * 272 *
280 * @return whether uploading crash dumps is permitted. 273 * @return whether uploading crash dumps is permitted.
281 */ 274 */
282 @Override 275 @Override
283 public boolean isNetworkAvailableForCrashUploads() { 276 public boolean isNetworkAvailableForCrashUploads() {
284 return isNetworkAvailable() && isWiFiOrEthernetNetwork(); 277 return isNetworkAvailable() && isWiFiOrEthernetNetwork();
285 } 278 }
286 279
287 /** 280 /**
288 * Checks whether uploading of crash dumps is permitted, based on the corres ponding command line
289 * flag only.
290 * TODO(jchinlee): this is not quite a boolean. Depending on other refactori ng, change to enum.
291 *
292 * @return whether uploading of crash dumps is enabled or disabled by a comm and line flag.
293 */
294 @Override
295 public boolean isCrashUploadDisabledByCommandLine() {
296 return mCrashUploadingDisabledByCommandLine;
297 }
298
299 /**
300 * Checks whether uploading of usage metrics is currently permitted. 281 * Checks whether uploading of usage metrics is currently permitted.
301 * 282 *
302 * Note that this function intentionally does not check |mCrashUploadingDisa bledByCommandLine|.
303 * See http://crbug.com/602703 for more details.
304 *
305 * @return whether uploading usage metrics is currently permitted. 283 * @return whether uploading usage metrics is currently permitted.
306 */ 284 */
307 @Override 285 @Override
308 public boolean isMetricsUploadPermitted() { 286 public boolean isMetricsUploadPermitted() {
309 return isNetworkAvailable() 287 return isNetworkAvailable()
310 && (isUsageAndCrashReportingPermittedByUser() || isUploadEnabled ForTests()); 288 && (isUsageAndCrashReportingPermittedByUser() || isUploadEnabled ForTests());
311 } 289 }
312 290
313 /** 291 /**
314 * Checks whether uploading of usage metrics and crash dumps is currently pe rmitted, based on 292 * Checks whether uploading of usage metrics and crash dumps is currently pe rmitted, based on
(...skipping 12 matching lines...) Expand all
327 * test devices to avoid UI manipulation. 305 * test devices to avoid UI manipulation.
328 * 306 *
329 * @return whether uploading should be enabled if at all possible. 307 * @return whether uploading should be enabled if at all possible.
330 */ 308 */
331 @Override 309 @Override
332 public boolean isUploadEnabledForTests() { 310 public boolean isUploadEnabledForTests() {
333 return CommandLine.getInstance().hasSwitch(ChromeSwitches.FORCE_CRASH_DU MP_UPLOAD); 311 return CommandLine.getInstance().hasSwitch(ChromeSwitches.FORCE_CRASH_DU MP_UPLOAD);
334 } 312 }
335 313
336 /** 314 /**
337 * Provides a way to remove disabling crash uploading entirely.
338 * Enable crash uploading based on user's preference when an overriding flag does not exist in
339 * commandline.
340 * Used to differentiate from tests that trigger crashes intentionally, so t hese crashes are not
341 * uploaded.
342 */
343 public void enablePotentialCrashUploading() {
344 mCrashUploadingDisabledByCommandLine = false;
345 }
346
347 /**
348 * Sets the Physical Web preference, which enables background scanning for b luetooth beacons 315 * Sets the Physical Web preference, which enables background scanning for b luetooth beacons
349 * and displays a notification when beacons are found. 316 * and displays a notification when beacons are found.
350 * 317 *
351 * @param enabled A boolean indicating whether to notify on nearby beacons. 318 * @param enabled A boolean indicating whether to notify on nearby beacons.
352 */ 319 */
353 public void setPhysicalWebEnabled(boolean enabled) { 320 public void setPhysicalWebEnabled(boolean enabled) {
354 int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF; 321 int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF;
355 boolean isOnboarding = isPhysicalWebOnboarding(); 322 boolean isOnboarding = isPhysicalWebOnboarding();
356 mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply(); 323 mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply();
357 if (enabled) { 324 if (enabled) {
(...skipping 18 matching lines...) Expand all
376 /** 343 /**
377 * Check whether Physical Web is configured to notify on nearby beacons. 344 * Check whether Physical Web is configured to notify on nearby beacons.
378 * 345 *
379 * @return boolean {@code true} if the feature is enabled. 346 * @return boolean {@code true} if the feature is enabled.
380 */ 347 */
381 public boolean isPhysicalWebEnabled() { 348 public boolean isPhysicalWebEnabled() {
382 int state = mSharedPreferences.getInt(PREF_PHYSICAL_WEB, PHYSICAL_WEB_ON BOARDING); 349 int state = mSharedPreferences.getInt(PREF_PHYSICAL_WEB, PHYSICAL_WEB_ON BOARDING);
383 return (state == PHYSICAL_WEB_ON); 350 return (state == PHYSICAL_WEB_ON);
384 } 351 }
385 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698