OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_contents/render_view_host_delegate_helper.h" | 5 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/character_encoding.h" | 10 #include "chrome/browser/character_encoding.h" |
11 #include "chrome/browser/pref_service.h" | 11 #include "chrome/browser/pref_service.h" |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
13 #include "chrome/browser/renderer_host/render_view_host.h" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
14 #include "chrome/browser/renderer_host/render_process_host.h" | 14 #include "chrome/browser/renderer_host/render_process_host.h" |
15 #include "chrome/browser/renderer_host/render_widget_host.h" | 15 #include "chrome/browser/renderer_host/render_widget_host.h" |
16 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
17 #include "chrome/browser/renderer_host/site_instance.h" | 17 #include "chrome/browser/renderer_host/site_instance.h" |
18 #include "chrome/browser/tab_contents/tab_contents.h" | 18 #include "chrome/browser/tab_contents/tab_contents.h" |
19 #include "chrome/browser/tab_contents/tab_contents_view.h" | 19 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 20 #include "chrome/browser/user_style_sheet_watcher.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 | 23 |
23 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( | 24 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( |
24 int route_id, | 25 int route_id, |
25 Profile* profile, | 26 Profile* profile, |
26 SiteInstance* site, | 27 SiteInstance* site, |
27 DOMUITypeID domui_type, | 28 DOMUITypeID domui_type, |
28 TabContents* old_tab_contents) { | 29 TabContents* old_tab_contents) { |
29 // Create the new web contents. This will automatically create the new | 30 // Create the new web contents. This will automatically create the new |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 i != pending_widget_views_.end(); ++i) { | 106 i != pending_widget_views_.end(); ++i) { |
106 if (host->view() == i->second) { | 107 if (host->view() == i->second) { |
107 pending_widget_views_.erase(i); | 108 pending_widget_views_.erase(i); |
108 return; | 109 return; |
109 } | 110 } |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 // static | 114 // static |
114 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( | 115 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( |
115 PrefService* prefs, bool is_dom_ui) { | 116 Profile* profile, bool is_dom_ui) { |
116 | 117 PrefService* prefs = profile->GetPrefs(); |
117 WebPreferences web_prefs; | 118 WebPreferences web_prefs; |
118 | 119 |
119 web_prefs.fixed_font_family = | 120 web_prefs.fixed_font_family = |
120 prefs->GetString(prefs::kWebKitFixedFontFamily); | 121 prefs->GetString(prefs::kWebKitFixedFontFamily); |
121 web_prefs.serif_font_family = | 122 web_prefs.serif_font_family = |
122 prefs->GetString(prefs::kWebKitSerifFontFamily); | 123 prefs->GetString(prefs::kWebKitSerifFontFamily); |
123 web_prefs.sans_serif_font_family = | 124 web_prefs.sans_serif_font_family = |
124 prefs->GetString(prefs::kWebKitSansSerifFontFamily); | 125 prefs->GetString(prefs::kWebKitSansSerifFontFamily); |
125 if (prefs->GetBoolean(prefs::kWebKitStandardFontIsSerif)) | 126 if (prefs->GetBoolean(prefs::kWebKitStandardFontIsSerif)) |
126 web_prefs.standard_font_family = web_prefs.serif_font_family; | 127 web_prefs.standard_font_family = web_prefs.serif_font_family; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 web_prefs.uses_page_cache = | 174 web_prefs.uses_page_cache = |
174 command_line.HasSwitch(switches::kEnableFastback); | 175 command_line.HasSwitch(switches::kEnableFastback); |
175 web_prefs.remote_fonts_enabled = | 176 web_prefs.remote_fonts_enabled = |
176 !command_line.HasSwitch(switches::kDisableRemoteFonts); | 177 !command_line.HasSwitch(switches::kDisableRemoteFonts); |
177 web_prefs.xss_auditor_enabled = | 178 web_prefs.xss_auditor_enabled = |
178 !command_line.HasSwitch(switches::kDisableXSSAuditor); | 179 !command_line.HasSwitch(switches::kDisableXSSAuditor); |
179 web_prefs.application_cache_enabled = | 180 web_prefs.application_cache_enabled = |
180 !command_line.HasSwitch(switches::kDisableApplicationCache); | 181 !command_line.HasSwitch(switches::kDisableApplicationCache); |
181 | 182 |
182 web_prefs.local_storage_enabled = | 183 web_prefs.local_storage_enabled = |
183 !command_line.HasSwitch(switches::kDisableLocalStorage); | 184 !command_line.HasSwitch(switches::kDisableLocalStorage); |
184 web_prefs.databases_enabled = | 185 web_prefs.databases_enabled = |
185 !command_line.HasSwitch(switches::kDisableDatabases); | 186 !command_line.HasSwitch(switches::kDisableDatabases); |
186 web_prefs.experimental_webgl_enabled = | 187 web_prefs.experimental_webgl_enabled = |
187 command_line.HasSwitch(switches::kEnableExperimentalWebGL); | 188 command_line.HasSwitch(switches::kEnableExperimentalWebGL); |
188 web_prefs.site_specific_quirks_enabled = | 189 web_prefs.site_specific_quirks_enabled = |
189 !command_line.HasSwitch(switches::kDisableSiteSpecificQuirks); | 190 !command_line.HasSwitch(switches::kDisableSiteSpecificQuirks); |
190 web_prefs.allow_file_access_from_file_urls = | 191 web_prefs.allow_file_access_from_file_urls = |
191 command_line.HasSwitch(switches::kAllowFileAccessFromFiles); | 192 command_line.HasSwitch(switches::kAllowFileAccessFromFiles); |
192 web_prefs.show_composited_layer_borders = | 193 web_prefs.show_composited_layer_borders = |
193 command_line.HasSwitch(switches::kShowCompositedLayerBorders); | 194 command_line.HasSwitch(switches::kShowCompositedLayerBorders); |
| 195 web_prefs.user_style_sheet_enabled = |
| 196 command_line.HasSwitch(switches::kEnableUserStyleSheet); |
| 197 if (web_prefs.user_style_sheet_enabled) { |
| 198 web_prefs.user_style_sheet_location = |
| 199 profile->GetUserStyleSheetWatcher()->user_style_sheet(); |
| 200 } |
| 201 |
194 } | 202 } |
195 | 203 |
196 web_prefs.uses_universal_detector = | 204 web_prefs.uses_universal_detector = |
197 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector); | 205 prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector); |
198 web_prefs.text_areas_are_resizable = | 206 web_prefs.text_areas_are_resizable = |
199 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); | 207 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); |
200 | 208 |
201 // User CSS is currently disabled because it crashes chrome. See | |
202 // webkit/glue/webpreferences.h for more details. | |
203 | |
204 // Make sure we will set the default_encoding with canonical encoding name. | 209 // Make sure we will set the default_encoding with canonical encoding name. |
205 web_prefs.default_encoding = | 210 web_prefs.default_encoding = |
206 CharacterEncoding::GetCanonicalEncodingNameByAliasName( | 211 CharacterEncoding::GetCanonicalEncodingNameByAliasName( |
207 web_prefs.default_encoding); | 212 web_prefs.default_encoding); |
208 if (web_prefs.default_encoding.empty()) { | 213 if (web_prefs.default_encoding.empty()) { |
209 prefs->ClearPref(prefs::kDefaultCharset); | 214 prefs->ClearPref(prefs::kDefaultCharset); |
210 web_prefs.default_encoding = WideToASCII( | 215 web_prefs.default_encoding = WideToASCII( |
211 prefs->GetString(prefs::kDefaultCharset)); | 216 prefs->GetString(prefs::kDefaultCharset)); |
212 } | 217 } |
213 DCHECK(!web_prefs.default_encoding.empty()); | 218 DCHECK(!web_prefs.default_encoding.empty()); |
214 | 219 |
215 if (is_dom_ui) { | 220 if (is_dom_ui) { |
216 web_prefs.loads_images_automatically = true; | 221 web_prefs.loads_images_automatically = true; |
217 web_prefs.javascript_enabled = true; | 222 web_prefs.javascript_enabled = true; |
218 } | 223 } |
219 | 224 |
220 return web_prefs; | 225 return web_prefs; |
221 } | 226 } |
OLD | NEW |