Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: chrome/browser/tab_contents/render_view_host_delegate_helper.cc

Issue 8879016: Add more per-tab preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK -> DCHECK Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 // static 334 // static
335 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( 335 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
336 RenderViewHost* rvh) { 336 RenderViewHost* rvh) {
337 Profile* profile = Profile::FromBrowserContext( 337 Profile* profile = Profile::FromBrowserContext(
338 rvh->process()->GetBrowserContext()); 338 rvh->process()->GetBrowserContext());
339 PrefService* prefs = profile->GetPrefs(); 339 PrefService* prefs = profile->GetPrefs();
340 WebPreferences web_prefs; 340 WebPreferences web_prefs;
341 341
342 web_prefs.standard_font_family = 342 web_prefs.standard_font_family =
343 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); 343 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
344 web_prefs.fixed_font_family = 344 web_prefs.fixed_font_family =
345 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 345 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
346 web_prefs.serif_font_family = 346 web_prefs.serif_font_family =
347 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 347 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
348 web_prefs.sans_serif_font_family = 348 web_prefs.sans_serif_font_family =
349 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); 349 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
350 web_prefs.cursive_font_family = 350 web_prefs.cursive_font_family =
351 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); 351 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
352 web_prefs.fantasy_font_family = 352 web_prefs.fantasy_font_family =
353 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); 353 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
354 354
355 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, 355 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
356 &web_prefs.standard_font_family_map); 356 &web_prefs.standard_font_family_map);
357 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, 357 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
358 &web_prefs.fixed_font_family_map); 358 &web_prefs.fixed_font_family_map);
359 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, 359 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
360 &web_prefs.serif_font_family_map); 360 &web_prefs.serif_font_family_map);
361 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, 361 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
362 &web_prefs.sans_serif_font_family_map); 362 &web_prefs.sans_serif_font_family_map);
363 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, 363 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
364 &web_prefs.cursive_font_family_map); 364 &web_prefs.cursive_font_family_map);
365 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, 365 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
366 &web_prefs.fantasy_font_family_map); 366 &web_prefs.fantasy_font_family_map);
367 367
368 web_prefs.default_font_size = 368 web_prefs.default_font_size =
369 prefs->GetInteger(prefs::kWebKitDefaultFontSize); 369 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize);
370 web_prefs.default_fixed_font_size = 370 web_prefs.default_fixed_font_size =
371 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); 371 prefs->GetInteger(prefs::kWebKitGlobalDefaultFixedFontSize);
372 web_prefs.minimum_font_size = 372 web_prefs.minimum_font_size =
373 prefs->GetInteger(prefs::kWebKitMinimumFontSize); 373 prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize);
374 web_prefs.minimum_logical_font_size = 374 web_prefs.minimum_logical_font_size =
375 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); 375 prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize);
376 376
377 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 377 web_prefs.default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset);
378 378
379 web_prefs.javascript_can_open_windows_automatically = 379 web_prefs.javascript_can_open_windows_automatically =
380 prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically); 380 prefs->GetBoolean(
381 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically);
381 web_prefs.dom_paste_enabled = 382 web_prefs.dom_paste_enabled =
382 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); 383 prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
383 web_prefs.shrinks_standalone_images_to_fit = 384 web_prefs.shrinks_standalone_images_to_fit =
384 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit); 385 prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
385 const DictionaryValue* inspector_settings = 386 const DictionaryValue* inspector_settings =
386 prefs->GetDictionary(prefs::kWebKitInspectorSettings); 387 prefs->GetDictionary(prefs::kWebKitInspectorSettings);
387 if (inspector_settings) { 388 if (inspector_settings) {
388 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys()); 389 for (DictionaryValue::key_iterator iter(inspector_settings->begin_keys());
389 iter != inspector_settings->end_keys(); ++iter) { 390 iter != inspector_settings->end_keys(); ++iter) {
390 std::string value; 391 std::string value;
391 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value)) 392 if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value))
392 web_prefs.inspector_settings.push_back( 393 web_prefs.inspector_settings.push_back(
393 std::make_pair(*iter, value)); 394 std::make_pair(*iter, value));
394 } 395 }
395 } 396 }
396 web_prefs.tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); 397 web_prefs.tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks);
397 398
398 { // Command line switches are used for preferences with no user interface. 399 { // Command line switches are used for preferences with no user interface.
399 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 400 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
400 web_prefs.developer_extras_enabled = true; 401 web_prefs.developer_extras_enabled = true;
401 web_prefs.javascript_enabled = 402 web_prefs.javascript_enabled =
402 !command_line.HasSwitch(switches::kDisableJavaScript) && 403 !command_line.HasSwitch(switches::kDisableJavaScript) &&
403 prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled); 404 prefs->GetBoolean(prefs::kWebKitGlobalJavascriptEnabled);
404 web_prefs.dart_enabled = !command_line.HasSwitch(switches::kDisableDart); 405 web_prefs.dart_enabled = !command_line.HasSwitch(switches::kDisableDart);
405 web_prefs.web_security_enabled = 406 web_prefs.web_security_enabled =
406 !command_line.HasSwitch(switches::kDisableWebSecurity) && 407 !command_line.HasSwitch(switches::kDisableWebSecurity) &&
407 prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled); 408 prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled);
408 web_prefs.plugins_enabled = 409 web_prefs.plugins_enabled =
409 !command_line.HasSwitch(switches::kDisablePlugins) && 410 !command_line.HasSwitch(switches::kDisablePlugins) &&
410 prefs->GetBoolean(prefs::kWebKitPluginsEnabled); 411 prefs->GetBoolean(prefs::kWebKitGlobalPluginsEnabled);
411 web_prefs.java_enabled = 412 web_prefs.java_enabled =
412 !command_line.HasSwitch(switches::kDisableJava) && 413 !command_line.HasSwitch(switches::kDisableJava) &&
413 prefs->GetBoolean(prefs::kWebKitJavaEnabled); 414 prefs->GetBoolean(prefs::kWebKitJavaEnabled);
414 web_prefs.loads_images_automatically = 415 web_prefs.loads_images_automatically =
415 prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); 416 prefs->GetBoolean(prefs::kWebKitGlobalLoadsImagesAutomatically);
416 web_prefs.uses_page_cache = 417 web_prefs.uses_page_cache =
417 command_line.HasSwitch(switches::kEnableFastback); 418 command_line.HasSwitch(switches::kEnableFastback);
418 web_prefs.remote_fonts_enabled = 419 web_prefs.remote_fonts_enabled =
419 !command_line.HasSwitch(switches::kDisableRemoteFonts); 420 !command_line.HasSwitch(switches::kDisableRemoteFonts);
420 web_prefs.xss_auditor_enabled = 421 web_prefs.xss_auditor_enabled =
421 !command_line.HasSwitch(switches::kDisableXSSAuditor); 422 !command_line.HasSwitch(switches::kDisableXSSAuditor);
422 web_prefs.application_cache_enabled = 423 web_prefs.application_cache_enabled =
423 !command_line.HasSwitch(switches::kDisableApplicationCache); 424 !command_line.HasSwitch(switches::kDisableApplicationCache);
424 425
425 web_prefs.local_storage_enabled = 426 web_prefs.local_storage_enabled =
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 web_prefs.text_areas_are_resizable = 537 web_prefs.text_areas_are_resizable =
537 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); 538 prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);
538 web_prefs.hyperlink_auditing_enabled = 539 web_prefs.hyperlink_auditing_enabled =
539 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); 540 prefs->GetBoolean(prefs::kEnableHyperlinkAuditing);
540 541
541 // Make sure we will set the default_encoding with canonical encoding name. 542 // Make sure we will set the default_encoding with canonical encoding name.
542 web_prefs.default_encoding = 543 web_prefs.default_encoding =
543 CharacterEncoding::GetCanonicalEncodingNameByAliasName( 544 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
544 web_prefs.default_encoding); 545 web_prefs.default_encoding);
545 if (web_prefs.default_encoding.empty()) { 546 if (web_prefs.default_encoding.empty()) {
546 prefs->ClearPref(prefs::kDefaultCharset); 547 prefs->ClearPref(prefs::kGlobalDefaultCharset);
547 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 548 web_prefs.default_encoding = prefs->GetString(prefs::kGlobalDefaultCharset);
548 } 549 }
549 DCHECK(!web_prefs.default_encoding.empty()); 550 DCHECK(!web_prefs.default_encoding.empty());
550 551
551 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( 552 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(
552 rvh->process()->GetID())) { 553 rvh->process()->GetID())) {
553 web_prefs.loads_images_automatically = true; 554 web_prefs.loads_images_automatically = true;
554 web_prefs.javascript_enabled = true; 555 web_prefs.javascript_enabled = true;
555 } 556 }
556 557
557 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 558 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 DictionaryValue* inspector_settings = update.Get(); 592 DictionaryValue* inspector_settings = update.Get();
592 inspector_settings->SetWithoutPathExpansion(key, 593 inspector_settings->SetWithoutPathExpansion(key,
593 Value::CreateStringValue(value)); 594 Value::CreateStringValue(value));
594 } 595 }
595 596
596 void RenderViewHostDelegateHelper::ClearInspectorSettings( 597 void RenderViewHostDelegateHelper::ClearInspectorSettings(
597 content::BrowserContext* browser_context) { 598 content::BrowserContext* browser_context) {
598 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 599 Profile::FromBrowserContext(browser_context)->GetPrefs()->
599 ClearPref(prefs::kWebKitInspectorSettings); 600 ClearPref(prefs::kWebKitInspectorSettings);
600 } 601 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/two_client_preferences_sync_test.cc ('k') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698