| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_FONT_WARMUP_WIN_H_ | |
| 6 #define CONTENT_COMMON_FONT_WARMUP_WIN_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 class SkFontMgr; | |
| 15 class SkTypeface; | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 // Make necessary calls to cache the data for a given font, used before | |
| 20 // sandbox lockdown. | |
| 21 CONTENT_EXPORT void DoPreSandboxWarmupForTypeface(SkTypeface* typeface); | |
| 22 | |
| 23 // Get the shared font manager used during pre-sandbox warmup for DirectWrite | |
| 24 // fonts. | |
| 25 CONTENT_EXPORT SkFontMgr* GetPreSandboxWarmupFontMgr(); | |
| 26 | |
| 27 class GdiFontPatchData { | |
| 28 public: | |
| 29 virtual ~GdiFontPatchData() {} | |
| 30 | |
| 31 protected: | |
| 32 GdiFontPatchData() {} | |
| 33 | |
| 34 private: | |
| 35 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); | |
| 36 }; | |
| 37 | |
| 38 // Hook a module's imported GDI font functions to reimplement font enumeration | |
| 39 // and font data retrieval for DLLs which can't be easily modified. | |
| 40 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( | |
| 41 const base::FilePath& path); | |
| 42 | |
| 43 // Testing method to get the number of in-flight emulated GDI handles. | |
| 44 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); | |
| 45 | |
| 46 // Testing method to reset the table of emulated GDI handles. | |
| 47 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); | |
| 48 | |
| 49 // Sets the pre-sandbox warmup font manager directly. This should only be used | |
| 50 // for testing the implementation. | |
| 51 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); | |
| 52 | |
| 53 // Warmup the direct write font manager for content processes. | |
| 54 CONTENT_EXPORT void WarmupDirectWrite(); | |
| 55 | |
| 56 // Directwrite connects to the font cache service to retrieve information about | |
| 57 // fonts installed on the system etc. This works well outside the sandbox and | |
| 58 // within the sandbox as long as the lpc connection maintained by the current | |
| 59 // process with the font cache service remains valid. It appears that there | |
| 60 // are cases when this connection is dropped after which directwrite is unable | |
| 61 // to connect to the font cache service which causes problems with characters | |
| 62 // disappearing. | |
| 63 // Directwrite has fallback code to enumerate fonts if it is unable to connect | |
| 64 // to the font cache service. We need to intercept the following APIs to | |
| 65 // ensure that it does not connect to the font cache service. | |
| 66 // NtALpcConnectPort | |
| 67 // OpenSCManagerW | |
| 68 // OpenServiceW | |
| 69 // StartServiceW | |
| 70 // CloseServiceHandle. | |
| 71 // These are all IAT patched. | |
| 72 CONTENT_EXPORT void PatchServiceManagerCalls(); | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_COMMON_FONT_WARMUP_WIN_H_ | |
| OLD | NEW |