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

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: 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"
26 #include "content/browser/gpu/gpu_data_manager.h" 28 #include "content/browser/gpu/gpu_data_manager.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 tab_contents->delegate()->RenderWidgetShowing(); 321 tab_contents->delegate()->RenderWidgetShowing();
320 322
321 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id); 323 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id);
322 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView()); 324 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView());
323 widget_host_view->GetRenderWidgetHost()->Init(); 325 widget_host_view->GetRenderWidgetHost()->Init();
324 return widget_host_view; 326 return widget_host_view;
325 } 327 }
326 328
327 // static 329 // static
328 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( 330 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
329 content::BrowserContext* browser_context, bool is_web_ui) { 331 RenderViewHost* rvh, bool is_web_ui) {
330 Profile* profile = Profile::FromBrowserContext(browser_context); 332 Profile* profile = Profile::FromBrowserContext(
333 rvh->process()->browser_context());
331 PrefService* prefs = profile->GetPrefs(); 334 PrefService* prefs = profile->GetPrefs();
332 WebPreferences web_prefs; 335 WebPreferences web_prefs;
333 336
334 web_prefs.standard_font_family = 337 web_prefs.standard_font_family =
335 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); 338 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily));
336 web_prefs.fixed_font_family = 339 web_prefs.fixed_font_family =
337 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 340 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily));
338 web_prefs.serif_font_family = 341 web_prefs.serif_font_family =
339 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 342 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily));
340 web_prefs.sans_serif_font_family = 343 web_prefs.sans_serif_font_family =
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 528 }
526 DCHECK(!web_prefs.default_encoding.empty()); 529 DCHECK(!web_prefs.default_encoding.empty());
527 530
528 if (is_web_ui) { 531 if (is_web_ui) {
529 web_prefs.loads_images_automatically = true; 532 web_prefs.loads_images_automatically = true;
530 web_prefs.javascript_enabled = true; 533 web_prefs.javascript_enabled = true;
531 } 534 }
532 535
533 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 536 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
534 537
538 ExtensionProcessManager* extension_process_manager =
539 profile->GetExtensionProcessManager();
540 if (extension_process_manager) {
541 const Extension* extension =
542 extension_process_manager->GetExtensionForSiteInstance(
543 rvh->site_instance()->id());
544 extension_webkit_preferences::SetPreferences(&web_prefs, extension);
545 }
546
535 return web_prefs; 547 return web_prefs;
536 } 548 }
537 549
538 void RenderViewHostDelegateHelper::UpdateInspectorSetting( 550 void RenderViewHostDelegateHelper::UpdateInspectorSetting(
539 content::BrowserContext* browser_context, 551 content::BrowserContext* browser_context,
540 const std::string& key, 552 const std::string& key,
541 const std::string& value) { 553 const std::string& value) {
542 DictionaryPrefUpdate update( 554 DictionaryPrefUpdate update(
543 Profile::FromBrowserContext(browser_context)->GetPrefs(), 555 Profile::FromBrowserContext(browser_context)->GetPrefs(),
544 prefs::kWebKitInspectorSettings); 556 prefs::kWebKitInspectorSettings);
545 DictionaryValue* inspector_settings = update.Get(); 557 DictionaryValue* inspector_settings = update.Get();
546 inspector_settings->SetWithoutPathExpansion(key, 558 inspector_settings->SetWithoutPathExpansion(key,
547 Value::CreateStringValue(value)); 559 Value::CreateStringValue(value));
548 } 560 }
549 561
550 void RenderViewHostDelegateHelper::ClearInspectorSettings( 562 void RenderViewHostDelegateHelper::ClearInspectorSettings(
551 content::BrowserContext* browser_context) { 563 content::BrowserContext* browser_context) {
552 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 564 Profile::FromBrowserContext(browser_context)->GetPrefs()->
553 ClearPref(prefs::kWebKitInspectorSettings); 565 ClearPref(prefs::kWebKitInspectorSettings);
554 } 566 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698