OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/ppapi_plugin/ppapi_webkitclient_impl.h" |
| 6 |
| 7 #include <map> |
| 8 |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "base/logging.h" |
| 11 #include "build/build_config.h" |
| 12 #include "content/renderer/renderer_webkitclient_impl.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 15 |
| 16 #if defined(OS_WIN) |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport
.h" |
| 18 #elif defined(OS_MACOSX) |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport
.h" |
| 20 #elif defined(OS_LINUX) |
| 21 #include "content/common/child_process_sandbox_support_linux.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" |
| 23 #endif |
| 24 |
| 25 using WebKit::WebFontRenderStyle; |
| 26 using WebKit::WebSandboxSupport; |
| 27 using WebKit::WebString; |
| 28 using WebKit::WebUChar; |
| 29 |
| 30 class PpapiWebKitClientImpl::SandboxSupport : public WebSandboxSupport { |
| 31 public: |
| 32 #if defined(OS_WIN) |
| 33 virtual bool ensureFontLoaded(HFONT); |
| 34 #elif defined(OS_MACOSX) |
| 35 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); |
| 36 #elif defined(OS_LINUX) |
| 37 virtual WebString getFontFamilyForCharacters( |
| 38 const WebUChar* characters, |
| 39 size_t numCharacters, |
| 40 const char* preferred_locale); |
| 41 virtual void getRenderStyleForStrike( |
| 42 const char* family, int sizeAndStyle, WebFontRenderStyle* out); |
| 43 |
| 44 private: |
| 45 // WebKit likes to ask us for the correct font family to use for a set of |
| 46 // unicode code points. It needs this information frequently so we cache it |
| 47 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
| 48 // The value is a string containing the correct font family. |
| 49 base::Lock unicode_font_families_mutex_; |
| 50 std::map<std::string, std::string> unicode_font_families_; |
| 51 #endif |
| 52 }; |
| 53 |
| 54 #if defined(OS_WIN) |
| 55 |
| 56 bool PpapiWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { |
| 57 // TODO(brettw) this should do the something similar to what |
| 58 // RendererWebKitClientImpl does and request that the browser load the font. |
| 59 NOTIMPLEMENTED(); |
| 60 return false; |
| 61 } |
| 62 |
| 63 #elif defined(OS_MACOSX) |
| 64 |
| 65 bool PpapiWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, |
| 66 ATSFontContainerRef* out) { |
| 67 // TODO(brettw) this should do the something similar to what |
| 68 // RendererWebKitClientImpl does and request that the browser load the font. |
| 69 NOTIMPLEMENTED(); |
| 70 return false; |
| 71 } |
| 72 |
| 73 #elif defined(OS_LINUX) |
| 74 |
| 75 WebString PpapiWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( |
| 76 const WebUChar* characters, |
| 77 size_t num_characters, |
| 78 const char* preferred_locale) { |
| 79 base::AutoLock lock(unicode_font_families_mutex_); |
| 80 const std::string key(reinterpret_cast<const char*>(characters), |
| 81 num_characters * sizeof(characters[0])); |
| 82 const std::map<std::string, std::string>::const_iterator iter = |
| 83 unicode_font_families_.find(key); |
| 84 if (iter != unicode_font_families_.end()) |
| 85 return WebString::fromUTF8(iter->second); |
| 86 |
| 87 const std::string family_name = |
| 88 child_process_sandbox_support::getFontFamilyForCharacters( |
| 89 characters, |
| 90 num_characters, |
| 91 preferred_locale); |
| 92 unicode_font_families_.insert(make_pair(key, family_name)); |
| 93 return WebString::fromUTF8(family_name); |
| 94 } |
| 95 |
| 96 void PpapiWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( |
| 97 const char* family, int sizeAndStyle, WebFontRenderStyle* out) { |
| 98 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, |
| 99 out); |
| 100 } |
| 101 |
| 102 #endif |
| 103 |
| 104 PpapiWebKitClientImpl::PpapiWebKitClientImpl() { |
| 105 } |
| 106 |
| 107 PpapiWebKitClientImpl::~PpapiWebKitClientImpl() { |
| 108 } |
| 109 |
| 110 WebKit::WebClipboard* PpapiWebKitClientImpl::clipboard() { |
| 111 NOTREACHED(); |
| 112 return NULL; |
| 113 } |
| 114 |
| 115 WebKit::WebMimeRegistry* PpapiWebKitClientImpl::mimeRegistry() { |
| 116 NOTREACHED(); |
| 117 return NULL; |
| 118 } |
| 119 |
| 120 WebKit::WebFileUtilities* PpapiWebKitClientImpl::fileUtilities() { |
| 121 NOTREACHED(); |
| 122 return NULL; |
| 123 } |
| 124 |
| 125 WebKit::WebSandboxSupport* PpapiWebKitClientImpl::sandboxSupport() { |
| 126 return sandbox_support_.get(); |
| 127 } |
| 128 |
| 129 bool PpapiWebKitClientImpl::sandboxEnabled() { |
| 130 return true; // Assume PPAPI is always sandboxed. |
| 131 } |
| 132 |
| 133 unsigned long long PpapiWebKitClientImpl::visitedLinkHash( |
| 134 const char* canonical_url, |
| 135 size_t length) { |
| 136 NOTREACHED(); |
| 137 return 0; |
| 138 } |
| 139 |
| 140 bool PpapiWebKitClientImpl::isLinkVisited(unsigned long long link_hash) { |
| 141 NOTREACHED(); |
| 142 return false; |
| 143 } |
| 144 |
| 145 WebKit::WebMessagePortChannel* |
| 146 PpapiWebKitClientImpl::createMessagePortChannel() { |
| 147 NOTREACHED(); |
| 148 return NULL; |
| 149 } |
| 150 |
| 151 void PpapiWebKitClientImpl::setCookies( |
| 152 const WebKit::WebURL& url, |
| 153 const WebKit::WebURL& first_party_for_cookies, |
| 154 const WebKit::WebString& value) { |
| 155 NOTREACHED(); |
| 156 } |
| 157 |
| 158 WebKit::WebString PpapiWebKitClientImpl::cookies( |
| 159 const WebKit::WebURL& url, |
| 160 const WebKit::WebURL& first_party_for_cookies) { |
| 161 NOTREACHED(); |
| 162 return WebKit::WebString(); |
| 163 } |
| 164 |
| 165 void PpapiWebKitClientImpl::prefetchHostName(const WebKit::WebString&) { |
| 166 NOTREACHED(); |
| 167 } |
| 168 |
| 169 WebKit::WebString PpapiWebKitClientImpl::defaultLocale() { |
| 170 NOTREACHED(); |
| 171 return WebKit::WebString(); |
| 172 } |
| 173 |
| 174 WebKit::WebThemeEngine* PpapiWebKitClientImpl::themeEngine() { |
| 175 NOTREACHED(); |
| 176 return NULL; |
| 177 } |
| 178 |
| 179 WebKit::WebURLLoader* PpapiWebKitClientImpl::createURLLoader() { |
| 180 NOTREACHED(); |
| 181 return NULL; |
| 182 } |
| 183 |
| 184 WebKit::WebSocketStreamHandle* |
| 185 PpapiWebKitClientImpl::createSocketStreamHandle() { |
| 186 NOTREACHED(); |
| 187 return NULL; |
| 188 } |
| 189 |
| 190 void PpapiWebKitClientImpl::getPluginList(bool refresh, |
| 191 WebKit::WebPluginListBuilder* builder) { |
| 192 NOTREACHED(); |
| 193 } |
| 194 |
| 195 WebKit::WebData PpapiWebKitClientImpl::loadResource(const char* name) { |
| 196 NOTREACHED(); |
| 197 return WebKit::WebData(); |
| 198 } |
| 199 |
| 200 WebKit::WebStorageNamespace* |
| 201 PpapiWebKitClientImpl::createLocalStorageNamespace( |
| 202 const WebKit::WebString& path, unsigned quota) { |
| 203 NOTREACHED(); |
| 204 return 0; |
| 205 } |
| 206 |
| 207 void PpapiWebKitClientImpl::dispatchStorageEvent( |
| 208 const WebKit::WebString& key, const WebKit::WebString& old_value, |
| 209 const WebKit::WebString& new_value, const WebKit::WebString& origin, |
| 210 const WebKit::WebURL& url, bool is_local_storage) { |
| 211 NOTREACHED(); |
| 212 } |
| 213 |
| 214 WebKit::WebSharedWorkerRepository* |
| 215 PpapiWebKitClientImpl::sharedWorkerRepository() { |
| 216 NOTREACHED(); |
| 217 return NULL; |
| 218 } |
| 219 |
| 220 int PpapiWebKitClientImpl::databaseDeleteFile( |
| 221 const WebKit::WebString& vfs_file_name, bool sync_dir) { |
| 222 NOTREACHED(); |
| 223 return 0; |
| 224 } |
| 225 |
| 226 void PpapiWebKitClientImpl::createIDBKeysFromSerializedValuesAndKeyPath( |
| 227 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values, |
| 228 const WebKit::WebString& keyPath, |
| 229 WebKit::WebVector<WebKit::WebIDBKey>& keys) { |
| 230 NOTREACHED(); |
| 231 } |
| 232 |
| 233 WebKit::WebSerializedScriptValue |
| 234 PpapiWebKitClientImpl::injectIDBKeyIntoSerializedValue( |
| 235 const WebKit::WebIDBKey& key, |
| 236 const WebKit::WebSerializedScriptValue& value, |
| 237 const WebKit::WebString& keyPath) { |
| 238 NOTREACHED(); |
| 239 return WebKit::WebSerializedScriptValue(); |
| 240 } |
OLD | NEW |