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

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

Issue 729103002: Revert of DirectWrite Font Cache browser side hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
16 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
17 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
18 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 18 #include "base/path_service.h"
20 #include "base/scoped_native_library.h" 19 #include "base/scoped_native_library.h"
21 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
23 #include "base/win/metro.h" 22 #include "base/win/metro.h"
24 #include "base/win/win_util.h" 23 #include "base/win/win_util.h"
25 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
26 #include "base/win/wrapped_window_proc.h" 25 #include "base/win/wrapped_window_proc.h"
27 #include "chrome/browser/browser_util_win.h" 26 #include "chrome/browser/browser_util_win.h"
28 #include "chrome/browser/chrome_elf_init_win.h" 27 #include "chrome/browser/chrome_elf_init_win.h"
29 #include "chrome/browser/first_run/first_run.h" 28 #include "chrome/browser/first_run/first_run.h"
30 #include "chrome/browser/install_verification/win/install_verification.h" 29 #include "chrome/browser/install_verification/win/install_verification.h"
31 #include "chrome/browser/prefs/incognito_mode_prefs.h" 30 #include "chrome/browser/prefs/incognito_mode_prefs.h"
32 #include "chrome/browser/profiles/profile_info_cache.h" 31 #include "chrome/browser/profiles/profile_info_cache.h"
33 #include "chrome/browser/profiles/profile_shortcut_manager.h" 32 #include "chrome/browser/profiles/profile_shortcut_manager.h"
34 #include "chrome/browser/shell_integration.h" 33 #include "chrome/browser/shell_integration.h"
35 #include "chrome/browser/ui/simple_message_box.h" 34 #include "chrome/browser/ui/simple_message_box.h"
36 #include "chrome/browser/ui/uninstall_browser_prompt.h" 35 #include "chrome/browser/ui/uninstall_browser_prompt.h"
37 #include "chrome/common/chrome_constants.h" 36 #include "chrome/common/chrome_constants.h"
38 #include "chrome/common/chrome_result_codes.h" 37 #include "chrome/common/chrome_result_codes.h"
39 #include "chrome/common/chrome_switches.h" 38 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/chrome_utility_messages.h"
41 #include "chrome/common/chrome_version_info.h" 39 #include "chrome/common/chrome_version_info.h"
42 #include "chrome/common/env_vars.h" 40 #include "chrome/common/env_vars.h"
43 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h" 41 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h"
44 #include "chrome/grit/chromium_strings.h" 42 #include "chrome/grit/chromium_strings.h"
45 #include "chrome/grit/generated_resources.h" 43 #include "chrome/grit/generated_resources.h"
46 #include "chrome/installer/util/browser_distribution.h" 44 #include "chrome/installer/util/browser_distribution.h"
47 #include "chrome/installer/util/helper.h" 45 #include "chrome/installer/util/helper.h"
48 #include "chrome/installer/util/install_util.h" 46 #include "chrome/installer/util/install_util.h"
49 #include "chrome/installer/util/l10n_string_util.h" 47 #include "chrome/installer/util/l10n_string_util.h"
50 #include "chrome/installer/util/shell_util.h" 48 #include "chrome/installer/util/shell_util.h"
51 #include "content/public/browser/browser_thread.h" 49 #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"
54 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
55 #include "content/public/common/dwrite_font_platform_win.h"
56 #include "content/public/common/main_function_params.h" 51 #include "content/public/common/main_function_params.h"
57 #include "installer_util_strings/installer_util_strings.h" 52 #include "installer_util_strings/installer_util_strings.h"
58 #include "ui/base/cursor/cursor_loader_win.h" 53 #include "ui/base/cursor/cursor_loader_win.h"
59 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
60 #include "ui/base/l10n/l10n_util_win.h" 55 #include "ui/base/l10n/l10n_util_win.h"
61 #include "ui/base/ui_base_switches.h" 56 #include "ui/base/ui_base_switches.h"
62 #include "ui/base/win/message_box_win.h" 57 #include "ui/base/win/message_box_win.h"
63 #include "ui/gfx/platform_font_win.h" 58 #include "ui/gfx/platform_font_win.h"
64 #include "ui/gfx/switches.h" 59 #include "ui/gfx/switches.h"
65 #include "ui/gfx/win/direct_write.h"
66 #include "ui/strings/grit/app_locale_settings.h" 60 #include "ui/strings/grit/app_locale_settings.h"
67 61
68 namespace { 62 namespace {
69 63
70 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( 64 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)(
71 const wchar_t* command_line, 65 const wchar_t* command_line,
72 DWORD flags); 66 DWORD flags);
73 67
74 void InitializeWindowProcExceptions() { 68 void InitializeWindowProcExceptions() {
75 // Get the breakpad pointer from chrome.exe 69 // Get the breakpad pointer from chrome.exe
(...skipping 20 matching lines...) Expand all
96 90
97 class TranslationDelegate : public installer::TranslationDelegate { 91 class TranslationDelegate : public installer::TranslationDelegate {
98 public: 92 public:
99 virtual base::string16 GetLocalizedString(int installer_string_id) override; 93 virtual base::string16 GetLocalizedString(int installer_string_id) override;
100 }; 94 };
101 95
102 bool IsSafeModeStart() { 96 bool IsSafeModeStart() {
103 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0; 97 return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0;
104 } 98 }
105 99
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
114 } // namespace 100 } // namespace
115 101
116 void ShowCloseBrowserFirstMessageBox() { 102 void ShowCloseBrowserFirstMessageBox() {
117 int message_id = IDS_UNINSTALL_CLOSE_APP; 103 int message_id = IDS_UNINSTALL_CLOSE_APP;
118 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && 104 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
119 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) { 105 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) {
120 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE; 106 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE;
121 } 107 }
122 chrome::ShowMessageBox(NULL, 108 chrome::ShowMessageBox(NULL,
123 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 109 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return rv; 237 return rv;
252 } 238 }
253 239
254 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { 240 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() {
255 ui::MessageBox(NULL, 241 ui::MessageBox(NULL,
256 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), 242 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage),
257 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), 243 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle),
258 MB_OK | MB_ICONERROR | MB_TOPMOST); 244 MB_OK | MB_ICONERROR | MB_TOPMOST);
259 } 245 }
260 246
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
279 void ChromeBrowserMainPartsWin::PostBrowserStart() { 247 void ChromeBrowserMainPartsWin::PostBrowserStart() {
280 ChromeBrowserMainParts::PostBrowserStart(); 248 ChromeBrowserMainParts::PostBrowserStart();
281 249
282 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice()); 250 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice());
283 251
284 // Set up a task to verify installed modules in the current process. Use a 252 // Set up a task to verify installed modules in the current process. Use a
285 // delay to reduce the impact on startup time. 253 // delay to reduce the impact on startup time.
286 content::BrowserThread::GetMessageLoopProxyForThread( 254 content::BrowserThread::GetMessageLoopProxyForThread(
287 content::BrowserThread::UI)->PostDelayedTask( 255 content::BrowserThread::UI)->PostDelayedTask(
288 FROM_HERE, 256 FROM_HERE,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (resource_id) 444 if (resource_id)
477 return l10n_util::GetStringUTF16(resource_id); 445 return l10n_util::GetStringUTF16(resource_id);
478 return base::string16(); 446 return base::string16();
479 } 447 }
480 448
481 // static 449 // static
482 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { 450 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() {
483 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); 451 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ());
484 installer::SetTranslationDelegate(&delegate); 452 installer::SetTranslationDelegate(&delegate);
485 } 453 }
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