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/chrome_content_browser_client.cc

Issue 439913002: Add a cache for FillFontFamilyMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from thestig. Created 6 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
« no previous file with comments | « no previous file | chrome/browser/font_family_cache.h » ('j') | chrome/browser/font_family_cache.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 32 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
33 #include "chrome/browser/defaults.h" 33 #include "chrome/browser/defaults.h"
34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" 34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
35 #include "chrome/browser/download/download_prefs.h" 35 #include "chrome/browser/download/download_prefs.h"
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" 36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
37 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/extensions/extension_util.h" 38 #include "chrome/browser/extensions/extension_util.h"
39 #include "chrome/browser/extensions/extension_web_ui.h" 39 #include "chrome/browser/extensions/extension_web_ui.h"
40 #include "chrome/browser/extensions/extension_webkit_preferences.h" 40 #include "chrome/browser/extensions/extension_webkit_preferences.h"
41 #include "chrome/browser/extensions/suggest_permission_util.h" 41 #include "chrome/browser/extensions/suggest_permission_util.h"
42 #include "chrome/browser/font_family_cache.h"
42 #include "chrome/browser/geolocation/chrome_access_token_store.h" 43 #include "chrome/browser/geolocation/chrome_access_token_store.h"
43 #include "chrome/browser/geolocation/geolocation_permission_context.h" 44 #include "chrome/browser/geolocation/geolocation_permission_context.h"
44 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 45 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
45 #include "chrome/browser/media/cast_transport_host_filter.h" 46 #include "chrome/browser/media/cast_transport_host_filter.h"
46 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 47 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
47 #include "chrome/browser/media/midi_permission_context.h" 48 #include "chrome/browser/media/midi_permission_context.h"
48 #include "chrome/browser/media/midi_permission_context_factory.h" 49 #include "chrome/browser/media/midi_permission_context_factory.h"
49 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 50 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
50 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 51 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
51 #include "chrome/browser/net/chrome_net_log.h" 52 #include "chrome/browser/net/chrome_net_log.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return true; 495 return true;
495 496
496 std::string common_name; 497 std::string common_name;
497 if (filter.GetString("ISSUER.CN", &common_name) && 498 if (filter.GetString("ISSUER.CN", &common_name) &&
498 (cert.issuer().common_name == common_name)) { 499 (cert.issuer().common_name == common_name)) {
499 return true; 500 return true;
500 } 501 }
501 return false; 502 return false;
502 } 503 }
503 504
504 #if !defined(OS_ANDROID) 505 #if !defined(OS_ANDROID) && defined(OS_POSIX) && !defined(OS_MACOSX)
Lei Zhang 2014/08/05 21:15:08 nit: #if defined(OS_POSIX) && !defined(OS_MACOSX)
erikchen 2014/08/05 21:34:17 Is the goal to get all the positive conditionals b
Lei Zhang 2014/08/05 21:48:55 Yes, it's more readable.
505 // Fills |map| with the per-script font prefs under path |map_name|.
506 void FillFontFamilyMap(const PrefService* prefs,
507 const char* map_name,
508 content::ScriptFontFamilyMap* map) {
509 // TODO(falken): Get rid of the brute-force scan over possible
510 // (font family / script) combinations - see http://crbug.com/308095.
511 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
512 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
513 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
514 std::string font_family = prefs->GetString(pref_name.c_str());
515 if (!font_family.empty())
516 (*map)[script] = base::UTF8ToUTF16(font_family);
517 }
518 }
519
520 #if defined(OS_POSIX) && !defined(OS_MACOSX)
521 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( 506 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
522 const std::string& process_type) { 507 const std::string& process_type) {
523 base::FilePath dumps_path; 508 base::FilePath dumps_path;
524 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); 509 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
525 { 510 {
526 ANNOTATE_SCOPED_MEMORY_LEAK; 511 ANNOTATE_SCOPED_MEMORY_LEAK;
527 bool upload = (getenv(env_vars::kHeadless) == NULL); 512 bool upload = (getenv(env_vars::kHeadless) == NULL);
528 breakpad::CrashHandlerHostLinux* crash_handler = 513 breakpad::CrashHandlerHostLinux* crash_handler =
529 new breakpad::CrashHandlerHostLinux(process_type, dumps_path, upload); 514 new breakpad::CrashHandlerHostLinux(process_type, dumps_path, upload);
530 crash_handler->StartUploaderThread(); 515 crash_handler->StartUploaderThread();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 552
568 if (process_type == switches::kGpuProcess) { 553 if (process_type == switches::kGpuProcess) {
569 static breakpad::CrashHandlerHostLinux* crash_handler = NULL; 554 static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
570 if (!crash_handler) 555 if (!crash_handler)
571 crash_handler = CreateCrashHandlerHost(process_type); 556 crash_handler = CreateCrashHandlerHost(process_type);
572 return crash_handler->GetDeathSignalSocket(); 557 return crash_handler->GetDeathSignalSocket();
573 } 558 }
574 559
575 return -1; 560 return -1;
576 } 561 }
577 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 562 #endif // !defined(OS_ANDROID) && defined(OS_POSIX) && !defined(OS_MACOSX)
578 #endif // !defined(OS_ANDROID)
579 563
580 #if !defined(OS_CHROMEOS) 564 #if !defined(OS_CHROMEOS)
581 GURL GetEffectiveURLForSignin(const GURL& url) { 565 GURL GetEffectiveURLForSignin(const GURL& url) {
582 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); 566 CHECK(SigninManager::IsWebBasedSigninFlowURL(url));
583 567
584 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); 568 GURL effective_url(SigninManager::kChromeSigninEffectiveSite);
585 // Copy the path because the argument to SetPathStr must outlive 569 // Copy the path because the argument to SetPathStr must outlive
586 // the Replacements object. 570 // the Replacements object.
587 const std::string path_copy(url.path()); 571 const std::string path_copy(url.path());
588 GURL::Replacements replacements; 572 GURL::Replacements replacements;
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 2400
2417 void ChromeContentBrowserClient::OverrideWebkitPrefs( 2401 void ChromeContentBrowserClient::OverrideWebkitPrefs(
2418 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) { 2402 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) {
2419 Profile* profile = Profile::FromBrowserContext( 2403 Profile* profile = Profile::FromBrowserContext(
2420 rvh->GetProcess()->GetBrowserContext()); 2404 rvh->GetProcess()->GetBrowserContext());
2421 PrefService* prefs = profile->GetPrefs(); 2405 PrefService* prefs = profile->GetPrefs();
2422 2406
2423 // Fill per-script font preferences. These are not registered on Android 2407 // Fill per-script font preferences. These are not registered on Android
2424 // - http://crbug.com/308033. 2408 // - http://crbug.com/308033.
2425 #if !defined(OS_ANDROID) 2409 #if !defined(OS_ANDROID)
2426 FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, 2410 FontFamilyCache::FillFontFamilyMap(profile,
2427 &web_prefs->standard_font_family_map); 2411 prefs::kWebKitStandardFontFamilyMap,
2428 FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, 2412 &web_prefs->standard_font_family_map);
2429 &web_prefs->fixed_font_family_map); 2413 FontFamilyCache::FillFontFamilyMap(profile,
2430 FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, 2414 prefs::kWebKitFixedFontFamilyMap,
2431 &web_prefs->serif_font_family_map); 2415 &web_prefs->fixed_font_family_map);
2432 FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, 2416 FontFamilyCache::FillFontFamilyMap(profile,
2433 &web_prefs->sans_serif_font_family_map); 2417 prefs::kWebKitSerifFontFamilyMap,
2434 FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, 2418 &web_prefs->serif_font_family_map);
2435 &web_prefs->cursive_font_family_map); 2419 FontFamilyCache::FillFontFamilyMap(profile,
2436 FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, 2420 prefs::kWebKitSansSerifFontFamilyMap,
2437 &web_prefs->fantasy_font_family_map); 2421 &web_prefs->sans_serif_font_family_map);
2438 FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap, 2422 FontFamilyCache::FillFontFamilyMap(profile,
2439 &web_prefs->pictograph_font_family_map); 2423 prefs::kWebKitCursiveFontFamilyMap,
2424 &web_prefs->cursive_font_family_map);
2425 FontFamilyCache::FillFontFamilyMap(profile,
2426 prefs::kWebKitFantasyFontFamilyMap,
2427 &web_prefs->fantasy_font_family_map);
2428 FontFamilyCache::FillFontFamilyMap(profile,
2429 prefs::kWebKitPictographFontFamilyMap,
2430 &web_prefs->pictograph_font_family_map);
2440 #endif 2431 #endif
2441 2432
2442 web_prefs->default_font_size = 2433 web_prefs->default_font_size =
2443 prefs->GetInteger(prefs::kWebKitDefaultFontSize); 2434 prefs->GetInteger(prefs::kWebKitDefaultFontSize);
2444 web_prefs->default_fixed_font_size = 2435 web_prefs->default_fixed_font_size =
2445 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); 2436 prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);
2446 web_prefs->minimum_font_size = 2437 web_prefs->minimum_font_size =
2447 prefs->GetInteger(prefs::kWebKitMinimumFontSize); 2438 prefs->GetInteger(prefs::kWebKitMinimumFontSize);
2448 web_prefs->minimum_logical_font_size = 2439 web_prefs->minimum_logical_font_size =
2449 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); 2440 prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 switches::kDisableWebRtcEncryption, 2941 switches::kDisableWebRtcEncryption,
2951 }; 2942 };
2952 to_command_line->CopySwitchesFrom(from_command_line, 2943 to_command_line->CopySwitchesFrom(from_command_line,
2953 kWebRtcDevSwitchNames, 2944 kWebRtcDevSwitchNames,
2954 arraysize(kWebRtcDevSwitchNames)); 2945 arraysize(kWebRtcDevSwitchNames));
2955 } 2946 }
2956 } 2947 }
2957 #endif // defined(ENABLE_WEBRTC) 2948 #endif // defined(ENABLE_WEBRTC)
2958 2949
2959 } // namespace chrome 2950 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/font_family_cache.h » ('j') | chrome/browser/font_family_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698