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