OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 "chrome/renderer/renderer_webkitclient_impl.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/file_path.h" | |
9 #include "base/platform_file.h" | |
10 #include "base/shared_memory.h" | |
11 #include "base/utf_string_conversions.h" | |
12 #include "chrome/common/chrome_switches.h" | |
13 #include "chrome/common/render_messages.h" | |
14 #include "chrome/renderer/net/renderer_net_predictor.h" | |
15 #include "chrome/renderer/render_thread.h" | |
16 #include "chrome/renderer/render_view.h" | |
17 #include "chrome/renderer/renderer_webaudiodevice_impl.h" | |
18 #include "chrome/renderer/renderer_webidbfactory_impl.h" | |
19 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | |
20 #include "chrome/renderer/visitedlink_slave.h" | |
21 #include "content/common/database_util.h" | |
22 #include "content/common/file_system/webfilesystem_impl.h" | |
23 #include "content/common/file_utilities_messages.h" | |
24 #include "content/common/mime_registry_messages.h" | |
25 #include "content/common/webblobregistry_impl.h" | |
26 #include "content/common/webmessageportchannel_impl.h" | |
27 #include "content/plugin/npobject_util.h" | |
28 #include "content/renderer/webgraphicscontext3d_command_buffer_impl.h" | |
29 #include "content/renderer/websharedworkerrepository_impl.h" | |
30 #include "googleurl/src/gurl.h" | |
31 #include "ipc/ipc_sync_message_filter.h" | |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlobRegistry.h" | |
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.
h" | |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" | |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" | |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | |
42 #include "webkit/glue/simple_webmimeregistry_impl.h" | |
43 #include "webkit/glue/webclipboard_impl.h" | |
44 #include "webkit/glue/webfileutilities_impl.h" | |
45 #include "webkit/glue/webkit_glue.h" | |
46 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | |
47 | |
48 #if defined(OS_WIN) | |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport
.h" | |
50 #endif | |
51 | |
52 #if defined(OS_MACOSX) | |
53 #include "content/common/font_descriptor_mac.h" | |
54 #include "content/common/font_loader_mac.h" | |
55 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport
.h" | |
56 #endif | |
57 | |
58 #if defined(OS_LINUX) | |
59 #include <string> | |
60 #include <map> | |
61 | |
62 #include "base/synchronization/lock.h" | |
63 #include "chrome/renderer/renderer_sandbox_support_linux.h" | |
64 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" | |
65 #endif | |
66 | |
67 #if defined(OS_POSIX) | |
68 #include "base/file_descriptor_posix.h" | |
69 #endif | |
70 | |
71 using WebKit::WebAudioDevice; | |
72 using WebKit::WebBlobRegistry; | |
73 using WebKit::WebFileSystem; | |
74 using WebKit::WebFrame; | |
75 using WebKit::WebIDBFactory; | |
76 using WebKit::WebIDBKey; | |
77 using WebKit::WebIDBKeyPath; | |
78 using WebKit::WebKitClient; | |
79 using WebKit::WebSerializedScriptValue; | |
80 using WebKit::WebStorageArea; | |
81 using WebKit::WebStorageEventDispatcher; | |
82 using WebKit::WebStorageNamespace; | |
83 using WebKit::WebString; | |
84 using WebKit::WebURL; | |
85 using WebKit::WebVector; | |
86 | |
87 //------------------------------------------------------------------------------ | |
88 | |
89 class RendererWebKitClientImpl::MimeRegistry | |
90 : public webkit_glue::SimpleWebMimeRegistryImpl { | |
91 public: | |
92 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); | |
93 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); | |
94 virtual WebKit::WebString preferredExtensionForMIMEType( | |
95 const WebKit::WebString&); | |
96 }; | |
97 | |
98 class RendererWebKitClientImpl::FileUtilities | |
99 : public webkit_glue::WebFileUtilitiesImpl { | |
100 public: | |
101 virtual void revealFolderInOS(const WebKit::WebString& path); | |
102 virtual bool getFileSize(const WebKit::WebString& path, long long& result); | |
103 virtual bool getFileModificationTime(const WebKit::WebString& path, | |
104 double& result); | |
105 virtual base::PlatformFile openFile(const WebKit::WebString& path, | |
106 int mode); | |
107 }; | |
108 | |
109 class RendererWebKitClientImpl::SandboxSupport | |
110 : public WebKit::WebSandboxSupport { | |
111 public: | |
112 #if defined(OS_WIN) | |
113 virtual bool ensureFontLoaded(HFONT); | |
114 #elif defined(OS_MACOSX) | |
115 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); | |
116 #elif defined(OS_LINUX) | |
117 virtual WebKit::WebString getFontFamilyForCharacters( | |
118 const WebKit::WebUChar* characters, | |
119 size_t numCharacters, | |
120 const char* preferred_locale); | |
121 virtual void getRenderStyleForStrike( | |
122 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | |
123 | |
124 private: | |
125 // WebKit likes to ask us for the correct font family to use for a set of | |
126 // unicode code points. It needs this information frequently so we cache it | |
127 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | |
128 // The value is a string containing the correct font family. | |
129 base::Lock unicode_font_families_mutex_; | |
130 std::map<std::string, std::string> unicode_font_families_; | |
131 #endif | |
132 }; | |
133 | |
134 //------------------------------------------------------------------------------ | |
135 | |
136 RendererWebKitClientImpl::RendererWebKitClientImpl() | |
137 : clipboard_(new webkit_glue::WebClipboardImpl), | |
138 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), | |
139 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), | |
140 sudden_termination_disables_(0), | |
141 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { | |
142 } | |
143 | |
144 RendererWebKitClientImpl::~RendererWebKitClientImpl() { | |
145 } | |
146 | |
147 //------------------------------------------------------------------------------ | |
148 | |
149 WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() { | |
150 return clipboard_.get(); | |
151 } | |
152 | |
153 WebKit::WebMimeRegistry* RendererWebKitClientImpl::mimeRegistry() { | |
154 return mime_registry_.get(); | |
155 } | |
156 | |
157 WebKit::WebFileUtilities* RendererWebKitClientImpl::fileUtilities() { | |
158 if (!file_utilities_.get()) { | |
159 file_utilities_.reset(new FileUtilities); | |
160 file_utilities_->set_sandbox_enabled(sandboxEnabled()); | |
161 } | |
162 return file_utilities_.get(); | |
163 } | |
164 | |
165 WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() { | |
166 return sandbox_support_.get(); | |
167 } | |
168 | |
169 WebKit::WebCookieJar* RendererWebKitClientImpl::cookieJar() { | |
170 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; | |
171 return NULL; | |
172 } | |
173 | |
174 bool RendererWebKitClientImpl::sandboxEnabled() { | |
175 // As explained in WebKitClient.h, this function is used to decide whether to | |
176 // allow file system operations to come out of WebKit or not. Even if the | |
177 // sandbox is disabled, there's no reason why the code should act any | |
178 // differently...unless we're in single process mode. In which case, we have | |
179 // no other choice. WebKitClient.h discourages using this switch unless | |
180 // absolutely necessary, so hopefully we won't end up with too many code paths | |
181 // being different in single-process mode. | |
182 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | |
183 } | |
184 | |
185 bool RendererWebKitClientImpl::SendSyncMessageFromAnyThread( | |
186 IPC::SyncMessage* msg) { | |
187 RenderThread* render_thread = RenderThread::current(); | |
188 if (render_thread) | |
189 return render_thread->Send(msg); | |
190 | |
191 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( | |
192 ChildThread::current()->sync_message_filter()); | |
193 return sync_msg_filter->Send(msg); | |
194 } | |
195 | |
196 unsigned long long RendererWebKitClientImpl::visitedLinkHash( | |
197 const char* canonical_url, | |
198 size_t length) { | |
199 return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint( | |
200 canonical_url, length); | |
201 } | |
202 | |
203 bool RendererWebKitClientImpl::isLinkVisited(unsigned long long link_hash) { | |
204 return RenderThread::current()->visited_link_slave()->IsVisited(link_hash); | |
205 } | |
206 | |
207 WebKit::WebMessagePortChannel* | |
208 RendererWebKitClientImpl::createMessagePortChannel() { | |
209 return new WebMessagePortChannelImpl(); | |
210 } | |
211 | |
212 void RendererWebKitClientImpl::prefetchHostName(const WebString& hostname) { | |
213 if (!hostname.isEmpty()) { | |
214 std::string hostname_utf8; | |
215 UTF16ToUTF8(hostname.data(), hostname.length(), &hostname_utf8); | |
216 DnsPrefetchCString(hostname_utf8.data(), hostname_utf8.length()); | |
217 } | |
218 } | |
219 | |
220 bool RendererWebKitClientImpl::CheckPreparsedJsCachingEnabled() const { | |
221 static bool checked = false; | |
222 static bool result = false; | |
223 if (!checked) { | |
224 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
225 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching); | |
226 checked = true; | |
227 } | |
228 return result; | |
229 } | |
230 | |
231 void RendererWebKitClientImpl::cacheMetadata( | |
232 const WebKit::WebURL& url, | |
233 double response_time, | |
234 const char* data, | |
235 size_t size) { | |
236 if (!CheckPreparsedJsCachingEnabled()) | |
237 return; | |
238 | |
239 // Let the browser know we generated cacheable metadata for this resource. The | |
240 // browser may cache it and return it on subsequent responses to speed | |
241 // the processing of this resource. | |
242 std::vector<char> copy(data, data + size); | |
243 RenderThread::current()->Send(new ViewHostMsg_DidGenerateCacheableMetadata( | |
244 url, response_time, copy)); | |
245 } | |
246 | |
247 WebString RendererWebKitClientImpl::defaultLocale() { | |
248 // TODO(darin): Eliminate this webkit_glue call. | |
249 return ASCIIToUTF16(webkit_glue::GetWebKitLocale()); | |
250 } | |
251 | |
252 void RendererWebKitClientImpl::suddenTerminationChanged(bool enabled) { | |
253 if (enabled) { | |
254 // We should not get more enables than disables, but we want it to be a | |
255 // non-fatal error if it does happen. | |
256 DCHECK_GT(sudden_termination_disables_, 0); | |
257 sudden_termination_disables_ = std::max(sudden_termination_disables_ - 1, | |
258 0); | |
259 if (sudden_termination_disables_ != 0) | |
260 return; | |
261 } else { | |
262 sudden_termination_disables_++; | |
263 if (sudden_termination_disables_ != 1) | |
264 return; | |
265 } | |
266 | |
267 RenderThread* thread = RenderThread::current(); | |
268 if (thread) // NULL in unittests. | |
269 thread->Send(new ViewHostMsg_SuddenTerminationChanged(enabled)); | |
270 } | |
271 | |
272 WebStorageNamespace* RendererWebKitClientImpl::createLocalStorageNamespace( | |
273 const WebString& path, unsigned quota) { | |
274 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
275 return WebStorageNamespace::createLocalStorageNamespace(path, quota); | |
276 return new RendererWebStorageNamespaceImpl(DOM_STORAGE_LOCAL); | |
277 } | |
278 | |
279 void RendererWebKitClientImpl::dispatchStorageEvent( | |
280 const WebString& key, const WebString& old_value, | |
281 const WebString& new_value, const WebString& origin, | |
282 const WebKit::WebURL& url, bool is_local_storage) { | |
283 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | |
284 // Inefficient, but only used in single process mode. | |
285 scoped_ptr<WebStorageEventDispatcher> event_dispatcher( | |
286 WebStorageEventDispatcher::create()); | |
287 event_dispatcher->dispatchStorageEvent(key, old_value, new_value, origin, | |
288 url, is_local_storage); | |
289 } | |
290 | |
291 //------------------------------------------------------------------------------ | |
292 | |
293 WebIDBFactory* RendererWebKitClientImpl::idbFactory() { | |
294 if (!web_idb_factory_.get()) { | |
295 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
296 web_idb_factory_.reset(WebIDBFactory::create()); | |
297 else | |
298 web_idb_factory_.reset(new RendererWebIDBFactoryImpl()); | |
299 } | |
300 return web_idb_factory_.get(); | |
301 } | |
302 | |
303 void RendererWebKitClientImpl::createIDBKeysFromSerializedValuesAndKeyPath( | |
304 const WebVector<WebSerializedScriptValue>& values, | |
305 const WebString& keyPath, | |
306 WebVector<WebIDBKey>& keys_out) { | |
307 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | |
308 WebVector<WebIDBKey> keys(values.size()); | |
309 for (size_t i = 0; i < values.size(); ++i) { | |
310 keys[i] = WebIDBKey::createFromValueAndKeyPath( | |
311 values[i], WebIDBKeyPath::create(keyPath)); | |
312 } | |
313 keys_out.swap(keys); | |
314 } | |
315 | |
316 WebSerializedScriptValue | |
317 RendererWebKitClientImpl::injectIDBKeyIntoSerializedValue(const WebIDBKey& key, | |
318 const WebSerializedScriptValue& value, | |
319 const WebString& keyPath) { | |
320 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | |
321 return WebIDBKey::injectIDBKeyIntoSerializedValue( | |
322 key, value, WebIDBKeyPath::create(keyPath)); | |
323 } | |
324 | |
325 //------------------------------------------------------------------------------ | |
326 | |
327 WebFileSystem* RendererWebKitClientImpl::fileSystem() { | |
328 if (!web_file_system_.get()) | |
329 web_file_system_.reset(new WebFileSystemImpl()); | |
330 return web_file_system_.get(); | |
331 } | |
332 | |
333 //------------------------------------------------------------------------------ | |
334 | |
335 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension( | |
336 const WebString& file_extension) { | |
337 if (IsPluginProcess()) | |
338 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | |
339 | |
340 // The sandbox restricts our access to the registry, so we need to proxy | |
341 // these calls over to the browser process. | |
342 std::string mime_type; | |
343 RenderThread::current()->Send( | |
344 new MimeRegistryMsg_GetMimeTypeFromExtension( | |
345 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); | |
346 return ASCIIToUTF16(mime_type); | |
347 | |
348 } | |
349 | |
350 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile( | |
351 const WebString& file_path) { | |
352 if (IsPluginProcess()) | |
353 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); | |
354 | |
355 // The sandbox restricts our access to the registry, so we need to proxy | |
356 // these calls over to the browser process. | |
357 std::string mime_type; | |
358 RenderThread::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( | |
359 FilePath(webkit_glue::WebStringToFilePathString(file_path)), | |
360 &mime_type)); | |
361 return ASCIIToUTF16(mime_type); | |
362 | |
363 } | |
364 | |
365 WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType( | |
366 const WebString& mime_type) { | |
367 if (IsPluginProcess()) | |
368 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); | |
369 | |
370 // The sandbox restricts our access to the registry, so we need to proxy | |
371 // these calls over to the browser process. | |
372 FilePath::StringType file_extension; | |
373 RenderThread::current()->Send( | |
374 new MimeRegistryMsg_GetPreferredExtensionForMimeType( | |
375 UTF16ToASCII(mime_type), &file_extension)); | |
376 return webkit_glue::FilePathStringToWebString(file_extension); | |
377 } | |
378 | |
379 //------------------------------------------------------------------------------ | |
380 | |
381 bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, | |
382 long long& result) { | |
383 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize( | |
384 webkit_glue::WebStringToFilePath(path), | |
385 reinterpret_cast<int64*>(&result)))) { | |
386 return result >= 0; | |
387 } | |
388 | |
389 result = -1; | |
390 return false; | |
391 } | |
392 | |
393 void RendererWebKitClientImpl::FileUtilities::revealFolderInOS( | |
394 const WebString& path) { | |
395 FilePath file_path(webkit_glue::WebStringToFilePath(path)); | |
396 file_util::AbsolutePath(&file_path); | |
397 RenderThread::current()->Send(new ViewHostMsg_RevealFolderInOS(file_path)); | |
398 } | |
399 | |
400 bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime( | |
401 const WebString& path, | |
402 double& result) { | |
403 base::Time time; | |
404 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime( | |
405 webkit_glue::WebStringToFilePath(path), &time))) { | |
406 result = time.ToDoubleT(); | |
407 return !time.is_null(); | |
408 } | |
409 | |
410 result = 0; | |
411 return false; | |
412 } | |
413 | |
414 base::PlatformFile RendererWebKitClientImpl::FileUtilities::openFile( | |
415 const WebString& path, | |
416 int mode) { | |
417 IPC::PlatformFileForTransit handle = IPC::InvalidPlatformFileForTransit(); | |
418 SendSyncMessageFromAnyThread(new FileUtilitiesMsg_OpenFile( | |
419 webkit_glue::WebStringToFilePath(path), mode, &handle)); | |
420 return IPC::PlatformFileForTransitToPlatformFile(handle); | |
421 } | |
422 | |
423 //------------------------------------------------------------------------------ | |
424 | |
425 #if defined(OS_WIN) | |
426 | |
427 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { | |
428 LOGFONT logfont; | |
429 GetObject(font, sizeof(LOGFONT), &logfont); | |
430 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); | |
431 } | |
432 | |
433 #elif defined(OS_LINUX) | |
434 | |
435 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( | |
436 const WebKit::WebUChar* characters, | |
437 size_t num_characters, | |
438 const char* preferred_locale) { | |
439 base::AutoLock lock(unicode_font_families_mutex_); | |
440 const std::string key(reinterpret_cast<const char*>(characters), | |
441 num_characters * sizeof(characters[0])); | |
442 const std::map<std::string, std::string>::const_iterator iter = | |
443 unicode_font_families_.find(key); | |
444 if (iter != unicode_font_families_.end()) | |
445 return WebString::fromUTF8(iter->second); | |
446 | |
447 const std::string family_name = | |
448 renderer_sandbox_support::getFontFamilyForCharacters(characters, | |
449 num_characters, | |
450 preferred_locale); | |
451 unicode_font_families_.insert(make_pair(key, family_name)); | |
452 return WebString::fromUTF8(family_name); | |
453 } | |
454 | |
455 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( | |
456 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | |
457 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out); | |
458 } | |
459 | |
460 #elif defined(OS_MACOSX) | |
461 | |
462 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, | |
463 ATSFontContainerRef* out) { | |
464 DCHECK(srcFont); | |
465 DCHECK(out); | |
466 | |
467 uint32 font_data_size; | |
468 FontDescriptor src_font_descriptor(srcFont); | |
469 base::SharedMemoryHandle font_data; | |
470 if (!RenderThread::current()->Send(new ViewHostMsg_LoadFont( | |
471 src_font_descriptor, &font_data_size, &font_data))) { | |
472 LOG(ERROR) << "Sending ViewHostMsg_LoadFont() IPC failed for " << | |
473 src_font_descriptor.font_name; | |
474 *out = kATSFontContainerRefUnspecified; | |
475 return false; | |
476 } | |
477 | |
478 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle()) { | |
479 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " << | |
480 src_font_descriptor.font_name; | |
481 *out = kATSFontContainerRefUnspecified; | |
482 return false; | |
483 } | |
484 | |
485 return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, out); | |
486 } | |
487 | |
488 #endif | |
489 | |
490 //------------------------------------------------------------------------------ | |
491 | |
492 WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile( | |
493 const WebString& vfs_file_name, int desired_flags) { | |
494 return DatabaseUtil::databaseOpenFile(vfs_file_name, desired_flags); | |
495 } | |
496 | |
497 int RendererWebKitClientImpl::databaseDeleteFile( | |
498 const WebString& vfs_file_name, bool sync_dir) { | |
499 return DatabaseUtil::databaseDeleteFile(vfs_file_name, sync_dir); | |
500 } | |
501 | |
502 long RendererWebKitClientImpl::databaseGetFileAttributes( | |
503 const WebString& vfs_file_name) { | |
504 return DatabaseUtil::databaseGetFileAttributes(vfs_file_name); | |
505 } | |
506 | |
507 long long RendererWebKitClientImpl::databaseGetFileSize( | |
508 const WebString& vfs_file_name) { | |
509 return DatabaseUtil::databaseGetFileSize(vfs_file_name); | |
510 } | |
511 | |
512 WebKit::WebSharedWorkerRepository* | |
513 RendererWebKitClientImpl::sharedWorkerRepository() { | |
514 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
515 switches::kDisableSharedWorkers)) { | |
516 return shared_worker_repository_.get(); | |
517 } else { | |
518 return NULL; | |
519 } | |
520 } | |
521 | |
522 WebKit::WebGraphicsContext3D* | |
523 RendererWebKitClientImpl::createGraphicsContext3D() { | |
524 // The WebGraphicsContext3DInProcessImpl code path is used for | |
525 // layout tests (though not through this code) as well as for | |
526 // debugging and bringing up new ports. | |
527 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | |
528 return new webkit::gpu::WebGraphicsContext3DInProcessImpl(); | |
529 } else { | |
530 #if defined(ENABLE_GPU) | |
531 return new WebGraphicsContext3DCommandBufferImpl(); | |
532 #else | |
533 return NULL; | |
534 #endif | |
535 } | |
536 } | |
537 | |
538 WebAudioDevice* | |
539 RendererWebKitClientImpl::createAudioDevice( | |
540 size_t buffer_size, | |
541 unsigned channels, | |
542 double sample_rate, | |
543 WebAudioDevice::RenderCallback* callback) { | |
544 return new RendererWebAudioDeviceImpl(buffer_size, | |
545 channels, | |
546 sample_rate, | |
547 callback); | |
548 } | |
549 | |
550 //------------------------------------------------------------------------------ | |
551 | |
552 WebKit::WebString RendererWebKitClientImpl::signedPublicKeyAndChallengeString( | |
553 unsigned key_size_index, | |
554 const WebKit::WebString& challenge, | |
555 const WebKit::WebURL& url) { | |
556 std::string signed_public_key; | |
557 RenderThread::current()->Send(new ViewHostMsg_Keygen( | |
558 static_cast<uint32>(key_size_index), | |
559 challenge.utf8(), | |
560 GURL(url), | |
561 &signed_public_key)); | |
562 return WebString::fromUTF8(signed_public_key); | |
563 } | |
564 | |
565 //------------------------------------------------------------------------------ | |
566 | |
567 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | |
568 if (!blob_registry_.get()) | |
569 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | |
570 return blob_registry_.get(); | |
571 } | |
OLD | NEW |