| 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 #include "third_party/skia/include/core/SkRefCnt.h" |
| 13 | 14 |
| 14 class SkFontMgr; | 15 class SkFontMgr; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class GdiFontPatchData { | 19 class GdiFontPatchData { |
| 19 public: | 20 public: |
| 20 virtual ~GdiFontPatchData() {} | 21 virtual ~GdiFontPatchData() {} |
| 21 | 22 |
| 22 protected: | 23 protected: |
| 23 GdiFontPatchData() {} | 24 GdiFontPatchData() {} |
| 24 | 25 |
| 25 private: | 26 private: |
| 26 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); | 27 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 // 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 |
| 30 // 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. |
| 31 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( | 32 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( |
| 32 const base::FilePath& path); | 33 const base::FilePath& path); |
| 33 | 34 |
| 34 // 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. |
| 35 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); | 36 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); |
| 36 | 37 |
| 37 // Testing method to reset the table of emulated GDI handles. | 38 // Testing method to reset the table of emulated GDI handles. |
| 38 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); | 39 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); |
| 39 | 40 |
| 40 // 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 |
| 41 // for testing the implementation. | 42 // for testing the implementation. |
| 42 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); | 43 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting( |
| 44 sk_sp<SkFontMgr> fontmgr); |
| 43 | 45 |
| 44 // Directwrite connects to the font cache service to retrieve information about | 46 // Directwrite connects to the font cache service to retrieve information about |
| 45 // fonts installed on the system etc. This works well outside the sandbox and | 47 // fonts installed on the system etc. This works well outside the sandbox and |
| 46 // within the sandbox as long as the lpc connection maintained by the current | 48 // within the sandbox as long as the lpc connection maintained by the current |
| 47 // process with the font cache service remains valid. It appears that there | 49 // process with the font cache service remains valid. It appears that there |
| 48 // are cases when this connection is dropped after which directwrite is unable | 50 // are cases when this connection is dropped after which directwrite is unable |
| 49 // to connect to the font cache service which causes problems with characters | 51 // to connect to the font cache service which causes problems with characters |
| 50 // disappearing. | 52 // disappearing. |
| 51 // Directwrite has fallback code to enumerate fonts if it is unable to connect | 53 // Directwrite has fallback code to enumerate fonts if it is unable to connect |
| 52 // to the font cache service. We need to intercept the following APIs to | 54 // to the font cache service. We need to intercept the following APIs to |
| 53 // ensure that it does not connect to the font cache service. | 55 // ensure that it does not connect to the font cache service. |
| 54 // NtALpcConnectPort | 56 // NtALpcConnectPort |
| 55 // OpenSCManagerW | 57 // OpenSCManagerW |
| 56 // OpenServiceW | 58 // OpenServiceW |
| 57 // StartServiceW | 59 // StartServiceW |
| 58 // CloseServiceHandle. | 60 // CloseServiceHandle. |
| 59 // These are all IAT patched. | 61 // These are all IAT patched. |
| 60 CONTENT_EXPORT void PatchServiceManagerCalls(); | 62 CONTENT_EXPORT void PatchServiceManagerCalls(); |
| 61 | 63 |
| 62 } // namespace content | 64 } // namespace content |
| 63 | 65 |
| 64 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 66 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
| OLD | NEW |