OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/html_viewer/layout_test_blink_settings_impl.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "build/build_config.h" | |
10 #include "components/html_viewer/web_preferences.h" | |
11 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | |
12 | |
13 #if defined(OS_WIN) | |
14 #include "ui/gfx/win/dpi.h" | |
15 #endif | |
16 | |
17 namespace html_viewer { | |
18 | |
19 namespace { | |
20 | |
21 const char kEnableAccelerated2DCanvas[] = "enable-accelerated-2d-canvas"; | |
22 | |
23 void UpdateWebPreferencesForTest(WebPreferences* prefs, | |
24 bool accelerated_2d_canvas_enabled) { | |
25 prefs->allow_universal_access_from_file_urls = true; | |
26 prefs->dom_paste_enabled = true; | |
27 prefs->javascript_can_access_clipboard = true; | |
28 prefs->xslt_enabled = true; | |
29 prefs->xss_auditor_enabled = false; | |
30 #if defined(OS_MACOSX) | |
31 prefs->editing_behavior = EDITING_BEHAVIOR_MAC; | |
32 #else | |
33 prefs->editing_behavior = EDITING_BEHAVIOR_WIN; | |
34 #endif | |
35 prefs->application_cache_enabled = true; | |
36 prefs->tabs_to_links = false; | |
37 prefs->hyperlink_auditing_enabled = false; | |
38 prefs->allow_displaying_insecure_content = true; | |
39 prefs->allow_running_insecure_content = false; | |
40 prefs->disable_reading_from_canvas = false; | |
41 prefs->strict_mixed_content_checking = false; | |
42 prefs->strict_powerful_feature_restrictions = false; | |
43 prefs->webgl_errors_to_console_enabled = false; | |
44 base::string16 serif; | |
45 #if defined(OS_MACOSX) | |
46 prefs->cursive_font_family_map[kCommonScript] = | |
47 base::ASCIIToUTF16("Apple Chancery"); | |
48 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Papyrus"); | |
49 serif = base::ASCIIToUTF16("Times"); | |
50 #else | |
51 prefs->cursive_font_family_map[kCommonScript] = | |
52 base::ASCIIToUTF16("Comic Sans MS"); | |
53 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact"); | |
54 serif = base::ASCIIToUTF16("times new roman"); | |
55 #endif | |
56 prefs->serif_font_family_map[kCommonScript] = serif; | |
57 prefs->standard_font_family_map[kCommonScript] = serif; | |
58 prefs->fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier"); | |
59 prefs->sans_serif_font_family_map[kCommonScript] = | |
60 base::ASCIIToUTF16("Helvetica"); | |
61 prefs->minimum_logical_font_size = 9; | |
62 prefs->asynchronous_spell_checking_enabled = false; | |
63 prefs->accelerated_2d_canvas_enabled = accelerated_2d_canvas_enabled; | |
64 prefs->mock_scrollbars_enabled = false; | |
65 prefs->smart_insert_delete_enabled = true; | |
66 prefs->minimum_accelerated_2d_canvas_size = 0; | |
67 #if defined(OS_ANDROID) | |
68 prefs->text_autosizing_enabled = false; | |
69 #endif | |
70 prefs->viewport_enabled = false; | |
71 prefs->default_minimum_page_scale_factor = 1.f; | |
72 prefs->default_maximum_page_scale_factor = 4.f; | |
73 } | |
74 | |
75 } // namespace | |
76 | |
77 LayoutTestBlinkSettingsImpl::LayoutTestBlinkSettingsImpl() | |
78 : BlinkSettingsImpl(), accelerated_2d_canvas_enabled_(false) {} | |
79 | |
80 void LayoutTestBlinkSettingsImpl::Init() { | |
81 BlinkSettingsImpl::Init(); | |
82 const base::CommandLine& command_line = | |
83 *base::CommandLine::ForCurrentProcess(); | |
84 accelerated_2d_canvas_enabled_ = | |
85 command_line.HasSwitch(kEnableAccelerated2DCanvas); | |
86 } | |
87 | |
88 void LayoutTestBlinkSettingsImpl::ApplySettingsToWebView( | |
89 blink::WebView* view) const { | |
90 WebPreferences prefs; | |
91 UpdateWebPreferencesForTest(&prefs, accelerated_2d_canvas_enabled_); | |
92 ApplySettings(view, prefs); | |
93 ApplyFontRendereringSettings(); | |
94 | |
95 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); | |
96 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); | |
97 | |
98 #if defined(OS_WIN) | |
99 gfx::SetDefaultDeviceScaleFactor(1.0f); | |
100 #endif | |
101 } | |
102 | |
103 } // namespace html_viewer | |
OLD | NEW |