[DevTools] Remove forwarded connections counting
[chromium-blink-merge.git] / content / ppapi_plugin / ppapi_blink_platform_impl.cc
blob5c9de83d08b87ce5af4bd4e0ef6480c695787ecf
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
3 // found in the LICENSE file.
5 #include "content/ppapi_plugin/ppapi_blink_platform_impl.h"
7 #include <map>
9 #include "base/logging.h"
10 #include "base/strings/string16.h"
11 #include "base/threading/platform_thread.h"
12 #include "build/build_config.h"
13 #include "content/child/child_thread_impl.h"
14 #include "content/common/child_process_messages.h"
15 #include "ppapi/proxy/plugin_globals.h"
16 #include "ppapi/shared_impl/proxy_lock.h"
17 #include "third_party/WebKit/public/platform/WebString.h"
19 #if defined(OS_MACOSX)
20 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h"
21 #elif defined(OS_POSIX) && !defined(OS_ANDROID)
22 #include "content/common/child_process_sandbox_support_impl_linux.h"
23 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
24 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
25 #include "third_party/icu/source/common/unicode/utf16.h"
26 #endif
28 using blink::WebSandboxSupport;
29 using blink::WebString;
30 using blink::WebUChar;
31 using blink::WebUChar32;
33 typedef struct CGFont* CGFontRef;
35 namespace content {
37 #if !defined(OS_ANDROID) && !defined(OS_WIN)
39 class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
40 public:
41 virtual ~SandboxSupport() {}
43 #if defined(OS_MACOSX)
44 virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID);
45 #elif defined(OS_POSIX)
46 SandboxSupport();
47 virtual void getFallbackFontForCharacter(
48 WebUChar32 character,
49 const char* preferred_locale,
50 blink::WebFallbackFont* fallbackFont);
51 virtual void getRenderStyleForStrike(const char* family,
52 int sizeAndStyle,
53 blink::WebFontRenderStyle* out);
55 private:
56 // WebKit likes to ask us for the correct font family to use for a set of
57 // unicode code points. It needs this information frequently so we cache it
58 // here.
59 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
60 // For debugging crbug.com/312965
61 base::PlatformThreadId creation_thread_;
62 #endif
65 #if defined(OS_MACOSX)
67 bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
68 CGFontRef* out,
69 uint32_t* font_id) {
70 // TODO(brettw) this should do the something similar to what
71 // RendererBlinkPlatformImpl does and request that the browser load the font.
72 // Note: need to unlock the proxy lock like ensureFontLoaded does.
73 NOTIMPLEMENTED();
74 return false;
77 #elif defined(OS_POSIX)
79 PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport()
80 : creation_thread_(base::PlatformThread::CurrentId()) {
83 void PpapiBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter(
84 WebUChar32 character,
85 const char* preferred_locale,
86 blink::WebFallbackFont* fallbackFont) {
87 ppapi::ProxyLock::AssertAcquired();
88 // For debugging crbug.com/312965
89 CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId());
90 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
91 unicode_font_families_.find(character);
92 if (iter != unicode_font_families_.end()) {
93 fallbackFont->name = iter->second.name;
94 fallbackFont->filename = iter->second.filename;
95 fallbackFont->fontconfigInterfaceId = iter->second.fontconfigInterfaceId;
96 fallbackFont->ttcIndex = iter->second.ttcIndex;
97 fallbackFont->isBold = iter->second.isBold;
98 fallbackFont->isItalic = iter->second.isItalic;
99 return;
102 GetFallbackFontForCharacter(character, preferred_locale, fallbackFont);
103 unicode_font_families_.insert(std::make_pair(character, *fallbackFont));
106 void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike(
107 const char* family,
108 int sizeAndStyle,
109 blink::WebFontRenderStyle* out) {
110 GetRenderStyleForStrike(family, sizeAndStyle, out);
113 #endif
115 #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
117 PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() {
118 #if !defined(OS_ANDROID) && !defined(OS_WIN)
119 sandbox_support_.reset(new PpapiBlinkPlatformImpl::SandboxSupport);
120 #endif
123 PpapiBlinkPlatformImpl::~PpapiBlinkPlatformImpl() {
126 void PpapiBlinkPlatformImpl::Shutdown() {
127 #if !defined(OS_ANDROID) && !defined(OS_WIN)
128 // SandboxSupport contains a map of WebFontFamily objects, which hold
129 // WebCStrings, which become invalidated when blink is shut down. Hence, we
130 // need to clear that map now, just before blink::shutdown() is called.
131 sandbox_support_.reset();
132 #endif
135 blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() {
136 NOTREACHED();
137 return NULL;
140 blink::WebMimeRegistry* PpapiBlinkPlatformImpl::mimeRegistry() {
141 NOTREACHED();
142 return NULL;
145 blink::WebFileUtilities* PpapiBlinkPlatformImpl::fileUtilities() {
146 NOTREACHED();
147 return NULL;
150 blink::WebSandboxSupport* PpapiBlinkPlatformImpl::sandboxSupport() {
151 #if !defined(OS_ANDROID) && !defined(OS_WIN)
152 return sandbox_support_.get();
153 #else
154 return nullptr;
155 #endif
158 bool PpapiBlinkPlatformImpl::sandboxEnabled() {
159 return true; // Assume PPAPI is always sandboxed.
162 unsigned long long PpapiBlinkPlatformImpl::visitedLinkHash(
163 const char* canonical_url,
164 size_t length) {
165 NOTREACHED();
166 return 0;
169 bool PpapiBlinkPlatformImpl::isLinkVisited(unsigned long long link_hash) {
170 NOTREACHED();
171 return false;
174 void PpapiBlinkPlatformImpl::createMessageChannel(
175 blink::WebMessagePortChannel** channel1,
176 blink::WebMessagePortChannel** channel2) {
177 NOTREACHED();
178 *channel1 = NULL;
179 *channel2 = NULL;
182 void PpapiBlinkPlatformImpl::setCookies(
183 const blink::WebURL& url,
184 const blink::WebURL& first_party_for_cookies,
185 const blink::WebString& value) {
186 NOTREACHED();
189 blink::WebString PpapiBlinkPlatformImpl::cookies(
190 const blink::WebURL& url,
191 const blink::WebURL& first_party_for_cookies) {
192 NOTREACHED();
193 return blink::WebString();
196 blink::WebString PpapiBlinkPlatformImpl::defaultLocale() {
197 NOTREACHED();
198 return blink::WebString();
201 blink::WebThemeEngine* PpapiBlinkPlatformImpl::themeEngine() {
202 NOTREACHED();
203 return NULL;
206 blink::WebURLLoader* PpapiBlinkPlatformImpl::createURLLoader() {
207 NOTREACHED();
208 return NULL;
211 void PpapiBlinkPlatformImpl::getPluginList(
212 bool refresh,
213 blink::WebPluginListBuilder* builder) {
214 NOTREACHED();
217 blink::WebData PpapiBlinkPlatformImpl::loadResource(const char* name) {
218 NOTREACHED();
219 return blink::WebData();
222 blink::WebStorageNamespace*
223 PpapiBlinkPlatformImpl::createLocalStorageNamespace() {
224 NOTREACHED();
225 return 0;
228 void PpapiBlinkPlatformImpl::dispatchStorageEvent(
229 const blink::WebString& key,
230 const blink::WebString& old_value,
231 const blink::WebString& new_value,
232 const blink::WebString& origin,
233 const blink::WebURL& url,
234 bool is_local_storage) {
235 NOTREACHED();
238 int PpapiBlinkPlatformImpl::databaseDeleteFile(
239 const blink::WebString& vfs_file_name,
240 bool sync_dir) {
241 NOTREACHED();
242 return 0;
245 } // namespace content