| OLD | NEW |
| 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 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "chrome/installer/util/browser_distribution.h" | 49 #include "chrome/installer/util/browser_distribution.h" |
| 50 #include "chrome/installer/util/helper.h" | 50 #include "chrome/installer/util/helper.h" |
| 51 #include "chrome/installer/util/install_util.h" | 51 #include "chrome/installer/util/install_util.h" |
| 52 #include "chrome/installer/util/installer_util_strings.h" | 52 #include "chrome/installer/util/installer_util_strings.h" |
| 53 #include "chrome/installer/util/l10n_string_util.h" | 53 #include "chrome/installer/util/l10n_string_util.h" |
| 54 #include "chrome/installer/util/shell_util.h" | 54 #include "chrome/installer/util/shell_util.h" |
| 55 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
| 56 #include "content/public/browser/utility_process_host.h" | 56 #include "content/public/browser/utility_process_host.h" |
| 57 #include "content/public/browser/utility_process_host_client.h" | 57 #include "content/public/browser/utility_process_host_client.h" |
| 58 #include "content/public/common/content_switches.h" | 58 #include "content/public/common/content_switches.h" |
| 59 #include "content/public/common/dwrite_font_platform_win.h" | |
| 60 #include "content/public/common/main_function_params.h" | 59 #include "content/public/common/main_function_params.h" |
| 61 #include "ui/base/cursor/cursor_loader_win.h" | 60 #include "ui/base/cursor/cursor_loader_win.h" |
| 62 #include "ui/base/l10n/l10n_util.h" | 61 #include "ui/base/l10n/l10n_util.h" |
| 63 #include "ui/base/l10n/l10n_util_win.h" | 62 #include "ui/base/l10n/l10n_util_win.h" |
| 64 #include "ui/base/ui_base_switches.h" | 63 #include "ui/base/ui_base_switches.h" |
| 65 #include "ui/base/win/message_box_win.h" | 64 #include "ui/base/win/message_box_win.h" |
| 66 #include "ui/gfx/platform_font_win.h" | 65 #include "ui/gfx/platform_font_win.h" |
| 67 #include "ui/gfx/switches.h" | 66 #include "ui/gfx/switches.h" |
| 68 #include "ui/gfx/win/direct_write.h" | |
| 69 #include "ui/strings/grit/app_locale_settings.h" | 67 #include "ui/strings/grit/app_locale_settings.h" |
| 70 | 68 |
| 71 #if defined(GOOGLE_CHROME_BUILD) | 69 #if defined(GOOGLE_CHROME_BUILD) |
| 72 #include "chrome/browser/google/did_run_updater_win.h" | 70 #include "chrome/browser/google/did_run_updater_win.h" |
| 73 #endif | 71 #endif |
| 74 | 72 |
| 75 #if BUILDFLAG(ENABLE_KASKO) | 73 #if BUILDFLAG(ENABLE_KASKO) |
| 76 #include "syzygy/kasko/api/reporter.h" | 74 #include "syzygy/kasko/api/reporter.h" |
| 77 #endif | 75 #endif |
| 78 | 76 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), | 101 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), |
| 104 &min_font_size); | 102 &min_font_size); |
| 105 return min_font_size; | 103 return min_font_size; |
| 106 } | 104 } |
| 107 | 105 |
| 108 class TranslationDelegate : public installer::TranslationDelegate { | 106 class TranslationDelegate : public installer::TranslationDelegate { |
| 109 public: | 107 public: |
| 110 base::string16 GetLocalizedString(int installer_string_id) override; | 108 base::string16 GetLocalizedString(int installer_string_id) override; |
| 111 }; | 109 }; |
| 112 | 110 |
| 113 void ExecuteFontCacheBuildTask(const base::FilePath& path) { | |
| 114 base::WeakPtr<content::UtilityProcessHost> utility_process_host( | |
| 115 content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr()); | |
| 116 utility_process_host->SetName( | |
| 117 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME)); | |
| 118 utility_process_host->DisableSandbox(); | |
| 119 utility_process_host->Send( | |
| 120 new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path)); | |
| 121 } | |
| 122 | |
| 123 #if BUILDFLAG(ENABLE_KASKO) | 111 #if BUILDFLAG(ENABLE_KASKO) |
| 124 void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) { | 112 void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) { |
| 125 DCHECK(!error); | 113 DCHECK(!error); |
| 126 if (error) | 114 if (error) |
| 127 return; | 115 return; |
| 128 base::FileEnumerator enumerator(path, true, base::FileEnumerator::FILES); | 116 base::FileEnumerator enumerator(path, true, base::FileEnumerator::FILES); |
| 129 for (base::FilePath report_file = enumerator.Next(); !report_file.empty(); | 117 for (base::FilePath report_file = enumerator.Next(); !report_file.empty(); |
| 130 report_file = enumerator.Next()) { | 118 report_file = enumerator.Next()) { |
| 131 if (report_file.Extension() == | 119 if (report_file.Extension() == |
| 132 kasko::api::kPermanentFailureMinidumpExtension) { | 120 kasko::api::kPermanentFailureMinidumpExtension) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 305 |
| 318 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { | 306 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { |
| 319 ui::MessageBox(NULL, | 307 ui::MessageBox(NULL, |
| 320 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), | 308 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), |
| 321 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), | 309 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), |
| 322 MB_OK | MB_ICONERROR | MB_TOPMOST); | 310 MB_OK | MB_ICONERROR | MB_TOPMOST); |
| 323 } | 311 } |
| 324 | 312 |
| 325 void ChromeBrowserMainPartsWin::PostProfileInit() { | 313 void ChromeBrowserMainPartsWin::PostProfileInit() { |
| 326 ChromeBrowserMainParts::PostProfileInit(); | 314 ChromeBrowserMainParts::PostProfileInit(); |
| 327 | |
| 328 // DirectWrite support is mainly available Windows 7 and up. | |
| 329 // Skip loading the font cache if we are using the font proxy field trial. | |
| 330 if (gfx::win::ShouldUseDirectWrite() && | |
| 331 !content::ShouldUseDirectWriteFontProxyFieldTrial()) { | |
| 332 base::FilePath path( | |
| 333 profile()->GetPath().AppendASCII(content::kFontCacheSharedSectionName)); | |
| 334 // This function will create a read only section if cache file exists | |
| 335 // otherwise it will spawn utility process to build cache file, which will | |
| 336 // be used during next browser start/postprofileinit. | |
| 337 if (!content::LoadFontCache(path)) { | |
| 338 // We delay building of font cache until first startup page loads. | |
| 339 // During first renderer start there are lot of things happening | |
| 340 // simultaneously some of them are: | |
| 341 // - Renderer is going through all font files on the system to create a | |
| 342 // font collection. | |
| 343 // - Renderer loading up startup URL, accessing HTML/JS File cache, net | |
| 344 // activity etc. | |
| 345 // - Extension initialization. | |
| 346 // We delay building of cache mainly to avoid parallel font file loading | |
| 347 // along with Renderer. Some systems have significant number of font files | |
| 348 // which takes long time to process. | |
| 349 // Related information is at http://crbug.com/436195. | |
| 350 const int kBuildFontCacheDelaySec = 30; | |
| 351 content::BrowserThread::PostDelayedTask( | |
| 352 content::BrowserThread::IO, | |
| 353 FROM_HERE, | |
| 354 base::Bind(ExecuteFontCacheBuildTask, path), | |
| 355 base::TimeDelta::FromSeconds(kBuildFontCacheDelaySec)); | |
| 356 } | |
| 357 } | |
| 358 } | 315 } |
| 359 | 316 |
| 360 void ChromeBrowserMainPartsWin::PostBrowserStart() { | 317 void ChromeBrowserMainPartsWin::PostBrowserStart() { |
| 361 ChromeBrowserMainParts::PostBrowserStart(); | 318 ChromeBrowserMainParts::PostBrowserStart(); |
| 362 | 319 |
| 363 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice(nullptr)); | 320 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice(nullptr)); |
| 364 | 321 |
| 365 // Set up a task to verify installed modules in the current process. | 322 // Set up a task to verify installed modules in the current process. |
| 366 content::BrowserThread::PostAfterStartupTask( | 323 content::BrowserThread::PostAfterStartupTask( |
| 367 FROM_HERE, content::BrowserThread::GetBlockingPool(), | 324 FROM_HERE, content::BrowserThread::GetBlockingPool(), |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (resource_id) | 511 if (resource_id) |
| 555 return l10n_util::GetStringUTF16(resource_id); | 512 return l10n_util::GetStringUTF16(resource_id); |
| 556 return base::string16(); | 513 return base::string16(); |
| 557 } | 514 } |
| 558 | 515 |
| 559 // static | 516 // static |
| 560 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { | 517 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { |
| 561 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); | 518 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); |
| 562 installer::SetTranslationDelegate(&delegate); | 519 installer::SetTranslationDelegate(&delegate); |
| 563 } | 520 } |
| OLD | NEW |