| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ |
| 7 | 7 |
| 8 #include <dwrite.h> | 8 #include <dwrite.h> |
| 9 #include <dwrite_2.h> |
| 9 #include <wrl.h> | 10 #include <wrl.h> |
| 10 #include <set> | 11 #include <set> |
| 11 #include <utility> | 12 #include <utility> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/location.h" | 15 #include "base/location.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 18 #include "content/public/browser/browser_message_filter.h" | 19 #include "content/public/browser/browser_message_filter.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 | 21 |
| 22 struct DWriteFontStyle; |
| 23 struct MapCharactersResult; |
| 24 |
| 21 namespace content { | 25 namespace content { |
| 22 | 26 |
| 23 // Implements a message filter that handles the dwrite font proxy messages. | 27 // Implements a message filter that handles the dwrite font proxy messages. |
| 24 // If DWrite is enabled, calls into the system font collection to obtain | 28 // If DWrite is enabled, calls into the system font collection to obtain |
| 25 // results. Otherwise, acts as if the system collection contains no fonts. | 29 // results. Otherwise, acts as if the system collection contains no fonts. |
| 26 class CONTENT_EXPORT DWriteFontProxyMessageFilter | 30 class CONTENT_EXPORT DWriteFontProxyMessageFilter |
| 27 : public BrowserMessageFilter { | 31 : public BrowserMessageFilter { |
| 28 public: | 32 public: |
| 29 DWriteFontProxyMessageFilter(); | 33 DWriteFontProxyMessageFilter(); |
| 30 | 34 |
| 31 // BrowserMessageFilter: | 35 // BrowserMessageFilter: |
| 32 bool OnMessageReceived(const IPC::Message& message) override; | 36 bool OnMessageReceived(const IPC::Message& message) override; |
| 33 void OverrideThreadForMessage(const IPC::Message& message, | 37 void OverrideThreadForMessage(const IPC::Message& message, |
| 34 content::BrowserThread::ID* thread) override; | 38 content::BrowserThread::ID* thread) override; |
| 35 | 39 |
| 36 protected: | 40 protected: |
| 37 ~DWriteFontProxyMessageFilter() override; | 41 ~DWriteFontProxyMessageFilter() override; |
| 38 | 42 |
| 39 void OnFindFamily(const base::string16& family_name, UINT32* family_index); | 43 void OnFindFamily(const base::string16& family_name, UINT32* family_index); |
| 40 void OnGetFamilyCount(UINT32* count); | 44 void OnGetFamilyCount(UINT32* count); |
| 41 void OnGetFamilyNames( | 45 void OnGetFamilyNames( |
| 42 UINT32 family_index, | 46 UINT32 family_index, |
| 43 std::vector<std::pair<base::string16, base::string16>>* family_names); | 47 std::vector<std::pair<base::string16, base::string16>>* family_names); |
| 44 void OnGetFontFiles(UINT32 family_index, | 48 void OnGetFontFiles(UINT32 family_index, |
| 45 std::vector<base::string16>* file_paths); | 49 std::vector<base::string16>* file_paths); |
| 50 void OnMapCharacters(const base::string16& text, |
| 51 const DWriteFontStyle& font_style, |
| 52 const base::string16& locale_name, |
| 53 uint32_t reading_direction, |
| 54 const base::string16& base_family_name, |
| 55 MapCharactersResult* result); |
| 46 | 56 |
| 47 void InitializeDirectWrite(); | 57 void InitializeDirectWrite(); |
| 48 | 58 |
| 49 private: | 59 private: |
| 50 bool AddFilesForFont(std::set<base::string16>* path_set, IDWriteFont* font); | 60 bool AddFilesForFont(std::set<base::string16>* path_set, IDWriteFont* font); |
| 51 bool AddLocalFile(std::set<base::string16>* path_set, | 61 bool AddLocalFile(std::set<base::string16>* path_set, |
| 52 IDWriteLocalFontFileLoader* local_loader, | 62 IDWriteLocalFontFileLoader* local_loader, |
| 53 IDWriteFontFile* font_file); | 63 IDWriteFontFile* font_file); |
| 54 | 64 |
| 55 private: | 65 private: |
| 56 bool direct_write_initialized_ = false; | 66 bool direct_write_initialized_ = false; |
| 57 Microsoft::WRL::ComPtr<IDWriteFontCollection> collection_; | 67 Microsoft::WRL::ComPtr<IDWriteFontCollection> collection_; |
| 68 Microsoft::WRL::ComPtr<IDWriteFactory2> factory2_; |
| 69 Microsoft::WRL::ComPtr<IDWriteFontFallback> font_fallback_; |
| 58 base::string16 windows_fonts_path_; | 70 base::string16 windows_fonts_path_; |
| 59 | 71 |
| 60 DISALLOW_COPY_AND_ASSIGN(DWriteFontProxyMessageFilter); | 72 DISALLOW_COPY_AND_ASSIGN(DWriteFontProxyMessageFilter); |
| 61 }; | 73 }; |
| 62 | 74 |
| 63 } // namespace content | 75 } // namespace content |
| 64 | 76 |
| 65 #endif // CONTENT_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ | 77 #endif // CONTENT_BROWSER_RENDERER_HOST_DWRITE_FONT_PROXY_MESSAGE_FILTER_WIN_H_ |
| OLD | NEW |