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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/autoclick/autoclick_controller.h" 9 #include "ash/autoclick/autoclick_controller.h"
10 #include "ash/common/accessibility_types.h" 10 #include "ash/common/accessibility_types.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/display/display_manager.h" 12 #include "ash/display/display_manager.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/i18n/time_formatting.h" 15 #include "base/i18n/time_formatting.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/sys_info.h" 20 #include "base/sys_info.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
24 #include "chrome/browser/chromeos/drive/file_system_util.h" 24 #include "chrome/browser/chromeos/drive/file_system_util.h"
25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" 25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h"
26 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 26 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
27 #include "chrome/browser/chromeos/net/network_throttling_observer.h"
27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" 28 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
28 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 29 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
29 #include "chrome/browser/chromeos/system/input_device_settings.h" 30 #include "chrome/browser/chromeos/system/input_device_settings.h"
30 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" 31 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
31 #include "chrome/browser/download/download_prefs.h" 32 #include "chrome/browser/download/download_prefs.h"
32 #include "chrome/browser/prefs/pref_service_syncable_util.h" 33 #include "chrome/browser/prefs/pref_service_syncable_util.h"
33 #include "chrome/common/chrome_features.h" 34 #include "chrome/common/chrome_features.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "chromeos/chromeos_switches.h" 36 #include "chromeos/chromeos_switches.h"
36 #include "chromeos/system/statistics_provider.h" 37 #include "chromeos/system/statistics_provider.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 ->SetAutoRepeatEnabled(enabled); 623 ->SetAutoRepeatEnabled(enabled);
623 } 624 }
624 } 625 }
625 if (reason != REASON_PREF_CHANGED || 626 if (reason != REASON_PREF_CHANGED ||
626 pref_name == prefs::kLanguageXkbAutoRepeatDelay || 627 pref_name == prefs::kLanguageXkbAutoRepeatDelay ||
627 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { 628 pref_name == prefs::kLanguageXkbAutoRepeatInterval) {
628 if (user_is_active) 629 if (user_is_active)
629 UpdateAutoRepeatRate(); 630 UpdateAutoRepeatRate();
630 } 631 }
631 632
633 // TODO(kirtika): Shill handles the initialization part, just handle
634 // the case when preference changes
635 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
636 pref_name == prefs::kNetworkThrottlingEnabled) {
637 PrefService* prefs = g_browser_process->local_state();
638 const base::DictionaryValue* throttling_policy =
639 prefs->GetDictionary(prefs::kNetworkThrottlingEnabled);
640 // TODO(kirtika): Add something like IsDictValid (see existing chrome code)
641 // here
642 if (!throttling_policy) {
643 LOG(ERROR) << "Couldn't get throttling policy";
644 } else {
645 bool enabled;
646 uint32_t upload_rate, download_rate;
647 throttling_policy->GetBoolean("enabled", &enabled);
648 throttling_policy->GetInteger("upload_rate_kbits",
649 reinterpret_cast<int*>(&upload_rate));
650 throttling_policy->GetInteger("download_rate_kbits",
651 reinterpret_cast<int*>(&download_rate));
652 }
653 // TODO(kirtika): Testing-only, till the actual policy is available
654 NetworkThrottlingObserver::Get()->OnPreferenceChanged(true, 3400, 3400);
655 }
656
632 if (reason == REASON_INITIALIZATION) 657 if (reason == REASON_INITIALIZATION)
633 SetInputMethodList(); 658 SetInputMethodList();
634 659
635 if (pref_name == prefs::kLanguagePreloadEngines && 660 if (pref_name == prefs::kLanguagePreloadEngines &&
636 reason == REASON_PREF_CHANGED) { 661 reason == REASON_PREF_CHANGED) {
637 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, 662 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
638 language_prefs::kPreloadEnginesConfigName, 663 language_prefs::kPreloadEnginesConfigName,
639 preload_engines_.GetValue()); 664 preload_engines_.GetValue());
640 } 665 }
641 666
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 touch_hud_projection_enabled_.SetValue(enabled); 817 touch_hud_projection_enabled_.SetValue(enabled);
793 } 818 }
794 819
795 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 820 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
796 if (active_user != user_) 821 if (active_user != user_)
797 return; 822 return;
798 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 823 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
799 } 824 }
800 825
801 } // namespace chromeos 826 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698