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 "webkit/glue/webpreferences.h" | 5 #include "webkit/glue/webpreferences.h" |
6 | 6 |
7 #include <unicode/uchar.h> | 7 #include <unicode/uchar.h> |
8 #include <unicode/uscript.h> | |
8 | 9 |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
19 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
20 | 21 |
21 using WebKit::WebNetworkStateNotifier; | 22 using WebKit::WebNetworkStateNotifier; |
22 using WebKit::WebRuntimeFeatures; | 23 using WebKit::WebRuntimeFeatures; |
23 using WebKit::WebSettings; | 24 using WebKit::WebSettings; |
24 using WebKit::WebString; | 25 using WebKit::WebString; |
25 using WebKit::WebURL; | 26 using WebKit::WebURL; |
26 using WebKit::WebView; | 27 using WebKit::WebView; |
27 | 28 |
29 namespace { | |
30 const char* kCommonScript = uscript_getShortName(USCRIPT_COMMON); | |
tony
2012/05/09 17:11:15
This one is correct :)
| |
31 } | |
32 | |
28 WebPreferences::WebPreferences() | 33 WebPreferences::WebPreferences() |
29 : standard_font_family(ASCIIToUTF16("Times New Roman")), | 34 : default_font_size(16), |
30 fixed_font_family(ASCIIToUTF16("Courier New")), | |
31 serif_font_family(ASCIIToUTF16("Times New Roman")), | |
32 sans_serif_font_family(ASCIIToUTF16("Arial")), | |
33 cursive_font_family(ASCIIToUTF16("Script")), | |
34 fantasy_font_family(), // Not sure what to use on Windows. | |
35 default_font_size(16), | |
36 default_fixed_font_size(13), | 35 default_fixed_font_size(13), |
37 minimum_font_size(0), | 36 minimum_font_size(0), |
38 minimum_logical_font_size(6), | 37 minimum_logical_font_size(6), |
39 default_device_scale_factor(1), | 38 default_device_scale_factor(1), |
40 default_encoding("ISO-8859-1"), | 39 default_encoding("ISO-8859-1"), |
41 javascript_enabled(true), | 40 javascript_enabled(true), |
42 web_security_enabled(true), | 41 web_security_enabled(true), |
43 javascript_can_open_windows_automatically(true), | 42 javascript_can_open_windows_automatically(true), |
44 loads_images_automatically(true), | 43 loads_images_automatically(true), |
45 images_enabled(true), | 44 images_enabled(true), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 allow_displaying_insecure_content(true), | 97 allow_displaying_insecure_content(true), |
99 allow_running_insecure_content(false), | 98 allow_running_insecure_content(false), |
100 password_echo_enabled(false), | 99 password_echo_enabled(false), |
101 should_print_backgrounds(false), | 100 should_print_backgrounds(false), |
102 enable_scroll_animator(false), | 101 enable_scroll_animator(false), |
103 hixie76_websocket_protocol_enabled(false), | 102 hixie76_websocket_protocol_enabled(false), |
104 visual_word_movement_enabled(false), | 103 visual_word_movement_enabled(false), |
105 per_tile_painting_enabled(false), | 104 per_tile_painting_enabled(false), |
106 css_regions_enabled(false), | 105 css_regions_enabled(false), |
107 css_shaders_enabled(false) { | 106 css_shaders_enabled(false) { |
107 standard_font_family_map[kCommonScript] = | |
108 ASCIIToUTF16("Times New Roman"); | |
109 fixed_font_family_map[kCommonScript] = | |
110 ASCIIToUTF16("Courier New"); | |
111 serif_font_family_map[kCommonScript] = | |
112 ASCIIToUTF16("Times New Roman"); | |
113 sans_serif_font_family_map[kCommonScript] = | |
114 ASCIIToUTF16("Arial"); | |
115 cursive_font_family_map[kCommonScript] = | |
116 ASCIIToUTF16("Script"); | |
117 fantasy_font_family_map[kCommonScript] = | |
118 ASCIIToUTF16("Impact"); | |
108 } | 119 } |
109 | 120 |
110 WebPreferences::~WebPreferences() { | 121 WebPreferences::~WebPreferences() { |
111 } | 122 } |
112 | 123 |
113 namespace { | 124 namespace { |
114 | 125 |
115 void setStandardFontFamilyWrapper(WebSettings* settings, | 126 void setStandardFontFamilyWrapper(WebSettings* settings, |
116 const string16& font, | 127 const string16& font, |
117 UScriptCode script) { | 128 UScriptCode script) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); | 170 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
160 if (script >= 0 && script < USCRIPT_CODE_LIMIT) | 171 if (script >= 0 && script < USCRIPT_CODE_LIMIT) |
161 (*setter)(settings, it->second, (UScriptCode) script); | 172 (*setter)(settings, it->second, (UScriptCode) script); |
162 } | 173 } |
163 } | 174 } |
164 | 175 |
165 } // namespace | 176 } // namespace |
166 | 177 |
167 void WebPreferences::Apply(WebView* web_view) const { | 178 void WebPreferences::Apply(WebView* web_view) const { |
168 WebSettings* settings = web_view->settings(); | 179 WebSettings* settings = web_view->settings(); |
169 settings->setStandardFontFamily(standard_font_family); | |
170 settings->setFixedFontFamily(fixed_font_family); | |
171 settings->setSerifFontFamily(serif_font_family); | |
172 settings->setSansSerifFontFamily(sans_serif_font_family); | |
173 settings->setCursiveFontFamily(cursive_font_family); | |
174 settings->setFantasyFontFamily(fantasy_font_family); | |
175 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, | 180 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, |
176 settings); | 181 settings); |
177 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); | 182 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); |
178 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); | 183 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); |
179 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, | 184 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, |
180 settings); | 185 settings); |
181 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, | 186 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, |
182 settings); | 187 settings); |
183 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, | 188 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, |
184 settings); | 189 settings); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 settings->setVisualWordMovementEnabled(visual_word_movement_enabled); | 350 settings->setVisualWordMovementEnabled(visual_word_movement_enabled); |
346 | 351 |
347 // Enable per-tile painting if requested on the command line. | 352 // Enable per-tile painting if requested on the command line. |
348 settings->setPerTilePaintingEnabled(per_tile_painting_enabled); | 353 settings->setPerTilePaintingEnabled(per_tile_painting_enabled); |
349 | 354 |
350 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled); | 355 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled); |
351 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled); | 356 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled); |
352 | 357 |
353 WebNetworkStateNotifier::setOnLine(is_online); | 358 WebNetworkStateNotifier::setOnLine(is_online); |
354 } | 359 } |
OLD | NEW |