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 7606028: Pass per-script fonts to WebKit settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Mattias's nits Created 9 years, 4 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 <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"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 TabContents* tab_contents, int route_id) { 292 TabContents* tab_contents, int route_id) {
293 if (tab_contents->delegate()) 293 if (tab_contents->delegate())
294 tab_contents->delegate()->RenderWidgetShowing(); 294 tab_contents->delegate()->RenderWidgetShowing();
295 295
296 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id); 296 RenderWidgetHostView* widget_host_view = GetCreatedWidget(route_id);
297 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView()); 297 widget_host_view->InitAsFullscreen(tab_contents->GetRenderWidgetHostView());
298 widget_host_view->GetRenderWidgetHost()->Init(); 298 widget_host_view->GetRenderWidgetHost()->Init();
299 return widget_host_view; 299 return widget_host_view;
300 } 300 }
301 301
302 static void FillFontFamilyMap(const PrefService* prefs,
303 const char* map_name,
304 WebPreferences::ScriptFontFamilyMap* map) {
305 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
306 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
307 const char* pref_name =
308 base::StringPrintf("%s.%s", map_name, script).c_str();
309 std::string font_family = prefs->GetString(pref_name);
310 if (!font_family.empty())
311 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
312 }
313 }
314
302 // static 315 // static
303 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( 316 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
304 content::BrowserContext* browser_context, bool is_web_ui) { 317 content::BrowserContext* browser_context, bool is_web_ui) {
305 Profile* profile = Profile::FromBrowserContext(browser_context); 318 Profile* profile = Profile::FromBrowserContext(browser_context);
306 PrefService* prefs = profile->GetPrefs(); 319 PrefService* prefs = profile->GetPrefs();
307 WebPreferences web_prefs; 320 WebPreferences web_prefs;
308 321
309 web_prefs.standard_font_family = 322 web_prefs.standard_font_family =
310 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); 323 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily));
311 web_prefs.fixed_font_family = 324 web_prefs.fixed_font_family =
312 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 325 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily));
313 web_prefs.serif_font_family = 326 web_prefs.serif_font_family =
314 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 327 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily));
315 web_prefs.sans_serif_font_family = 328 web_prefs.sans_serif_font_family =
316 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); 329 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily));
317 web_prefs.cursive_font_family = 330 web_prefs.cursive_font_family =
318 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); 331 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily));
319 web_prefs.fantasy_font_family = 332 web_prefs.fantasy_font_family =
320 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); 333 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily));
321 334
335 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
336 &web_prefs.standard_font_family_map);
337 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
338 &web_prefs.fixed_font_family_map);
339 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
340 &web_prefs.serif_font_family_map);
341 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
342 &web_prefs.sans_serif_font_family_map);
343 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
344 &web_prefs.cursive_font_family_map);
345 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
346 &web_prefs.fantasy_font_family_map);
347
322 web_prefs.default_font_size = 348 web_prefs.default_font_size =
323 prefs->GetInteger(prefs::kWebKitDefaultFontSize); 349 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
324 web_prefs.default_fixed_font_size = 350 web_prefs.default_fixed_font_size =
325 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); 351 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
326 web_prefs.minimum_font_size = 352 web_prefs.minimum_font_size =
327 prefs->GetInteger(prefs::kWebKitMinimumFontSize); 353 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
328 web_prefs.minimum_logical_font_size = 354 web_prefs.minimum_logical_font_size =
329 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); 355 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
330 356
331 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 357 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 DictionaryValue* inspector_settings = update.Get(); 517 DictionaryValue* inspector_settings = update.Get();
492 inspector_settings->SetWithoutPathExpansion(key, 518 inspector_settings->SetWithoutPathExpansion(key,
493 Value::CreateStringValue(value)); 519 Value::CreateStringValue(value));
494 } 520 }
495 521
496 void RenderViewHostDelegateHelper::ClearInspectorSettings( 522 void RenderViewHostDelegateHelper::ClearInspectorSettings(
497 content::BrowserContext* browser_context) { 523 content::BrowserContext* browser_context) {
498 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 524 Profile::FromBrowserContext(browser_context)->GetPrefs()->
499 ClearPref(prefs::kWebKitInspectorSettings); 525 ClearPref(prefs::kWebKitInspectorSettings);
500 } 526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698