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 typedef void (*SetFontFamilyWrapper)( | |
| 132 WebKit::WebSettings*, const string16&, UScriptCode); | |
| 133 void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map, | |
| 134 SetFontFamilyWrapper setter, | |
| 135 WebSettings* settings) { | |
| 136 for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin(); | |
| 137 it != map.end(); ++it) { | |
| 138 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); | |
|
jungshik at Google
2011/08/15 23:12:42
Does it work with Hans and Hant? It looks like Ha
falken
2011/08/16 07:46:44
Strange, it seems like "Hans" and "Hant" are worki
| |
| 139 if (script >= 0 && script < USCRIPT_CODE_LIMIT) | |
| 140 (*setter)(settings, it->second, (UScriptCode) script); | |
| 141 } | |
| 142 } | |
| 143 | |
| 95 void WebPreferences::Apply(WebView* web_view) const { | 144 void WebPreferences::Apply(WebView* web_view) const { |
| 96 WebSettings* settings = web_view->settings(); | 145 WebSettings* settings = web_view->settings(); |
| 97 settings->setStandardFontFamily(standard_font_family); | 146 settings->setStandardFontFamily(standard_font_family); |
| 98 settings->setFixedFontFamily(fixed_font_family); | 147 settings->setFixedFontFamily(fixed_font_family); |
| 99 settings->setSerifFontFamily(serif_font_family); | 148 settings->setSerifFontFamily(serif_font_family); |
| 100 settings->setSansSerifFontFamily(sans_serif_font_family); | 149 settings->setSansSerifFontFamily(sans_serif_font_family); |
| 101 settings->setCursiveFontFamily(cursive_font_family); | 150 settings->setCursiveFontFamily(cursive_font_family); |
| 102 settings->setFantasyFontFamily(fantasy_font_family); | 151 settings->setFantasyFontFamily(fantasy_font_family); |
| 152 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, | |
| 153 settings); | |
| 154 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper,settings); | |
| 155 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); | |
| 156 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, | |
| 157 settings); | |
| 158 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, | |
| 159 settings); | |
| 160 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, | |
| 161 settings); | |
| 103 settings->setDefaultFontSize(default_font_size); | 162 settings->setDefaultFontSize(default_font_size); |
| 104 settings->setDefaultFixedFontSize(default_fixed_font_size); | 163 settings->setDefaultFixedFontSize(default_fixed_font_size); |
| 105 settings->setMinimumFontSize(minimum_font_size); | 164 settings->setMinimumFontSize(minimum_font_size); |
| 106 settings->setMinimumLogicalFontSize(minimum_logical_font_size); | 165 settings->setMinimumLogicalFontSize(minimum_logical_font_size); |
| 107 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); | 166 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); |
| 108 settings->setJavaScriptEnabled(javascript_enabled); | 167 settings->setJavaScriptEnabled(javascript_enabled); |
| 109 settings->setWebSecurityEnabled(web_security_enabled); | 168 settings->setWebSecurityEnabled(web_security_enabled); |
| 110 settings->setJavaScriptCanOpenWindowsAutomatically( | 169 settings->setJavaScriptCanOpenWindowsAutomatically( |
| 111 javascript_can_open_windows_automatically); | 170 javascript_can_open_windows_automatically); |
| 112 settings->setLoadsImagesAutomatically(loads_images_automatically); | 171 settings->setLoadsImagesAutomatically(loads_images_automatically); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 settings->setFullScreenEnabled(fullscreen_enabled); | 294 settings->setFullScreenEnabled(fullscreen_enabled); |
| 236 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content); | 295 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content); |
| 237 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content); | 296 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content); |
| 238 settings->setShouldPrintBackgrounds(should_print_backgrounds); | 297 settings->setShouldPrintBackgrounds(should_print_backgrounds); |
| 239 settings->setEnableScrollAnimator(enable_scroll_animator); | 298 settings->setEnableScrollAnimator(enable_scroll_animator); |
| 240 settings->setHixie76WebSocketProtocolEnabled( | 299 settings->setHixie76WebSocketProtocolEnabled( |
| 241 hixie76_websocket_protocol_enabled); | 300 hixie76_websocket_protocol_enabled); |
| 242 | 301 |
| 243 WebNetworkStateNotifier::setOnLine(is_online); | 302 WebNetworkStateNotifier::setOnLine(is_online); |
| 244 } | 303 } |
| OLD | NEW |