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

Side by Side Diff: chrome/browser/net/prediction_options.cc

Issue 421653006: Update "Predict network actions" UI setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 6 years, 4 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 | « chrome/browser/net/prediction_options.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/net/prediction_options.h" 5 #include "chrome/browser/net/prediction_options.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile_io_data.h" 9 #include "chrome/browser/profiles/profile_io_data.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 28 matching lines...) Expand all
39 namespace chrome_browser_net { 39 namespace chrome_browser_net {
40 40
41 void RegisterPredictionOptionsProfilePrefs( 41 void RegisterPredictionOptionsProfilePrefs(
42 user_prefs::PrefRegistrySyncable* registry) { 42 user_prefs::PrefRegistrySyncable* registry) {
43 registry->RegisterIntegerPref( 43 registry->RegisterIntegerPref(
44 prefs::kNetworkPredictionOptions, 44 prefs::kNetworkPredictionOptions,
45 chrome_browser_net::NETWORK_PREDICTION_UNSET, 45 chrome_browser_net::NETWORK_PREDICTION_UNSET,
46 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 46 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
47 } 47 }
48 48
49 void MigrateNetworkPredictionUserPrefs(PrefService* pref_service) {
50 // Nothing to do if the user or this migration code has already set the new
51 // preference.
52 if (pref_service->GetUserPrefValue(prefs::kNetworkPredictionOptions))
53 return;
54
55 // Nothing to do if the user has not set the old preference.
56 const base::Value* network_prediction_enabled =
57 pref_service->GetUserPrefValue(prefs::kNetworkPredictionEnabled);
58 if (!network_prediction_enabled)
59 return;
60
61 bool value = false;
62 if (network_prediction_enabled->GetAsBoolean(&value)) {
63 pref_service->SetInteger(
64 prefs::kNetworkPredictionOptions,
65 value ? chrome_browser_net::NETWORK_PREDICTION_WIFI_ONLY
66 : chrome_browser_net::NETWORK_PREDICTION_NEVER);
67 }
68 }
69
49 bool CanPredictNetworkActionsIO(ProfileIOData* profile_io_data) { 70 bool CanPredictNetworkActionsIO(ProfileIOData* profile_io_data) {
50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 71 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
51 DCHECK(profile_io_data); 72 DCHECK(profile_io_data);
52 73
53 return CanPredictNetworkActions( 74 return CanPredictNetworkActions(
54 profile_io_data->network_prediction_options()->GetValue(), 75 profile_io_data->network_prediction_options()->GetValue(),
55 profile_io_data->network_prediction_enabled()->GetValue()); 76 profile_io_data->network_prediction_enabled()->GetValue());
56 } 77 }
57 78
58 bool CanPredictNetworkActionsUI(PrefService* prefs) { 79 bool CanPredictNetworkActionsUI(PrefService* prefs) {
59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 80 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
60 DCHECK(prefs); 81 DCHECK(prefs);
61 return CanPredictNetworkActions( 82 return CanPredictNetworkActions(
62 prefs->GetInteger(prefs::kNetworkPredictionOptions), 83 prefs->GetInteger(prefs::kNetworkPredictionOptions),
63 prefs->GetBoolean(prefs::kNetworkPredictionEnabled)); 84 prefs->GetBoolean(prefs::kNetworkPredictionEnabled));
64 } 85 }
65 86
66 } // namespace chrome_browser_net 87 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/prediction_options.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698