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