OLD | NEW |
---|---|
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 <limits> | |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "ash/autoclick/autoclick_controller.h" | 10 #include "ash/autoclick/autoclick_controller.h" |
10 #include "ash/common/accessibility_types.h" | 11 #include "ash/common/accessibility_types.h" |
11 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
12 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/i18n/time_formatting.h" | 16 #include "base/i18n/time_formatting.h" |
16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
24 #include "chrome/browser/chromeos/drive/file_system_util.h" | 25 #include "chrome/browser/chromeos/drive/file_system_util.h" |
25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" | 26 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" |
26 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 27 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
28 #include "chrome/browser/chromeos/net/network_throttling_observer.h" | |
27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" | 29 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
28 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
29 #include "chrome/browser/chromeos/system/input_device_settings.h" | 31 #include "chrome/browser/chromeos/system/input_device_settings.h" |
30 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" | 32 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
31 #include "chrome/browser/download/download_prefs.h" | 33 #include "chrome/browser/download/download_prefs.h" |
32 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 34 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
33 #include "chrome/common/chrome_features.h" | 35 #include "chrome/common/chrome_features.h" |
34 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
35 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
36 #include "chromeos/system/statistics_provider.h" | 38 #include "chromeos/system/statistics_provider.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 DCHECK(g_browser_process); | 117 DCHECK(g_browser_process); |
116 PrefService* local_state = g_browser_process->local_state(); | 118 PrefService* local_state = g_browser_process->local_state(); |
117 DCHECK(local_state); | 119 DCHECK(local_state); |
118 hardware_keyboard_id = | 120 hardware_keyboard_id = |
119 local_state->GetString(prefs::kHardwareKeyboardLayout); | 121 local_state->GetString(prefs::kHardwareKeyboardLayout); |
120 } else { | 122 } else { |
121 hardware_keyboard_id = "xkb:us::eng"; // only for testing. | 123 hardware_keyboard_id = "xkb:us::eng"; // only for testing. |
122 } | 124 } |
123 | 125 |
124 registry->RegisterBooleanPref(prefs::kPerformanceTracingEnabled, false); | 126 registry->RegisterBooleanPref(prefs::kPerformanceTracingEnabled, false); |
125 | 127 registry->RegisterDictionaryPref(prefs::kNetworkThrottlingEnabled); |
Andrew T Wilson (Slow)
2016/10/21 13:27:30
Agreed with Mattias that I don't understand why we
| |
126 registry->RegisterBooleanPref( | 128 registry->RegisterBooleanPref( |
127 prefs::kTapToClickEnabled, | 129 prefs::kTapToClickEnabled, |
128 true, | 130 true, |
129 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | 131 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
130 registry->RegisterBooleanPref( | 132 registry->RegisterBooleanPref( |
131 prefs::kTapDraggingEnabled, | 133 prefs::kTapDraggingEnabled, |
132 false, | 134 false, |
133 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | 135 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
134 registry->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerClick, false); | 136 registry->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerClick, false); |
135 // This preference can only be set to true by policy or command_line flag | 137 // This preference can only be set to true by policy or command_line flag |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 390 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
389 xkb_auto_repeat_interval_pref_.Init( | 391 xkb_auto_repeat_interval_pref_.Init( |
390 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 392 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
391 | 393 |
392 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, | 394 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, |
393 callback); | 395 callback); |
394 | 396 |
395 pref_change_registrar_.Init(prefs); | 397 pref_change_registrar_.Init(prefs); |
396 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); | 398 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
397 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); | 399 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); |
400 pref_change_registrar_.Add(prefs::kNetworkThrottlingEnabled, callback); | |
398 } | 401 } |
399 | 402 |
400 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 403 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
401 DCHECK(profile); | 404 DCHECK(profile); |
402 DCHECK(user); | 405 DCHECK(user); |
403 syncable_prefs::PrefServiceSyncable* prefs = | 406 syncable_prefs::PrefServiceSyncable* prefs = |
404 PrefServiceSyncableFromProfile(profile); | 407 PrefServiceSyncableFromProfile(profile); |
405 // This causes OnIsSyncingChanged to be called when the value of | 408 // This causes OnIsSyncingChanged to be called when the value of |
406 // PrefService::IsSyncing() changes. | 409 // PrefService::IsSyncing() changes. |
407 prefs->AddObserver(this); | 410 prefs->AddObserver(this); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 ->SetAutoRepeatEnabled(enabled); | 625 ->SetAutoRepeatEnabled(enabled); |
623 } | 626 } |
624 } | 627 } |
625 if (reason != REASON_PREF_CHANGED || | 628 if (reason != REASON_PREF_CHANGED || |
626 pref_name == prefs::kLanguageXkbAutoRepeatDelay || | 629 pref_name == prefs::kLanguageXkbAutoRepeatDelay || |
627 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { | 630 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { |
628 if (user_is_active) | 631 if (user_is_active) |
629 UpdateAutoRepeatRate(); | 632 UpdateAutoRepeatRate(); |
630 } | 633 } |
631 | 634 |
635 if (pref_name == prefs::kNetworkThrottlingEnabled && | |
636 reason == REASON_PREF_CHANGED) { | |
637 PrefService* prefs = g_browser_process->local_state(); | |
638 const base::DictionaryValue* throttling_policy = | |
639 prefs->GetDictionary(prefs::kNetworkThrottlingEnabled); | |
640 | |
641 if (!throttling_policy) { | |
Andrew T Wilson (Slow)
2016/10/21 13:27:30
empty clause?
| |
642 } else { | |
643 bool enabled; | |
644 uint32_t upload_rate, download_rate; | |
645 throttling_policy->GetBoolean("enabled", &enabled); | |
646 throttling_policy->GetInteger("upload_rate_kbits", | |
647 reinterpret_cast<int*>(&upload_rate)); | |
648 throttling_policy->GetInteger("download_rate_kbits", | |
649 reinterpret_cast<int*>(&download_rate)); | |
650 NetworkThrottlingObserver::Get()->OnPreferenceChanged( | |
Andrew T Wilson (Slow)
2016/10/21 13:27:30
This is kind of ugly - can you have NetworkThrottl
stevenjb
2016/10/21 19:41:20
+1. NetworkThrottlingObserver should be a proper p
| |
651 enabled, upload_rate, download_rate); | |
652 } | |
653 } | |
654 | |
632 if (reason == REASON_INITIALIZATION) | 655 if (reason == REASON_INITIALIZATION) |
633 SetInputMethodList(); | 656 SetInputMethodList(); |
634 | 657 |
635 if (pref_name == prefs::kLanguagePreloadEngines && | 658 if (pref_name == prefs::kLanguagePreloadEngines && |
636 reason == REASON_PREF_CHANGED) { | 659 reason == REASON_PREF_CHANGED) { |
637 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 660 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
638 language_prefs::kPreloadEnginesConfigName, | 661 language_prefs::kPreloadEnginesConfigName, |
639 preload_engines_.GetValue()); | 662 preload_engines_.GetValue()); |
640 } | 663 } |
641 | 664 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 touch_hud_projection_enabled_.SetValue(enabled); | 815 touch_hud_projection_enabled_.SetValue(enabled); |
793 } | 816 } |
794 | 817 |
795 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 818 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
796 if (active_user != user_) | 819 if (active_user != user_) |
797 return; | 820 return; |
798 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 821 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
799 } | 822 } |
800 | 823 |
801 } // namespace chromeos | 824 } // namespace chromeos |
OLD | NEW |