OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h" | 5 #include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/child/child_thread.h" | 13 #include "content/child/child_thread.h" |
14 #include "content/common/child_process_messages.h" | 14 #include "content/common/child_process_messages.h" |
15 #include "ppapi/proxy/plugin_globals.h" | 15 #include "ppapi/proxy/plugin_globals.h" |
16 #include "ppapi/shared_impl/proxy_lock.h" | 16 #include "ppapi/shared_impl/proxy_lock.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
18 | 18 |
19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
20 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" | 20 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" |
21 #elif defined(OS_MACOSX) | 21 #elif defined(OS_MACOSX) |
22 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" | 22 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" |
23 #elif defined(OS_ANDROID) | 23 #elif defined(OS_ANDROID) |
24 #include "third_party/WebKit/public/platform/android/WebSandboxSupport.h" | 24 #include "third_party/WebKit/public/platform/android/WebSandboxSupport.h" |
25 #elif defined(OS_POSIX) | 25 #elif defined(OS_POSIX) |
26 #include "content/common/child_process_sandbox_support_impl_linux.h" | 26 #include "content/common/child_process_sandbox_support_impl_linux.h" |
27 #include "third_party/WebKit/public/platform/linux/WebFontFamily.h" | 27 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" |
28 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" | 28 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" |
29 #include "third_party/icu/source/common/unicode/utf16.h" | 29 #include "third_party/icu/source/common/unicode/utf16.h" |
30 #endif | 30 #endif |
31 | 31 |
32 using blink::WebSandboxSupport; | 32 using blink::WebSandboxSupport; |
33 using blink::WebString; | 33 using blink::WebString; |
34 using blink::WebUChar; | 34 using blink::WebUChar; |
35 using blink::WebUChar32; | 35 using blink::WebUChar32; |
36 | 36 |
37 typedef struct CGFont* CGFontRef; | 37 typedef struct CGFont* CGFontRef; |
38 | 38 |
39 namespace content { | 39 namespace content { |
40 | 40 |
41 class PpapiWebKitPlatformSupportImpl::SandboxSupport | 41 class PpapiWebKitPlatformSupportImpl::SandboxSupport |
42 : public WebSandboxSupport { | 42 : public WebSandboxSupport { |
43 public: | 43 public: |
44 virtual ~SandboxSupport() {} | 44 virtual ~SandboxSupport() {} |
45 | 45 |
46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 virtual bool ensureFontLoaded(HFONT); | 47 virtual bool ensureFontLoaded(HFONT); |
48 #elif defined(OS_MACOSX) | 48 #elif defined(OS_MACOSX) |
49 virtual bool loadFont( | 49 virtual bool loadFont( |
50 NSFont* srcFont, CGFontRef* out, uint32_t* fontID); | 50 NSFont* srcFont, CGFontRef* out, uint32_t* fontID); |
51 #elif defined(OS_ANDROID) | 51 #elif defined(OS_ANDROID) |
52 // Empty class. | 52 // Empty class. |
53 #elif defined(OS_POSIX) | 53 #elif defined(OS_POSIX) |
54 SandboxSupport(); | 54 SandboxSupport(); |
| 55 // TODO(dro): crbug.com/382411 Remove this function, once the blink side |
| 56 // does not need it anymore. |
55 virtual void getFontFamilyForCharacter( | 57 virtual void getFontFamilyForCharacter( |
56 WebUChar32 character, | 58 WebUChar32 character, |
57 const char* preferred_locale, | 59 const char* preferred_locale, |
58 blink::WebFontFamily* family); | 60 blink::WebFontFamily* family); |
| 61 virtual void getFallbackFontForCharacter( |
| 62 WebUChar32 character, |
| 63 const char* preferred_locale, |
| 64 blink::WebFallbackFont* fallbackFont); |
59 virtual void getRenderStyleForStrike( | 65 virtual void getRenderStyleForStrike( |
60 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out); | 66 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out); |
61 | 67 |
62 private: | 68 private: |
63 // WebKit likes to ask us for the correct font family to use for a set of | 69 // WebKit likes to ask us for the correct font family to use for a set of |
64 // unicode code points. It needs this information frequently so we cache it | 70 // unicode code points. It needs this information frequently so we cache it |
65 // here. | 71 // here. |
66 std::map<int32_t, blink::WebFontFamily> unicode_font_families_; | 72 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; |
67 // For debugging crbug.com/312965 | 73 // For debugging crbug.com/312965 |
68 base::PlatformThreadId creation_thread_; | 74 base::PlatformThreadId creation_thread_; |
69 #endif | 75 #endif |
70 }; | 76 }; |
71 | 77 |
72 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
73 | 79 |
74 bool PpapiWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( | 80 bool PpapiWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( |
75 HFONT font) { | 81 HFONT font) { |
76 LOGFONT logfont; | 82 LOGFONT logfont; |
(...skipping 29 matching lines...) Expand all Loading... |
106 } | 112 } |
107 | 113 |
108 void | 114 void |
109 PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter( | 115 PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter( |
110 WebUChar32 character, | 116 WebUChar32 character, |
111 const char* preferred_locale, | 117 const char* preferred_locale, |
112 blink::WebFontFamily* family) { | 118 blink::WebFontFamily* family) { |
113 ppapi::ProxyLock::AssertAcquired(); | 119 ppapi::ProxyLock::AssertAcquired(); |
114 // For debugging crbug.com/312965 | 120 // For debugging crbug.com/312965 |
115 CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId()); | 121 CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId()); |
116 const std::map<int32_t, blink::WebFontFamily>::const_iterator iter = | 122 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter = |
117 unicode_font_families_.find(character); | 123 unicode_font_families_.find(character); |
118 if (iter != unicode_font_families_.end()) { | 124 if (iter != unicode_font_families_.end()) { |
119 family->name = iter->second.name; | 125 family->name = iter->second.name; |
120 family->isBold = iter->second.isBold; | 126 family->isBold = iter->second.isBold; |
121 family->isItalic = iter->second.isItalic; | 127 family->isItalic = iter->second.isItalic; |
122 return; | 128 return; |
123 } | 129 } |
124 | 130 |
125 GetFontFamilyForCharacter(character, preferred_locale, family); | 131 blink::WebFallbackFont fallbackFont; |
126 unicode_font_families_.insert(std::make_pair(character, *family)); | 132 GetFallbackFontForCharacter(character, preferred_locale, &fallbackFont); |
| 133 unicode_font_families_.insert(std::make_pair(character, fallbackFont)); |
| 134 family->name = fallbackFont.name; |
| 135 family->isBold = fallbackFont.isBold; |
| 136 family->isItalic = fallbackFont.isItalic; |
| 137 } |
| 138 |
| 139 void |
| 140 PpapiWebKitPlatformSupportImpl::SandboxSupport::getFallbackFontForCharacter( |
| 141 WebUChar32 character, |
| 142 const char* preferred_locale, |
| 143 blink::WebFallbackFont* fallbackFont) { |
| 144 ppapi::ProxyLock::AssertAcquired(); |
| 145 // For debugging crbug.com/312965 |
| 146 CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId()); |
| 147 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter = |
| 148 unicode_font_families_.find(character); |
| 149 if (iter != unicode_font_families_.end()) { |
| 150 fallbackFont->name = iter->second.name; |
| 151 fallbackFont->filename = iter->second.filename; |
| 152 fallbackFont->ttcIndex = iter->second.ttcIndex; |
| 153 fallbackFont->isBold = iter->second.isBold; |
| 154 fallbackFont->isItalic = iter->second.isItalic; |
| 155 return; |
| 156 } |
| 157 |
| 158 GetFallbackFontForCharacter(character, preferred_locale, fallbackFont); |
| 159 unicode_font_families_.insert(std::make_pair(character, *fallbackFont)); |
127 } | 160 } |
128 | 161 |
129 void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( | 162 void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( |
130 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) { | 163 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) { |
131 GetRenderStyleForStrike(family, sizeAndStyle, out); | 164 GetRenderStyleForStrike(family, sizeAndStyle, out); |
132 } | 165 } |
133 | 166 |
134 #endif | 167 #endif |
135 | 168 |
136 PpapiWebKitPlatformSupportImpl::PpapiWebKitPlatformSupportImpl() | 169 PpapiWebKitPlatformSupportImpl::PpapiWebKitPlatformSupportImpl() |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 NOTREACHED(); | 282 NOTREACHED(); |
250 } | 283 } |
251 | 284 |
252 int PpapiWebKitPlatformSupportImpl::databaseDeleteFile( | 285 int PpapiWebKitPlatformSupportImpl::databaseDeleteFile( |
253 const blink::WebString& vfs_file_name, bool sync_dir) { | 286 const blink::WebString& vfs_file_name, bool sync_dir) { |
254 NOTREACHED(); | 287 NOTREACHED(); |
255 return 0; | 288 return 0; |
256 } | 289 } |
257 | 290 |
258 } // namespace content | 291 } // namespace content |
OLD | NEW |