Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/webpreferences.h" | 5 #include "webkit/glue/webpreferences.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 allow_displaying_insecure_content(true), | 85 allow_displaying_insecure_content(true), |
| 86 allow_running_insecure_content(false), | 86 allow_running_insecure_content(false), |
| 87 should_print_backgrounds(false), | 87 should_print_backgrounds(false), |
| 88 enable_scroll_animator(false), | 88 enable_scroll_animator(false), |
| 89 hixie76_websocket_protocol_enabled(false) { | 89 hixie76_websocket_protocol_enabled(false) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 WebPreferences::~WebPreferences() { | 92 WebPreferences::~WebPreferences() { |
| 93 } | 93 } |
| 94 | 94 |
| 95 void setStandardFontFamilyWrapper(WebSettings* settings, | |
| 96 const string16& font, | |
| 97 UScriptCode script) { | |
| 98 settings->setStandardFontFamily(font, script); | |
| 99 } | |
| 100 | |
| 101 void setFixedFontFamilyWrapper(WebSettings* settings, | |
| 102 const string16& font, | |
| 103 UScriptCode script) { | |
| 104 settings->setFixedFontFamily(font, script); | |
| 105 } | |
| 106 | |
| 107 void setSerifFontFamilyWrapper(WebSettings* settings, | |
| 108 const string16& font, | |
| 109 UScriptCode script) { | |
| 110 settings->setSerifFontFamily(font, script); | |
| 111 } | |
| 112 | |
| 113 void setSansSerifFontFamilyWrapper(WebSettings* settings, | |
| 114 const string16& font, | |
| 115 UScriptCode script) { | |
| 116 settings->setSansSerifFontFamily(font, script); | |
| 117 } | |
| 118 | |
| 119 void setCursiveFontFamilyWrapper(WebSettings* settings, | |
| 120 const string16& font, | |
| 121 UScriptCode script) { | |
| 122 settings->setCursiveFontFamily(font, script); | |
| 123 } | |
| 124 | |
| 125 void setFantasyFontFamilyWrapper(WebSettings* settings, | |
| 126 const string16& font, | |
| 127 UScriptCode script) { | |
| 128 settings->setFantasyFontFamily(font, script); | |
| 129 } | |
| 130 | |
| 131 void WebPreferences::ApplyFontsFromMap(const ScriptFontFamilyMap& map, | |
|
tony
2011/08/10 19:23:40
It looks like this could also be a local function
| |
| 132 SetFontFamilyWrapper setter, | |
| 133 WebSettings* settings) const { | |
| 134 for (ScriptFontFamilyMap::const_iterator it = map.begin(); | |
| 135 it != map.end(); ++it) { | |
| 136 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); | |
| 137 if (script >= 0 && script < USCRIPT_CODE_LIMIT) | |
| 138 (*setter)(settings, it->second, (UScriptCode) script); | |
| 139 } | |
| 140 } | |
| 141 | |
| 95 void WebPreferences::Apply(WebView* web_view) const { | 142 void WebPreferences::Apply(WebView* web_view) const { |
| 96 WebSettings* settings = web_view->settings(); | 143 WebSettings* settings = web_view->settings(); |
| 97 settings->setStandardFontFamily(standard_font_family); | 144 settings->setStandardFontFamily(standard_font_family); |
| 98 settings->setFixedFontFamily(fixed_font_family); | 145 settings->setFixedFontFamily(fixed_font_family); |
| 99 settings->setSerifFontFamily(serif_font_family); | 146 settings->setSerifFontFamily(serif_font_family); |
| 100 settings->setSansSerifFontFamily(sans_serif_font_family); | 147 settings->setSansSerifFontFamily(sans_serif_font_family); |
| 101 settings->setCursiveFontFamily(cursive_font_family); | 148 settings->setCursiveFontFamily(cursive_font_family); |
| 102 settings->setFantasyFontFamily(fantasy_font_family); | 149 settings->setFantasyFontFamily(fantasy_font_family); |
| 150 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, | |
| 151 settings); | |
| 152 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper,settings); | |
| 153 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); | |
| 154 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, | |
| 155 settings); | |
| 156 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, | |
| 157 settings); | |
| 158 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, | |
| 159 settings); | |
| 103 settings->setDefaultFontSize(default_font_size); | 160 settings->setDefaultFontSize(default_font_size); |
| 104 settings->setDefaultFixedFontSize(default_fixed_font_size); | 161 settings->setDefaultFixedFontSize(default_fixed_font_size); |
| 105 settings->setMinimumFontSize(minimum_font_size); | 162 settings->setMinimumFontSize(minimum_font_size); |
| 106 settings->setMinimumLogicalFontSize(minimum_logical_font_size); | 163 settings->setMinimumLogicalFontSize(minimum_logical_font_size); |
| 107 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); | 164 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); |
| 108 settings->setJavaScriptEnabled(javascript_enabled); | 165 settings->setJavaScriptEnabled(javascript_enabled); |
| 109 settings->setWebSecurityEnabled(web_security_enabled); | 166 settings->setWebSecurityEnabled(web_security_enabled); |
| 110 settings->setJavaScriptCanOpenWindowsAutomatically( | 167 settings->setJavaScriptCanOpenWindowsAutomatically( |
| 111 javascript_can_open_windows_automatically); | 168 javascript_can_open_windows_automatically); |
| 112 settings->setLoadsImagesAutomatically(loads_images_automatically); | 169 settings->setLoadsImagesAutomatically(loads_images_automatically); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 settings->setFullScreenEnabled(fullscreen_enabled); | 292 settings->setFullScreenEnabled(fullscreen_enabled); |
| 236 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content); | 293 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content); |
| 237 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content); | 294 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content); |
| 238 settings->setShouldPrintBackgrounds(should_print_backgrounds); | 295 settings->setShouldPrintBackgrounds(should_print_backgrounds); |
| 239 settings->setEnableScrollAnimator(enable_scroll_animator); | 296 settings->setEnableScrollAnimator(enable_scroll_animator); |
| 240 settings->setHixie76WebSocketProtocolEnabled( | 297 settings->setHixie76WebSocketProtocolEnabled( |
| 241 hixie76_websocket_protocol_enabled); | 298 hixie76_websocket_protocol_enabled); |
| 242 | 299 |
| 243 WebNetworkStateNotifier::setOnLine(is_online); | 300 WebNetworkStateNotifier::setOnLine(is_online); |
| 244 } | 301 } |
| OLD | NEW |