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 "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 "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/background/background_contents_service.h" | 10 #include "chrome/browser/background/background_contents_service.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 // static | 332 // static |
333 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( | 333 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( |
334 RenderViewHost* rvh) { | 334 RenderViewHost* rvh) { |
335 Profile* profile = Profile::FromBrowserContext( | 335 Profile* profile = Profile::FromBrowserContext( |
336 rvh->process()->GetBrowserContext()); | 336 rvh->process()->GetBrowserContext()); |
337 PrefService* prefs = profile->GetPrefs(); | 337 PrefService* prefs = profile->GetPrefs(); |
338 WebPreferences web_prefs; | 338 WebPreferences web_prefs; |
339 | 339 |
340 web_prefs.standard_font_family = | 340 web_prefs.standard_font_family = |
341 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); | 341 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); |
342 web_prefs.fixed_font_family = | 342 web_prefs.fixed_font_family = |
343 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); | 343 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); |
344 web_prefs.serif_font_family = | 344 web_prefs.serif_font_family = |
345 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); | 345 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); |
346 web_prefs.sans_serif_font_family = | 346 web_prefs.sans_serif_font_family = |
347 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); | 347 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); |
348 web_prefs.cursive_font_family = | 348 web_prefs.cursive_font_family = |
349 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); | 349 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily)); |
350 web_prefs.fantasy_font_family = | 350 web_prefs.fantasy_font_family = |
351 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); | 351 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily)); |
352 | 352 |
353 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, | 353 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, |
354 &web_prefs.standard_font_family_map); | 354 &web_prefs.standard_font_family_map); |
355 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, | 355 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, |
356 &web_prefs.fixed_font_family_map); | 356 &web_prefs.fixed_font_family_map); |
357 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, | 357 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, |
358 &web_prefs.serif_font_family_map); | 358 &web_prefs.serif_font_family_map); |
359 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, | 359 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, |
360 &web_prefs.sans_serif_font_family_map); | 360 &web_prefs.sans_serif_font_family_map); |
361 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, | 361 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, |
362 &web_prefs.cursive_font_family_map); | 362 &web_prefs.cursive_font_family_map); |
363 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, | 363 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, |
364 &web_prefs.fantasy_font_family_map); | 364 &web_prefs.fantasy_font_family_map); |
365 | 365 |
366 web_prefs.default_font_size = | 366 web_prefs.default_font_size = |
367 prefs->GetInteger(prefs::kWebKitDefaultFontSize); | 367 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize); |
368 web_prefs.default_fixed_font_size = | 368 web_prefs.default_fixed_font_size = |
369 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); | 369 prefs->GetInteger(prefs::kWebKitGlobalDefaultFixedFontSize); |
370 web_prefs.minimum_font_size = | 370 web_prefs.minimum_font_size = |
371 prefs->GetInteger(prefs::kWebKitMinimumFontSize); | 371 prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize); |
372 web_prefs.minimum_logical_font_size = | 372 web_prefs.minimum_logical_font_size = |
373 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); | 373 prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize); |
374 | 374 |
375 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); | 375 web_prefs.default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset); |
376 | 376 |
377 web_prefs.javascript_can_open_windows_automatically = | 377 web_prefs.javascript_can_open_windows_automatically = |
378 prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically); | 378 prefs->GetBoolean( |
| 379 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically); |
379 web_prefs.dom_paste_enabled = | 380 web_prefs.dom_paste_enabled = |
380 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); | 381 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); |
381 web_prefs.shrinks_standalone_images_to_fit = | 382 web_prefs.shrinks_standalone_images_to_fit = |
382 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit); | 383 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit); |
383 const DictionaryValue* inspector_settings = | 384 const DictionaryValue* inspector_settings = |
384 prefs->GetDictionary(prefs::kWebKitInspectorSettings); | 385 prefs->GetDictionary(prefs::kWebKitInspectorSettings); |
385 if (inspector_settings) { | 386 if (inspector_settings) { |
386 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys()); | 387 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys()); |
387 iter != inspector_settings->end_keys(); ++iter) { | 388 iter != inspector_settings->end_keys(); ++iter) { |
388 std::string value; | 389 std::string value; |
389 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value)) | 390 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value)) |
390 web_prefs.inspector_settings.push_back( | 391 web_prefs.inspector_settings.push_back( |
391 std::make_pair(*iter, value)); | 392 std::make_pair(*iter, value)); |
392 } | 393 } |
393 } | 394 } |
394 web_prefs.tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); | 395 web_prefs.tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); |
395 | 396 |
396 { // Command line switches are used for preferences with no user interface. | 397 { // Command line switches are used for preferences with no user interface. |
397 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 398 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
398 web_prefs.developer_extras_enabled = true; | 399 web_prefs.developer_extras_enabled = true; |
399 web_prefs.javascript_enabled = | 400 web_prefs.javascript_enabled = |
400 !command_line.HasSwitch(switches::kDisableJavaScript) && | 401 !command_line.HasSwitch(switches::kDisableJavaScript) && |
401 prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled); | 402 prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled); |
402 web_prefs.web_security_enabled = | 403 web_prefs.web_security_enabled = |
403 !command_line.HasSwitch(switches::kDisableWebSecurity) && | 404 !command_line.HasSwitch(switches::kDisableWebSecurity) && |
404 prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled); | 405 prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled); |
405 web_prefs.plugins_enabled = | 406 web_prefs.plugins_enabled = |
406 !command_line.HasSwitch(switches::kDisablePlugins) && | 407 !command_line.HasSwitch(switches::kDisablePlugins) && |
407 prefs->GetBoolean(prefs::kWebKitPluginsEnabled); | 408 prefs->GetBoolean(prefs::kWebKitGlobalPluginsEnabled); |
408 web_prefs.java_enabled = | 409 web_prefs.java_enabled = |
409 !command_line.HasSwitch(switches::kDisableJava) && | 410 !command_line.HasSwitch(switches::kDisableJava) && |
410 prefs->GetBoolean(prefs::kWebKitJavaEnabled); | 411 prefs->GetBoolean(prefs::kWebKitJavaEnabled); |
411 web_prefs.loads_images_automatically = | 412 web_prefs.loads_images_automatically = |
412 prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); | 413 prefs->GetBoolean(prefs::kWebKitGlobalLoadsImagesAutomatically); |
413 web_prefs.uses_page_cache = | 414 web_prefs.uses_page_cache = |
414 command_line.HasSwitch(switches::kEnableFastback); | 415 command_line.HasSwitch(switches::kEnableFastback); |
415 web_prefs.remote_fonts_enabled = | 416 web_prefs.remote_fonts_enabled = |
416 !command_line.HasSwitch(switches::kDisableRemoteFonts); | 417 !command_line.HasSwitch(switches::kDisableRemoteFonts); |
417 web_prefs.xss_auditor_enabled = | 418 web_prefs.xss_auditor_enabled = |
418 !command_line.HasSwitch(switches::kDisableXSSAuditor); | 419 !command_line.HasSwitch(switches::kDisableXSSAuditor); |
419 web_prefs.application_cache_enabled = | 420 web_prefs.application_cache_enabled = |
420 !command_line.HasSwitch(switches::kDisableApplicationCache); | 421 !command_line.HasSwitch(switches::kDisableApplicationCache); |
421 | 422 |
422 web_prefs.local_storage_enabled = | 423 web_prefs.local_storage_enabled = |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 web_prefs.text_areas_are_resizable = | 531 web_prefs.text_areas_are_resizable = |
531 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); | 532 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); |
532 web_prefs.hyperlink_auditing_enabled = | 533 web_prefs.hyperlink_auditing_enabled = |
533 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); | 534 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); |
534 | 535 |
535 // Make sure we will set the default_encoding with canonical encoding name. | 536 // Make sure we will set the default_encoding with canonical encoding name. |
536 web_prefs.default_encoding = | 537 web_prefs.default_encoding = |
537 CharacterEncoding::GetCanonicalEncodingNameByAliasName( | 538 CharacterEncoding::GetCanonicalEncodingNameByAliasName( |
538 web_prefs.default_encoding); | 539 web_prefs.default_encoding); |
539 if (web_prefs.default_encoding.empty()) { | 540 if (web_prefs.default_encoding.empty()) { |
540 prefs->ClearPref(prefs::kDefaultCharset); | 541 prefs->ClearPref(prefs::kGlobalDefaultCharset); |
541 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); | 542 web_prefs.default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset); |
542 } | 543 } |
543 DCHECK(!web_prefs.default_encoding.empty()); | 544 DCHECK(!web_prefs.default_encoding.empty()); |
544 | 545 |
545 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( | 546 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
546 rvh->process()->GetID())) { | 547 rvh->process()->GetID())) { |
547 web_prefs.loads_images_automatically = true; | 548 web_prefs.loads_images_automatically = true; |
548 web_prefs.javascript_enabled = true; | 549 web_prefs.javascript_enabled = true; |
549 } | 550 } |
550 | 551 |
551 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); | 552 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 DictionaryValue* inspector_settings = update.Get(); | 586 DictionaryValue* inspector_settings = update.Get(); |
586 inspector_settings->SetWithoutPathExpansion(key, | 587 inspector_settings->SetWithoutPathExpansion(key, |
587 Value::CreateStringValue(value)); | 588 Value::CreateStringValue(value)); |
588 } | 589 } |
589 | 590 |
590 void RenderViewHostDelegateHelper::ClearInspectorSettings( | 591 void RenderViewHostDelegateHelper::ClearInspectorSettings( |
591 content::BrowserContext* browser_context) { | 592 content::BrowserContext* browser_context) { |
592 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 593 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
593 ClearPref(prefs::kWebKitInspectorSettings); | 594 ClearPref(prefs::kWebKitInspectorSettings); |
594 } | 595 } |
OLD | NEW |