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