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

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 brettw's comments 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 20 matching lines...) Expand all
31 #include "content/browser/site_instance.h" 31 #include "content/browser/site_instance.h"
32 #include "content/browser/tab_contents/navigation_details.h" 32 #include "content/browser/tab_contents/navigation_details.h"
33 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
34 #include "content/browser/tab_contents/tab_contents_delegate.h" 34 #include "content/browser/tab_contents/tab_contents_delegate.h"
35 #include "content/browser/tab_contents/tab_contents_view.h" 35 #include "content/browser/tab_contents/tab_contents_view.h"
36 #include "content/browser/webui/web_ui.h" 36 #include "content/browser/webui/web_ui.h"
37 #include "content/common/notification_service.h" 37 #include "content/common/notification_service.h"
38 #include "content/common/view_messages.h" 38 #include "content/common/view_messages.h"
39 #include "net/base/network_change_notifier.h" 39 #include "net/base/network_change_notifier.h"
40 40
41 namespace {
42
43 // Fills |map| with the per-script font prefs under path |map_name|.
44 void FillFontFamilyMap(const PrefService* prefs,
45 const char* map_name,
46 WebPreferences::ScriptFontFamilyMap* map) {
47 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
48 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
49 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
50 std::string font_family = prefs->GetString(pref_name.c_str());
51 if (!font_family.empty())
52 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
53 }
54 }
55
56 } // namespace
brettw 2011/08/23 17:19:58 Two spaces before //
57
58
41 RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() { 59 RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() {
42 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 60 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
43 NotificationService::AllSources()); 61 NotificationService::AllSources());
44 } 62 }
45 63
46 RenderViewHostDelegateViewHelper::~RenderViewHostDelegateViewHelper() {} 64 RenderViewHostDelegateViewHelper::~RenderViewHostDelegateViewHelper() {}
47 65
48 void RenderViewHostDelegateViewHelper::Observe( 66 void RenderViewHostDelegateViewHelper::Observe(
49 int type, 67 int type,
50 const NotificationSource& source, 68 const NotificationSource& source,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); 330 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily));
313 web_prefs.serif_font_family = 331 web_prefs.serif_font_family =
314 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); 332 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily));
315 web_prefs.sans_serif_font_family = 333 web_prefs.sans_serif_font_family =
316 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); 334 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily));
317 web_prefs.cursive_font_family = 335 web_prefs.cursive_font_family =
318 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); 336 UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily));
319 web_prefs.fantasy_font_family = 337 web_prefs.fantasy_font_family =
320 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); 338 UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily));
321 339
340 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
341 &web_prefs.standard_font_family_map);
342 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
343 &web_prefs.fixed_font_family_map);
344 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
345 &web_prefs.serif_font_family_map);
346 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
347 &web_prefs.sans_serif_font_family_map);
348 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
349 &web_prefs.cursive_font_family_map);
350 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
351 &web_prefs.fantasy_font_family_map);
352
322 web_prefs.default_font_size = 353 web_prefs.default_font_size =
323 prefs->GetInteger(prefs::kWebKitDefaultFontSize); 354 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
324 web_prefs.default_fixed_font_size = 355 web_prefs.default_fixed_font_size =
325 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); 356 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
326 web_prefs.minimum_font_size = 357 web_prefs.minimum_font_size =
327 prefs->GetInteger(prefs::kWebKitMinimumFontSize); 358 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
328 web_prefs.minimum_logical_font_size = 359 web_prefs.minimum_logical_font_size =
329 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); 360 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
330 361
331 web_prefs.default_encoding = prefs->GetString(prefs::kDefaultCharset); 362 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(); 522 DictionaryValue* inspector_settings = update.Get();
492 inspector_settings->SetWithoutPathExpansion(key, 523 inspector_settings->SetWithoutPathExpansion(key,
493 Value::CreateStringValue(value)); 524 Value::CreateStringValue(value));
494 } 525 }
495 526
496 void RenderViewHostDelegateHelper::ClearInspectorSettings( 527 void RenderViewHostDelegateHelper::ClearInspectorSettings(
497 content::BrowserContext* browser_context) { 528 content::BrowserContext* browser_context) {
498 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 529 Profile::FromBrowserContext(browser_context)->GetPrefs()->
499 ClearPref(prefs::kWebKitInspectorSettings); 530 ClearPref(prefs::kWebKitInspectorSettings);
500 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698