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

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: pref strings instead of dictionary 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 void FillFontFamilyMap(const PrefService* prefs,
303 const std::string& map_name,
304 WebPreferences::ScriptFontFamilyMap* map) {
305 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
306 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
307 std::string pref_name = map_name + "." + script;
308 std::string font_family = prefs->GetString(pref_name.c_str());
309 if (!font_family.empty())
310 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
311 }
312 }
313
302 // static 314 // static
303 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( 315 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
304 content::BrowserContext* browser_context, bool is_web_ui) { 316 content::BrowserContext* browser_context, bool is_web_ui) {
305 Profile* profile = Profile::FromBrowserContext(browser_context); 317 Profile* profile = Profile::FromBrowserContext(browser_context);
306 PrefService* prefs = profile->GetPrefs(); 318 PrefService* prefs = profile->GetPrefs();
307 WebPreferences web_prefs; 319 WebPreferences web_prefs;
308 320
309 web_prefs.standard_font_family = 321 web_prefs.standard_font_family =
310 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); 322 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily));
311 web_prefs.fixed_font_family = 323 web_prefs.fixed_font_family =
312 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 324 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily));
313 web_prefs.serif_font_family = 325 web_prefs.serif_font_family =
314 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 326 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily));
315 web_prefs.sans_serif_font_family = 327 web_prefs.sans_serif_font_family =
316 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); 328 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily));
317 web_prefs.cursive_font_family = 329 web_prefs.cursive_font_family =
318 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); 330 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily));
319 web_prefs.fantasy_font_family = 331 web_prefs.fantasy_font_family =
320 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); 332 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily));
321 333
334 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
335 &web_prefs.standard_font_family_map);
336 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
337 &web_prefs.fixed_font_family_map);
338 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
339 &web_prefs.serif_font_family_map);
340 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
341 &web_prefs.sans_serif_font_family_map);
342 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
343 &web_prefs.cursive_font_family_map);
344 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
345 &web_prefs.fantasy_font_family_map);
346
322 web_prefs.default_font_size = 347 web_prefs.default_font_size =
323 prefs->GetInteger(prefs::kWebKitDefaultFontSize); 348 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
324 web_prefs.default_fixed_font_size = 349 web_prefs.default_fixed_font_size =
325 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); 350 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
326 web_prefs.minimum_font_size = 351 web_prefs.minimum_font_size =
327 prefs->GetInteger(prefs::kWebKitMinimumFontSize); 352 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
328 web_prefs.minimum_logical_font_size = 353 web_prefs.minimum_logical_font_size =
329 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); 354 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
330 355
331 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 356 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(); 516 DictionaryValue* inspector_settings = update.Get();
492 inspector_settings->SetWithoutPathExpansion(key, 517 inspector_settings->SetWithoutPathExpansion(key,
493 Value::CreateStringValue(value)); 518 Value::CreateStringValue(value));
494 } 519 }
495 520
496 void RenderViewHostDelegateHelper::ClearInspectorSettings( 521 void RenderViewHostDelegateHelper::ClearInspectorSettings(
497 content::BrowserContext* browser_context) { 522 content::BrowserContext* browser_context) {
498 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 523 Profile::FromBrowserContext(browser_context)->GetPrefs()->
499 ClearPref(prefs::kWebKitInspectorSettings); 524 ClearPref(prefs::kWebKitInspectorSettings);
500 } 525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698