Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Fills |map| with the per-script font prefs under path |map_name|. | |
| 303 static void FillFontFamilyMap(const PrefService* prefs, | |
|
brettw
2011/08/22 23:23:28
Don't put static functions in the middle of the fi
falken
2011/08/23 12:05:53
Done.
| |
| 304 const char* map_name, | |
| 305 WebPreferences::ScriptFontFamilyMap* map) { | |
| 306 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | |
| 307 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | |
| 308 const char* pref_name = | |
| 309 base::StringPrintf("%s.%s", map_name, script).c_str(); | |
|
brettw
2011/08/22 23:23:28
This is wrong, the temporary string returned by st
falken
2011/08/23 12:05:53
Oops. Done.
| |
| 310 std::string font_family = prefs->GetString(pref_name); | |
| 311 if (!font_family.empty()) | |
| 312 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family))); | |
| 313 } | |
| 314 } | |
| 315 | |
| 302 // static | 316 // static |
| 303 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( | 317 WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( |
| 304 content::BrowserContext* browser_context, bool is_web_ui) { | 318 content::BrowserContext* browser_context, bool is_web_ui) { |
| 305 Profile* profile = Profile::FromBrowserContext(browser_context); | 319 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 306 PrefService* prefs = profile->GetPrefs(); | 320 PrefService* prefs = profile->GetPrefs(); |
| 307 WebPreferences web_prefs; | 321 WebPreferences web_prefs; |
| 308 | 322 |
| 309 web_prefs.standard_font_family = | 323 web_prefs.standard_font_family = |
| 310 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); | 324 UTF8ToUTF16(prefs->GetString(prefs::kWebKitStandardFontFamily)); |
| 311 web_prefs.fixed_font_family = | 325 web_prefs.fixed_font_family = |
| 312 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); | 326 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); |
| 313 web_prefs.serif_font_family = | 327 web_prefs.serif_font_family = |
| 314 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); | 328 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); |
| 315 web_prefs.sans_serif_font_family = | 329 web_prefs.sans_serif_font_family = |
| 316 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); | 330 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); |
| 317 web_prefs.cursive_font_family = | 331 web_prefs.cursive_font_family = |
| 318 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); | 332 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); |
| 319 web_prefs.fantasy_font_family = | 333 web_prefs.fantasy_font_family = |
| 320 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); | 334 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); |
| 321 | 335 |
| 336 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, | |
| 337 &web_prefs.standard_font_family_map); | |
| 338 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, | |
| 339 &web_prefs.fixed_font_family_map); | |
| 340 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, | |
| 341 &web_prefs.serif_font_family_map); | |
| 342 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, | |
| 343 &web_prefs.sans_serif_font_family_map); | |
| 344 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, | |
| 345 &web_prefs.cursive_font_family_map); | |
| 346 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, | |
| 347 &web_prefs.fantasy_font_family_map); | |
| 348 | |
| 322 web_prefs.default_font_size = | 349 web_prefs.default_font_size = |
| 323 prefs->GetInteger(prefs::kWebKitDefaultFontSize); | 350 prefs->GetInteger(prefs::kWebKitDefaultFontSize); |
| 324 web_prefs.default_fixed_font_size = | 351 web_prefs.default_fixed_font_size = |
| 325 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); | 352 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); |
| 326 web_prefs.minimum_font_size = | 353 web_prefs.minimum_font_size = |
| 327 prefs->GetInteger(prefs::kWebKitMinimumFontSize); | 354 prefs->GetInteger(prefs::kWebKitMinimumFontSize); |
| 328 web_prefs.minimum_logical_font_size = | 355 web_prefs.minimum_logical_font_size = |
| 329 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); | 356 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); |
| 330 | 357 |
| 331 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); | 358 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 DictionaryValue* inspector_settings = update.Get(); | 518 DictionaryValue* inspector_settings = update.Get(); |
| 492 inspector_settings->SetWithoutPathExpansion(key, | 519 inspector_settings->SetWithoutPathExpansion(key, |
| 493 Value::CreateStringValue(value)); | 520 Value::CreateStringValue(value)); |
| 494 } | 521 } |
| 495 | 522 |
| 496 void RenderViewHostDelegateHelper::ClearInspectorSettings( | 523 void RenderViewHostDelegateHelper::ClearInspectorSettings( |
| 497 content::BrowserContext* browser_context) { | 524 content::BrowserContext* browser_context) { |
| 498 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 525 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
| 499 ClearPref(prefs::kWebKitInspectorSettings); | 526 ClearPref(prefs::kWebKitInspectorSettings); |
| 500 } | 527 } |
| OLD | NEW |