Chromium Code Reviews| 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/renderer_preferences_util.h" | 5 #include "chrome/browser/renderer_preferences_util.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 | |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/strings/string_util.h" | |
| 8 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 11 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 12 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/renderer_preferences.h" | 17 #include "content/public/common/renderer_preferences.h" |
| 14 #include "content/public/common/webrtc_ip_handling_policy.h" | 18 #include "content/public/common/webrtc_ip_handling_policy.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
| 16 | 20 |
| 17 #if defined(OS_LINUX) || defined(OS_ANDROID) | 21 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 18 #include "ui/gfx/font_render_params.h" | 22 #include "ui/gfx/font_render_params.h" |
| 19 #endif | 23 #endif |
| 20 | 24 |
| 21 #if defined(TOOLKIT_VIEWS) | 25 #if defined(TOOLKIT_VIEWS) |
| 22 #include "ui/views/controls/textfield/textfield.h" | 26 #include "ui/views/controls/textfield/textfield.h" |
| 23 #endif | 27 #endif |
| 24 | 28 |
| 25 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) | 29 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/themes/theme_service.h" | 30 #include "chrome/browser/themes/theme_service.h" |
| 27 #include "chrome/browser/themes/theme_service_factory.h" | 31 #include "chrome/browser/themes/theme_service_factory.h" |
| 28 #include "ui/views/linux_ui/linux_ui.h" | 32 #include "ui/views/linux_ui/linux_ui.h" |
| 29 #endif | 33 #endif |
| 30 | 34 |
| 35 namespace { | |
| 36 | |
| 37 // Parses a string |range| with a port range in the form "<min>-<max>". | |
|
Guido Urdaneta
2016/07/06 08:56:55
This code is largely duplicated from remoting/prot
tommi (sloooow) - chröme
2016/07/06 10:46:42
I don't think it's a huge deal. The TODO below is
| |
| 38 // If |range| is not in the correct format or contains an invalid range, zero | |
| 39 // is written to |min_port| and |max_port|. | |
| 40 // TODO(guidou): Consider replacing with remoting/protocol/port_range.cc | |
| 41 void ParsePortRange(const std::string& range, | |
| 42 uint16_t* min_port, | |
| 43 uint16_t* max_port) { | |
| 44 *min_port = 0; | |
| 45 *max_port = 0; | |
| 46 | |
| 47 if (range.empty()) | |
| 48 return; | |
| 49 | |
| 50 size_t separator_index = range.find('-'); | |
| 51 if (separator_index == std::string::npos) | |
| 52 return; | |
| 53 | |
| 54 base::StringPiece min_port_string = base::TrimWhitespaceASCII( | |
| 55 range.substr(0, separator_index), base::TRIM_ALL); | |
| 56 base::StringPiece max_port_string = base::TrimWhitespaceASCII( | |
| 57 range.substr(separator_index + 1), base::TRIM_ALL); | |
| 58 unsigned min_port_uint, max_port_uint; | |
| 59 if (!base::StringToUint(min_port_string, &min_port_uint) || | |
| 60 !base::StringToUint(max_port_string, &max_port_uint)) { | |
| 61 return; | |
| 62 } | |
| 63 if (min_port == 0 || min_port_uint > max_port_uint || | |
| 64 max_port_uint > UINT16_MAX) | |
|
tommi (sloooow) - chröme
2016/07/06 10:46:43
{}
(could run git cl format)
Guido Urdaneta
2016/07/07 09:27:55
Done.
| |
| 65 return; | |
| 66 | |
| 67 *min_port = static_cast<uint16_t>(min_port_uint); | |
| 68 *max_port = static_cast<uint16_t>(max_port_uint); | |
| 69 } | |
| 70 | |
| 71 } // namespace | |
| 72 | |
| 31 namespace renderer_preferences_util { | 73 namespace renderer_preferences_util { |
| 32 | 74 |
| 33 void UpdateFromSystemSettings(content::RendererPreferences* prefs, | 75 void UpdateFromSystemSettings(content::RendererPreferences* prefs, |
| 34 Profile* profile, | 76 Profile* profile, |
| 35 content::WebContents* web_contents) { | 77 content::WebContents* web_contents) { |
| 36 const PrefService* pref_service = profile->GetPrefs(); | 78 const PrefService* pref_service = profile->GetPrefs(); |
| 37 prefs->accept_languages = pref_service->GetString(prefs::kAcceptLanguages); | 79 prefs->accept_languages = pref_service->GetString(prefs::kAcceptLanguages); |
| 38 prefs->enable_referrers = pref_service->GetBoolean(prefs::kEnableReferrers); | 80 prefs->enable_referrers = pref_service->GetBoolean(prefs::kEnableReferrers); |
| 39 prefs->enable_do_not_track = | 81 prefs->enable_do_not_track = |
| 40 pref_service->GetBoolean(prefs::kEnableDoNotTrack); | 82 pref_service->GetBoolean(prefs::kEnableDoNotTrack); |
| 41 #if defined(ENABLE_WEBRTC) | 83 #if defined(ENABLE_WEBRTC) |
| 42 prefs->webrtc_ip_handling_policy = std::string(); | 84 prefs->webrtc_ip_handling_policy = std::string(); |
| 43 // Handling the backward compatibility of previous boolean verions of policy | 85 // Handling the backward compatibility of previous boolean verions of policy |
| 44 // controls. | 86 // controls. |
| 45 if (!pref_service->HasPrefPath(prefs::kWebRTCIPHandlingPolicy)) { | 87 if (!pref_service->HasPrefPath(prefs::kWebRTCIPHandlingPolicy)) { |
| 46 if (!pref_service->GetBoolean(prefs::kWebRTCNonProxiedUdpEnabled)) { | 88 if (!pref_service->GetBoolean(prefs::kWebRTCNonProxiedUdpEnabled)) { |
| 47 prefs->webrtc_ip_handling_policy = | 89 prefs->webrtc_ip_handling_policy = |
| 48 content::kWebRTCIPHandlingDisableNonProxiedUdp; | 90 content::kWebRTCIPHandlingDisableNonProxiedUdp; |
| 49 } else if (!pref_service->GetBoolean(prefs::kWebRTCMultipleRoutesEnabled)) { | 91 } else if (!pref_service->GetBoolean(prefs::kWebRTCMultipleRoutesEnabled)) { |
| 50 prefs->webrtc_ip_handling_policy = | 92 prefs->webrtc_ip_handling_policy = |
| 51 content::kWebRTCIPHandlingDefaultPublicInterfaceOnly; | 93 content::kWebRTCIPHandlingDefaultPublicInterfaceOnly; |
| 52 } | 94 } |
| 53 } | 95 } |
| 54 if (prefs->webrtc_ip_handling_policy.empty()) { | 96 if (prefs->webrtc_ip_handling_policy.empty()) { |
| 55 prefs->webrtc_ip_handling_policy = | 97 prefs->webrtc_ip_handling_policy = |
| 56 pref_service->GetString(prefs::kWebRTCIPHandlingPolicy); | 98 pref_service->GetString(prefs::kWebRTCIPHandlingPolicy); |
| 57 } | 99 } |
| 100 std::string webrtc_udp_port_range = | |
| 101 pref_service->GetString(prefs::kWebRTCUDPPortRange); | |
| 102 ParsePortRange(webrtc_udp_port_range, &prefs->webrtc_udp_min_port, | |
| 103 &prefs->webrtc_udp_max_port); | |
| 58 #endif | 104 #endif |
| 59 | 105 |
| 60 #if defined(USE_DEFAULT_RENDER_THEME) | 106 #if defined(USE_DEFAULT_RENDER_THEME) |
| 61 prefs->focus_ring_color = SkColorSetRGB(0x4D, 0x90, 0xFE); | 107 prefs->focus_ring_color = SkColorSetRGB(0x4D, 0x90, 0xFE); |
| 62 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
| 63 // This color is 0x544d90fe modulated with 0xffffff. | 109 // This color is 0x544d90fe modulated with 0xffffff. |
| 64 prefs->active_selection_bg_color = SkColorSetRGB(0xCB, 0xE4, 0xFA); | 110 prefs->active_selection_bg_color = SkColorSetRGB(0xCB, 0xE4, 0xFA); |
| 65 prefs->active_selection_fg_color = SK_ColorBLACK; | 111 prefs->active_selection_fg_color = SK_ColorBLACK; |
| 66 prefs->inactive_selection_bg_color = SkColorSetRGB(0xEA, 0xEA, 0xEA); | 112 prefs->inactive_selection_bg_color = SkColorSetRGB(0xEA, 0xEA, 0xEA); |
| 67 prefs->inactive_selection_fg_color = SK_ColorBLACK; | 113 prefs->inactive_selection_fg_color = SK_ColorBLACK; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 prefs->subpixel_rendering = params.subpixel_rendering; | 151 prefs->subpixel_rendering = params.subpixel_rendering; |
| 106 #endif | 152 #endif |
| 107 | 153 |
| 108 #if !defined(OS_MACOSX) | 154 #if !defined(OS_MACOSX) |
| 109 prefs->plugin_fullscreen_allowed = | 155 prefs->plugin_fullscreen_allowed = |
| 110 pref_service->GetBoolean(prefs::kFullscreenAllowed); | 156 pref_service->GetBoolean(prefs::kFullscreenAllowed); |
| 111 #endif | 157 #endif |
| 112 } | 158 } |
| 113 | 159 |
| 114 } // namespace renderer_preferences_util | 160 } // namespace renderer_preferences_util |
| OLD | NEW |