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

Side by Side Diff: chrome/browser/chrome_browser_main_win.cc

Issue 724633002: DirectWrite Font Cache browser side hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enforcing cache file size limit 20MB and reducing cached percentile. Created 6 years, 1 month 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 | « chrome/browser/chrome_browser_main_win.h ('k') | chrome/chrome_utility.gypi » ('j') | no next file with comments »
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_browser_main_win.h" 5 #include "chrome/browser/chrome_browser_main_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/environment.h" 13 #include "base/environment.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h"
15 #include "base/i18n/rtl.h" 16 #include "base/i18n/rtl.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/scoped_native_library.h" 20 #include "base/scoped_native_library.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/win/metro.h" 23 #include "base/win/metro.h"
23 #include "base/win/win_util.h" 24 #include "base/win/win_util.h"
24 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
25 #include "base/win/wrapped_window_proc.h" 26 #include "base/win/wrapped_window_proc.h"
26 #include "chrome/browser/browser_util_win.h" 27 #include "chrome/browser/browser_util_win.h"
27 #include "chrome/browser/chrome_elf_init_win.h" 28 #include "chrome/browser/chrome_elf_init_win.h"
28 #include "chrome/browser/first_run/first_run.h" 29 #include "chrome/browser/first_run/first_run.h"
29 #include "chrome/browser/install_verification/win/install_verification.h" 30 #include "chrome/browser/install_verification/win/install_verification.h"
30 #include "chrome/browser/prefs/incognito_mode_prefs.h" 31 #include "chrome/browser/prefs/incognito_mode_prefs.h"
31 #include "chrome/browser/profiles/profile_info_cache.h" 32 #include "chrome/browser/profiles/profile_info_cache.h"
32 #include "chrome/browser/profiles/profile_shortcut_manager.h" 33 #include "chrome/browser/profiles/profile_shortcut_manager.h"
33 #include "chrome/browser/shell_integration.h" 34 #include "chrome/browser/shell_integration.h"
34 #include "chrome/browser/ui/simple_message_box.h" 35 #include "chrome/browser/ui/simple_message_box.h"
35 #include "chrome/browser/ui/uninstall_browser_prompt.h" 36 #include "chrome/browser/ui/uninstall_browser_prompt.h"
36 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
37 #include "chrome/common/chrome_result_codes.h" 38 #include "chrome/common/chrome_result_codes.h"
38 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/chrome_utility_messages.h"
39 #include "chrome/common/chrome_version_info.h" 41 #include "chrome/common/chrome_version_info.h"
40 #include "chrome/common/env_vars.h" 42 #include "chrome/common/env_vars.h"
41 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h" 43 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h"
42 #include "chrome/grit/chromium_strings.h" 44 #include "chrome/grit/chromium_strings.h"
43 #include "chrome/grit/generated_resources.h" 45 #include "chrome/grit/generated_resources.h"
44 #include "chrome/installer/util/browser_distribution.h" 46 #include "chrome/installer/util/browser_distribution.h"
45 #include "chrome/installer/util/helper.h" 47 #include "chrome/installer/util/helper.h"
46 #include "chrome/installer/util/install_util.h" 48 #include "chrome/installer/util/install_util.h"
47 #include "chrome/installer/util/l10n_string_util.h" 49 #include "chrome/installer/util/l10n_string_util.h"
48 #include "chrome/installer/util/shell_util.h" 50 #include "chrome/installer/util/shell_util.h"
49 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
52 #include "content/public/browser/utility_process_host.h"
53 #include "content/public/browser/utility_process_host_client.h"
50 #include "content/public/common/content_switches.h" 54 #include "content/public/common/content_switches.h"
55 #include "content/public/common/dwrite_font_platform_win.h"
51 #include "content/public/common/main_function_params.h" 56 #include "content/public/common/main_function_params.h"
52 #include "installer_util_strings/installer_util_strings.h" 57 #include "installer_util_strings/installer_util_strings.h"
53 #include "ui/base/cursor/cursor_loader_win.h" 58 #include "ui/base/cursor/cursor_loader_win.h"
54 #include "ui/base/l10n/l10n_util.h" 59 #include "ui/base/l10n/l10n_util.h"
55 #include "ui/base/l10n/l10n_util_win.h" 60 #include "ui/base/l10n/l10n_util_win.h"
56 #include "ui/base/ui_base_switches.h" 61 #include "ui/base/ui_base_switches.h"
57 #include "ui/base/win/message_box_win.h" 62 #include "ui/base/win/message_box_win.h"
58 #include "ui/gfx/platform_font_win.h" 63 #include "ui/gfx/platform_font_win.h"
59 #include "ui/gfx/switches.h" 64 #include "ui/gfx/switches.h"
65 #include "ui/gfx/win/direct_write.h"
60 #include "ui/strings/grit/app_locale_settings.h" 66 #include "ui/strings/grit/app_locale_settings.h"
61 67
62 namespace { 68 namespace {
63 69
64 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( 70 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)(
65 const wchar_t* command_line, 71 const wchar_t* command_line,
66 DWORD flags); 72 DWORD flags);
67 73
68 void InitializeWindowProcExceptions() { 74 void InitializeWindowProcExceptions() {
69 // Get the breakpad pointer from chrome.exe 75 // Get the breakpad pointer from chrome.exe
(...skipping 20 matching lines...) Expand all
90 96
91 class TranslationDelegate : public installer::TranslationDelegate { 97 class TranslationDelegate : public installer::TranslationDelegate {
92 public: 98 public:
93 virtual base::string16 GetLocalizedString(int installer_string_id) override; 99 virtual base::string16 GetLocalizedString(int installer_string_id) override;
94 }; 100 };
95 101
96 bool IsSafeModeStart() { 102 bool IsSafeModeStart() {
97 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0; 103 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0;
98 } 104 }
99 105
106 void ExecuteFontCacheBuildTask(const base::FilePath& path) {
107 base::WeakPtr<content::UtilityProcessHost> utility_process_host(
108 content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
109 utility_process_host->DisableSandbox();
110 utility_process_host->Send(
111 new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
112 }
113
100 } // namespace 114 } // namespace
101 115
102 void ShowCloseBrowserFirstMessageBox() { 116 void ShowCloseBrowserFirstMessageBox() {
103 int message_id = IDS_UNINSTALL_CLOSE_APP; 117 int message_id = IDS_UNINSTALL_CLOSE_APP;
104 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && 118 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
105 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) { 119 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) {
106 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE; 120 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE;
107 } 121 }
108 chrome::ShowMessageBox(NULL, 122 chrome::ShowMessageBox(NULL,
109 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 123 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return rv; 251 return rv;
238 } 252 }
239 253
240 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { 254 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() {
241 ui::MessageBox(NULL, 255 ui::MessageBox(NULL,
242 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), 256 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage),
243 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), 257 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle),
244 MB_OK | MB_ICONERROR | MB_TOPMOST); 258 MB_OK | MB_ICONERROR | MB_TOPMOST);
245 } 259 }
246 260
261 void ChromeBrowserMainPartsWin::PostProfileInit() {
262 ChromeBrowserMainParts::PostProfileInit();
263
264 // DirectWrite support is mainly available Windows 7 and up.
265 if (gfx::win::ShouldUseDirectWrite()) {
266 base::FilePath path(
267 profile()->GetPath().AppendASCII(content::kFontCacheSharedSectionName));
268 // This function will create a read only section if cache file exists
269 // otherwise it will spawn utility process to build cache file, which will
270 // be used during next browser start/postprofileinit.
271 if (!content::LoadFontCache(path)) {
272 content::BrowserThread::PostTask(
273 content::BrowserThread::IO, FROM_HERE,
274 base::Bind(ExecuteFontCacheBuildTask, path));
275 }
276 }
277 }
278
247 void ChromeBrowserMainPartsWin::PostBrowserStart() { 279 void ChromeBrowserMainPartsWin::PostBrowserStart() {
248 ChromeBrowserMainParts::PostBrowserStart(); 280 ChromeBrowserMainParts::PostBrowserStart();
249 281
250 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice()); 282 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice());
251 283
252 // Set up a task to verify installed modules in the current process. Use a 284 // Set up a task to verify installed modules in the current process. Use a
253 // delay to reduce the impact on startup time. 285 // delay to reduce the impact on startup time.
254 content::BrowserThread::GetMessageLoopProxyForThread( 286 content::BrowserThread::GetMessageLoopProxyForThread(
255 content::BrowserThread::UI)->PostDelayedTask( 287 content::BrowserThread::UI)->PostDelayedTask(
256 FROM_HERE, 288 FROM_HERE,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (resource_id) 476 if (resource_id)
445 return l10n_util::GetStringUTF16(resource_id); 477 return l10n_util::GetStringUTF16(resource_id);
446 return base::string16(); 478 return base::string16();
447 } 479 }
448 480
449 // static 481 // static
450 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { 482 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() {
451 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); 483 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ());
452 installer::SetTranslationDelegate(&delegate); 484 installer::SetTranslationDelegate(&delegate);
453 } 485 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main_win.h ('k') | chrome/chrome_utility.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698