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

Unified Diff: chrome/browser/chromeos/preferences.cc

Issue 2364703002: Add network throttling as an enterprise policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add network bandwidth throttling as an enterprise policy Created 4 years, 2 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
Index: chrome/browser/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index ad25bcc182b6eb8f5bf616751e0ea2431b533417..d1c2a1145521da9cb7a8c9b9de0fe8d2cfc8f6ab 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/input_method/input_method_syncer.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
+#include "chrome/browser/chromeos/net/network_throttling_observer.h"
#include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
@@ -629,6 +630,30 @@ void Preferences::ApplyPreferences(ApplyReason reason,
UpdateAutoRepeatRate();
}
+ // TODO(kirtika): Shill handles the initialization part, just handle
+ // the case when preference changes
+ if (reason == REASON_INITIALIZATION ||
Mattias Nissler (ping if slow) 2016/10/20 07:28:40 If you want this code to trigger when the pref cha
+ pref_name == prefs::kNetworkThrottlingEnabled) {
+ PrefService* prefs = g_browser_process->local_state();
+ const base::DictionaryValue* throttling_policy =
+ prefs->GetDictionary(prefs::kNetworkThrottlingEnabled);
+ // TODO(kirtika): Add something like IsDictValid (see existing chrome code)
+ // here
+ if (!throttling_policy) {
+ LOG(ERROR) << "Couldn't get throttling policy";
+ } else {
+ bool enabled;
+ uint32_t upload_rate, download_rate;
+ throttling_policy->GetBoolean("enabled", &enabled);
+ throttling_policy->GetInteger("upload_rate_kbits",
+ reinterpret_cast<int*>(&upload_rate));
+ throttling_policy->GetInteger("download_rate_kbits",
+ reinterpret_cast<int*>(&download_rate));
+ }
+ // TODO(kirtika): Testing-only, till the actual policy is available
+ NetworkThrottlingObserver::Get()->OnPreferenceChanged(true, 3400, 3400);
+ }
+
if (reason == REASON_INITIALIZATION)
SetInputMethodList();

Powered by Google App Engine
This is Rietveld 408576698