OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 5 #ifndef CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
6 #define CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 6 #define CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
14 class SkFontMgr; | 14 class SkFontMgr; |
15 class SkTypeface; | 15 class SkTypeface; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 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 { | 19 class GdiFontPatchData { |
28 public: | 20 public: |
29 virtual ~GdiFontPatchData() {} | 21 virtual ~GdiFontPatchData() {} |
30 | 22 |
31 protected: | 23 protected: |
32 GdiFontPatchData() {} | 24 GdiFontPatchData() {} |
33 | 25 |
34 private: | 26 private: |
35 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); | 27 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); |
36 }; | 28 }; |
37 | 29 |
38 // Hook a module's imported GDI font functions to reimplement font enumeration | 30 // 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. | 31 // and font data retrieval for DLLs which can't be easily modified. |
40 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( | 32 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( |
41 const base::FilePath& path); | 33 const base::FilePath& path); |
42 | 34 |
43 // Testing method to get the number of in-flight emulated GDI handles. | 35 // Testing method to get the number of in-flight emulated GDI handles. |
44 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); | 36 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); |
45 | 37 |
46 // Testing method to reset the table of emulated GDI handles. | 38 // Testing method to reset the table of emulated GDI handles. |
47 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); | 39 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); |
48 | 40 |
49 // Sets the pre-sandbox warmup font manager directly. This should only be used | 41 // Sets the pre-sandbox warmup font manager directly. This should only be used |
50 // for testing the implementation. | 42 // for testing the implementation. |
51 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); | 43 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); |
52 | 44 |
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 | 45 // 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 | 46 // 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 | 47 // 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 | 48 // 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 | 49 // 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 | 50 // to connect to the font cache service which causes problems with characters |
62 // disappearing. | 51 // disappearing. |
63 // Directwrite has fallback code to enumerate fonts if it is unable to connect | 52 // 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 | 53 // 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. | 54 // ensure that it does not connect to the font cache service. |
66 // NtALpcConnectPort | 55 // NtALpcConnectPort |
67 // OpenSCManagerW | 56 // OpenSCManagerW |
68 // OpenServiceW | 57 // OpenServiceW |
69 // StartServiceW | 58 // StartServiceW |
70 // CloseServiceHandle. | 59 // CloseServiceHandle. |
71 // These are all IAT patched. | 60 // These are all IAT patched. |
72 CONTENT_EXPORT void PatchServiceManagerCalls(); | 61 CONTENT_EXPORT void PatchServiceManagerCalls(); |
73 | 62 |
74 } // namespace content | 63 } // namespace content |
75 | 64 |
76 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 65 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
OLD | NEW |