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

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

Issue 8403024: Set extension-related webkit preferences in a common location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove is_web_ui param Created 9 years, 1 month 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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/background/background_contents_service.h" 12 #include "chrome/browser/background/background_contents_service.h"
13 #include "chrome/browser/background/background_contents_service_factory.h" 13 #include "chrome/browser/background/background_contents_service_factory.h"
14 #include "chrome/browser/chrome_content_browser_client.h" 14 #include "chrome/browser/chrome_content_browser_client.h"
15 #include "chrome/browser/character_encoding.h" 15 #include "chrome/browser/character_encoding.h"
16 #include "chrome/browser/extensions/extension_process_manager.h"
16 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_webkit_preferences.h"
17 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prefs/scoped_user_pref_update.h" 20 #include "chrome/browser/prefs/scoped_user_pref_update.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 21 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h" 22 #include "chrome/browser/prerender/prerender_manager_factory.h"
21 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/tab_contents/background_contents.h" 24 #include "chrome/browser/tab_contents/background_contents.h"
23 #include "chrome/browser/user_style_sheet_watcher.h" 25 #include "chrome/browser/user_style_sheet_watcher.h"
24 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "content/browser/child_process_security_policy.h"
26 #include "content/browser/gpu/gpu_data_manager.h" 29 #include "content/browser/gpu/gpu_data_manager.h"
27 #include "content/browser/gpu/gpu_process_host.h" 30 #include "content/browser/gpu/gpu_process_host.h"
28 #include "content/browser/renderer_host/render_view_host.h" 31 #include "content/browser/renderer_host/render_view_host.h"
29 #include "content/browser/renderer_host/render_process_host.h" 32 #include "content/browser/renderer_host/render_process_host.h"
30 #include "content/browser/renderer_host/render_widget_fullscreen_host.h" 33 #include "content/browser/renderer_host/render_widget_fullscreen_host.h"
31 #include "content/browser/renderer_host/render_widget_host.h" 34 #include "content/browser/renderer_host/render_widget_host.h"
32 #include "content/browser/renderer_host/render_widget_host_view.h" 35 #include "content/browser/renderer_host/render_widget_host_view.h"
33 #include "content/browser/site_instance.h" 36 #include "content/browser/site_instance.h"
34 #include "content/browser/tab_contents/navigation_details.h" 37 #include "content/browser/tab_contents/navigation_details.h"
35 #include "content/browser/tab_contents/tab_contents.h" 38 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 tab_contents->delegate()->RenderWidgetShowing(); 322 tab_contents->delegate()->RenderWidgetShowing();
320 323
321 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id); 324 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id);
322 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView()); 325 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView());
323 widget_host_view->GetRenderWidgetHost()->Init(); 326 widget_host_view->GetRenderWidgetHost()->Init();
324 return widget_host_view; 327 return widget_host_view;
325 } 328 }
326 329
327 // static 330 // static
328 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( 331 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
329 content::BrowserContext* browser_context, bool is_web_ui) { 332 RenderViewHost* rvh) {
330 Profile* profile = Profile::FromBrowserContext(browser_context); 333 Profile* profile = Profile::FromBrowserContext(
334 rvh->process()->browser_context());
331 PrefService* prefs = profile->GetPrefs(); 335 PrefService* prefs = profile->GetPrefs();
332 WebPreferences web_prefs; 336 WebPreferences web_prefs;
333 337
334 web_prefs.standard_font_family = 338 web_prefs.standard_font_family =
335 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); 339 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily));
336 web_prefs.fixed_font_family = 340 web_prefs.fixed_font_family =
337 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 341 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily));
338 web_prefs.serif_font_family = 342 web_prefs.serif_font_family =
339 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 343 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily));
340 web_prefs.sans_serif_font_family = 344 web_prefs.sans_serif_font_family =
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // Make sure we will set the default_encoding with canonical encoding name. 522 // Make sure we will set the default_encoding with canonical encoding name.
519 web_prefs.default_encoding = 523 web_prefs.default_encoding =
520 CharacterEncoding::GetCanonicalEncodingNameByAliasName( 524 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
521 web_prefs.default_encoding); 525 web_prefs.default_encoding);
522 if (web_prefs.default_encoding.empty()) { 526 if (web_prefs.default_encoding.empty()) {
523 prefs->ClearPref(prefs::kDefaultCharset); 527 prefs->ClearPref(prefs::kDefaultCharset);
524 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 528 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset);
525 } 529 }
526 DCHECK(!web_prefs.default_encoding.empty()); 530 DCHECK(!web_prefs.default_encoding.empty());
527 531
528 if (is_web_ui) { 532 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(
533 rvh->process()->id())) {
529 web_prefs.loads_images_automatically = true; 534 web_prefs.loads_images_automatically = true;
530 web_prefs.javascript_enabled = true; 535 web_prefs.javascript_enabled = true;
531 } 536 }
532 537
533 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 538 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
534 539
540 ExtensionProcessManager* extension_process_manager =
541 profile->GetExtensionProcessManager();
542 if (extension_process_manager) {
543 const Extension* extension =
544 extension_process_manager->GetExtensionForSiteInstance(
545 rvh->site_instance()->id());
546 extension_webkit_preferences::SetPreferences(&web_prefs, extension);
547 }
548
535 return web_prefs; 549 return web_prefs;
536 } 550 }
537 551
538 void RenderViewHostDelegateHelper::UpdateInspectorSetting( 552 void RenderViewHostDelegateHelper::UpdateInspectorSetting(
539 content::BrowserContext* browser_context, 553 content::BrowserContext* browser_context,
540 const std::string& key, 554 const std::string& key,
541 const std::string& value) { 555 const std::string& value) {
542 DictionaryPrefUpdate update( 556 DictionaryPrefUpdate update(
543 Profile::FromBrowserContext(browser_context)->GetPrefs(), 557 Profile::FromBrowserContext(browser_context)->GetPrefs(),
544 prefs::kWebKitInspectorSettings); 558 prefs::kWebKitInspectorSettings);
545 DictionaryValue* inspector_settings = update.Get(); 559 DictionaryValue* inspector_settings = update.Get();
546 inspector_settings->SetWithoutPathExpansion(key, 560 inspector_settings->SetWithoutPathExpansion(key,
547 Value::CreateStringValue(value)); 561 Value::CreateStringValue(value));
548 } 562 }
549 563
550 void RenderViewHostDelegateHelper::ClearInspectorSettings( 564 void RenderViewHostDelegateHelper::ClearInspectorSettings(
551 content::BrowserContext* browser_context) { 565 content::BrowserContext* browser_context) {
552 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 566 Profile::FromBrowserContext(browser_context)->GetPrefs()->
553 ClearPref(prefs::kWebKitInspectorSettings); 567 ClearPref(prefs::kWebKitInspectorSettings);
554 } 568 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_host_delegate_helper.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698