| 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_blink_platform_impl.h" | 5 #include "content/ppapi_plugin/ppapi_blink_platform_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_impl.h" | 13 #include "content/child/child_thread_impl.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_MACOSX) |
| 20 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" | |
| 21 #elif defined(OS_MACOSX) | |
| 22 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" | 20 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" |
| 23 #elif defined(OS_ANDROID) | 21 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
| 24 #include "third_party/WebKit/public/platform/android/WebSandboxSupport.h" | |
| 25 #elif defined(OS_POSIX) | |
| 26 #include "content/common/child_process_sandbox_support_impl_linux.h" | 22 #include "content/common/child_process_sandbox_support_impl_linux.h" |
| 27 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" | 23 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" |
| 28 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" | 24 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" |
| 29 #include "third_party/icu/source/common/unicode/utf16.h" | 25 #include "third_party/icu/source/common/unicode/utf16.h" |
| 30 #endif | 26 #endif |
| 31 | 27 |
| 32 using blink::WebSandboxSupport; | 28 using blink::WebSandboxSupport; |
| 33 using blink::WebString; | 29 using blink::WebString; |
| 34 using blink::WebUChar; | 30 using blink::WebUChar; |
| 35 using blink::WebUChar32; | 31 using blink::WebUChar32; |
| 36 | 32 |
| 37 typedef struct CGFont* CGFontRef; | 33 typedef struct CGFont* CGFontRef; |
| 38 | 34 |
| 39 namespace content { | 35 namespace content { |
| 40 | 36 |
| 37 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 38 |
| 41 class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { | 39 class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { |
| 42 public: | 40 public: |
| 43 virtual ~SandboxSupport() {} | 41 virtual ~SandboxSupport() {} |
| 44 | 42 |
| 45 #if defined(OS_WIN) | 43 #if defined(OS_MACOSX) |
| 46 virtual bool ensureFontLoaded(HFONT); | |
| 47 #elif defined(OS_MACOSX) | |
| 48 virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID); | 44 virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID); |
| 49 #elif defined(OS_ANDROID) | |
| 50 // Empty class. | |
| 51 #elif defined(OS_POSIX) | 45 #elif defined(OS_POSIX) |
| 52 SandboxSupport(); | 46 SandboxSupport(); |
| 53 virtual void getFallbackFontForCharacter( | 47 virtual void getFallbackFontForCharacter( |
| 54 WebUChar32 character, | 48 WebUChar32 character, |
| 55 const char* preferred_locale, | 49 const char* preferred_locale, |
| 56 blink::WebFallbackFont* fallbackFont); | 50 blink::WebFallbackFont* fallbackFont); |
| 57 virtual void getRenderStyleForStrike(const char* family, | 51 virtual void getRenderStyleForStrike(const char* family, |
| 58 int sizeAndStyle, | 52 int sizeAndStyle, |
| 59 blink::WebFontRenderStyle* out); | 53 blink::WebFontRenderStyle* out); |
| 60 | 54 |
| 61 private: | 55 private: |
| 62 // WebKit likes to ask us for the correct font family to use for a set of | 56 // WebKit likes to ask us for the correct font family to use for a set of |
| 63 // unicode code points. It needs this information frequently so we cache it | 57 // unicode code points. It needs this information frequently so we cache it |
| 64 // here. | 58 // here. |
| 65 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; | 59 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; |
| 66 // For debugging crbug.com/312965 | 60 // For debugging crbug.com/312965 |
| 67 base::PlatformThreadId creation_thread_; | 61 base::PlatformThreadId creation_thread_; |
| 68 #endif | 62 #endif |
| 69 }; | 63 }; |
| 70 | 64 |
| 71 #if defined(OS_WIN) | 65 #if defined(OS_MACOSX) |
| 72 | |
| 73 bool PpapiBlinkPlatformImpl::SandboxSupport::ensureFontLoaded(HFONT font) { | |
| 74 LOGFONT logfont; | |
| 75 GetObject(font, sizeof(LOGFONT), &logfont); | |
| 76 | |
| 77 // Use the proxy sender rather than going directly to the ChildThread since | |
| 78 // the proxy browser sender will properly unlock during sync messages. | |
| 79 return ppapi::proxy::PluginGlobals::Get()->GetBrowserSender()->Send( | |
| 80 new ChildProcessHostMsg_PreCacheFont(logfont)); | |
| 81 } | |
| 82 | |
| 83 #elif defined(OS_MACOSX) | |
| 84 | 66 |
| 85 bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, | 67 bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, |
| 86 CGFontRef* out, | 68 CGFontRef* out, |
| 87 uint32_t* font_id) { | 69 uint32_t* font_id) { |
| 88 // TODO(brettw) this should do the something similar to what | 70 // TODO(brettw) this should do the something similar to what |
| 89 // RendererBlinkPlatformImpl does and request that the browser load the font. | 71 // RendererBlinkPlatformImpl does and request that the browser load the font. |
| 90 // Note: need to unlock the proxy lock like ensureFontLoaded does. | 72 // Note: need to unlock the proxy lock like ensureFontLoaded does. |
| 91 NOTIMPLEMENTED(); | 73 NOTIMPLEMENTED(); |
| 92 return false; | 74 return false; |
| 93 } | 75 } |
| 94 | 76 |
| 95 #elif defined(OS_ANDROID) | |
| 96 | |
| 97 // Empty class. | |
| 98 | |
| 99 #elif defined(OS_POSIX) | 77 #elif defined(OS_POSIX) |
| 100 | 78 |
| 101 PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() | 79 PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() |
| 102 : creation_thread_(base::PlatformThread::CurrentId()) { | 80 : creation_thread_(base::PlatformThread::CurrentId()) { |
| 103 } | 81 } |
| 104 | 82 |
| 105 void PpapiBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter( | 83 void PpapiBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter( |
| 106 WebUChar32 character, | 84 WebUChar32 character, |
| 107 const char* preferred_locale, | 85 const char* preferred_locale, |
| 108 blink::WebFallbackFont* fallbackFont) { | 86 blink::WebFallbackFont* fallbackFont) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 127 | 105 |
| 128 void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike( | 106 void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike( |
| 129 const char* family, | 107 const char* family, |
| 130 int sizeAndStyle, | 108 int sizeAndStyle, |
| 131 blink::WebFontRenderStyle* out) { | 109 blink::WebFontRenderStyle* out) { |
| 132 GetRenderStyleForStrike(family, sizeAndStyle, out); | 110 GetRenderStyleForStrike(family, sizeAndStyle, out); |
| 133 } | 111 } |
| 134 | 112 |
| 135 #endif | 113 #endif |
| 136 | 114 |
| 137 PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() | 115 #endif // !defined(OS_ANDROID) && !defined(OS_WIN) |
| 138 : sandbox_support_(new PpapiBlinkPlatformImpl::SandboxSupport()) { | 116 |
| 117 PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() { |
| 118 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 119 sandbox_support_.reset(new PpapiBlinkPlatformImpl::SandboxSupport); |
| 120 #endif |
| 139 } | 121 } |
| 140 | 122 |
| 141 PpapiBlinkPlatformImpl::~PpapiBlinkPlatformImpl() { | 123 PpapiBlinkPlatformImpl::~PpapiBlinkPlatformImpl() { |
| 142 } | 124 } |
| 143 | 125 |
| 144 void PpapiBlinkPlatformImpl::Shutdown() { | 126 void PpapiBlinkPlatformImpl::Shutdown() { |
| 127 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 145 // SandboxSupport contains a map of WebFontFamily objects, which hold | 128 // SandboxSupport contains a map of WebFontFamily objects, which hold |
| 146 // WebCStrings, which become invalidated when blink is shut down. Hence, we | 129 // WebCStrings, which become invalidated when blink is shut down. Hence, we |
| 147 // need to clear that map now, just before blink::shutdown() is called. | 130 // need to clear that map now, just before blink::shutdown() is called. |
| 148 sandbox_support_.reset(); | 131 sandbox_support_.reset(); |
| 132 #endif |
| 149 } | 133 } |
| 150 | 134 |
| 151 blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() { | 135 blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() { |
| 152 NOTREACHED(); | 136 NOTREACHED(); |
| 153 return NULL; | 137 return NULL; |
| 154 } | 138 } |
| 155 | 139 |
| 156 blink::WebMimeRegistry* PpapiBlinkPlatformImpl::mimeRegistry() { | 140 blink::WebMimeRegistry* PpapiBlinkPlatformImpl::mimeRegistry() { |
| 157 NOTREACHED(); | 141 NOTREACHED(); |
| 158 return NULL; | 142 return NULL; |
| 159 } | 143 } |
| 160 | 144 |
| 161 blink::WebFileUtilities* PpapiBlinkPlatformImpl::fileUtilities() { | 145 blink::WebFileUtilities* PpapiBlinkPlatformImpl::fileUtilities() { |
| 162 NOTREACHED(); | 146 NOTREACHED(); |
| 163 return NULL; | 147 return NULL; |
| 164 } | 148 } |
| 165 | 149 |
| 166 blink::WebSandboxSupport* PpapiBlinkPlatformImpl::sandboxSupport() { | 150 blink::WebSandboxSupport* PpapiBlinkPlatformImpl::sandboxSupport() { |
| 151 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 167 return sandbox_support_.get(); | 152 return sandbox_support_.get(); |
| 153 #else |
| 154 return nullptr; |
| 155 #endif |
| 168 } | 156 } |
| 169 | 157 |
| 170 bool PpapiBlinkPlatformImpl::sandboxEnabled() { | 158 bool PpapiBlinkPlatformImpl::sandboxEnabled() { |
| 171 return true; // Assume PPAPI is always sandboxed. | 159 return true; // Assume PPAPI is always sandboxed. |
| 172 } | 160 } |
| 173 | 161 |
| 174 unsigned long long PpapiBlinkPlatformImpl::visitedLinkHash( | 162 unsigned long long PpapiBlinkPlatformImpl::visitedLinkHash( |
| 175 const char* canonical_url, | 163 const char* canonical_url, |
| 176 size_t length) { | 164 size_t length) { |
| 177 NOTREACHED(); | 165 NOTREACHED(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 236 } |
| 249 | 237 |
| 250 int PpapiBlinkPlatformImpl::databaseDeleteFile( | 238 int PpapiBlinkPlatformImpl::databaseDeleteFile( |
| 251 const blink::WebString& vfs_file_name, | 239 const blink::WebString& vfs_file_name, |
| 252 bool sync_dir) { | 240 bool sync_dir) { |
| 253 NOTREACHED(); | 241 NOTREACHED(); |
| 254 return 0; | 242 return 0; |
| 255 } | 243 } |
| 256 | 244 |
| 257 } // namespace content | 245 } // namespace content |
| OLD | NEW |