Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 10823086: Make plugins work in a RenderViewTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed TODOs Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/renderer_webkitplatformsupport_impl.h" 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "base/synchronization/lock.h" 72 #include "base/synchronization/lock.h"
73 #include "content/common/child_process_sandbox_support_impl_linux.h" 73 #include "content/common/child_process_sandbox_support_impl_linux.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon tFamily.h" 74 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon tFamily.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebSan dboxSupport.h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebSan dboxSupport.h"
76 #endif 76 #endif
77 77
78 #if defined(OS_POSIX) 78 #if defined(OS_POSIX)
79 #include "base/file_descriptor_posix.h" 79 #include "base/file_descriptor_posix.h"
80 #endif 80 #endif
81 81
82 using content::RenderThread;
82 using WebKit::WebAudioDevice; 83 using WebKit::WebAudioDevice;
83 using WebKit::WebBlobRegistry; 84 using WebKit::WebBlobRegistry;
84 using WebKit::WebFileInfo; 85 using WebKit::WebFileInfo;
85 using WebKit::WebFileSystem; 86 using WebKit::WebFileSystem;
86 using WebKit::WebFrame; 87 using WebKit::WebFrame;
87 using WebKit::WebGamepads; 88 using WebKit::WebGamepads;
88 using WebKit::WebIDBFactory; 89 using WebKit::WebIDBFactory;
89 using WebKit::WebIDBKey; 90 using WebKit::WebIDBKey;
90 using WebKit::WebIDBKeyPath; 91 using WebKit::WebIDBKeyPath;
91 using WebKit::WebKitPlatformSupport; 92 using WebKit::WebKitPlatformSupport;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 }; 161 };
161 #endif // defined(OS_ANDROID) 162 #endif // defined(OS_ANDROID)
162 163
163 //------------------------------------------------------------------------------ 164 //------------------------------------------------------------------------------
164 165
165 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() 166 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl()
166 : clipboard_client_(new RendererClipboardClient), 167 : clipboard_client_(new RendererClipboardClient),
167 clipboard_(new webkit_glue::WebClipboardImpl(clipboard_client_.get())), 168 clipboard_(new webkit_glue::WebClipboardImpl(clipboard_client_.get())),
168 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), 169 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry),
169 sudden_termination_disables_(0), 170 sudden_termination_disables_(0),
171 plugin_refresh_allowed_(true),
170 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { 172 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) {
171 if (g_sandbox_enabled) { 173 if (g_sandbox_enabled) {
172 sandbox_support_.reset( 174 sandbox_support_.reset(
173 new RendererWebKitPlatformSupportImpl::SandboxSupport); 175 new RendererWebKitPlatformSupportImpl::SandboxSupport);
174 } else { 176 } else {
175 DVLOG(1) << "Disabling sandbox support for testing."; 177 DVLOG(1) << "Disabling sandbox support for testing.";
176 } 178 }
177 } 179 }
178 180
179 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() { 181 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() {
180 } 182 }
181 183
182 //------------------------------------------------------------------------------ 184 //------------------------------------------------------------------------------
183 185
184 namespace { 186 namespace {
185 187
186 bool SendSyncMessageFromAnyThreadInternal(IPC::SyncMessage* msg) { 188 bool SendSyncMessageFromAnyThreadInternal(IPC::SyncMessage* msg) {
187 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 189 RenderThread* render_thread = RenderThread::Get();
188 if (render_thread) 190 if (render_thread)
189 return render_thread->Send(msg); 191 return render_thread->Send(msg);
190 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( 192 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter(
191 ChildThread::current()->sync_message_filter()); 193 ChildThread::current()->sync_message_filter());
192 return sync_msg_filter->Send(msg); 194 return sync_msg_filter->Send(msg);
193 } 195 }
194 196
195 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) { 197 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) {
196 base::TimeTicks begin = base::TimeTicks::Now(); 198 base::TimeTicks begin = base::TimeTicks::Now();
197 const bool success = SendSyncMessageFromAnyThreadInternal(msg); 199 const bool success = SendSyncMessageFromAnyThreadInternal(msg);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 double response_time, 291 double response_time,
290 const char* data, 292 const char* data,
291 size_t size) { 293 size_t size) {
292 if (!CheckPreparsedJsCachingEnabled()) 294 if (!CheckPreparsedJsCachingEnabled())
293 return; 295 return;
294 296
295 // Let the browser know we generated cacheable metadata for this resource. The 297 // Let the browser know we generated cacheable metadata for this resource. The
296 // browser may cache it and return it on subsequent responses to speed 298 // browser may cache it and return it on subsequent responses to speed
297 // the processing of this resource. 299 // the processing of this resource.
298 std::vector<char> copy(data, data + size); 300 std::vector<char> copy(data, data + size);
299 RenderThreadImpl::current()->Send( 301 RenderThread::Get()->Send(
300 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy)); 302 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy));
301 } 303 }
302 304
303 WebString RendererWebKitPlatformSupportImpl::defaultLocale() { 305 WebString RendererWebKitPlatformSupportImpl::defaultLocale() {
304 return ASCIIToUTF16(RenderThreadImpl::Get()->GetLocale()); 306 return ASCIIToUTF16(RenderThread::Get()->GetLocale());
305 } 307 }
306 308
307 void RendererWebKitPlatformSupportImpl::suddenTerminationChanged(bool enabled) { 309 void RendererWebKitPlatformSupportImpl::suddenTerminationChanged(bool enabled) {
308 if (enabled) { 310 if (enabled) {
309 // We should not get more enables than disables, but we want it to be a 311 // We should not get more enables than disables, but we want it to be a
310 // non-fatal error if it does happen. 312 // non-fatal error if it does happen.
311 DCHECK_GT(sudden_termination_disables_, 0); 313 DCHECK_GT(sudden_termination_disables_, 0);
312 sudden_termination_disables_ = std::max(sudden_termination_disables_ - 1, 314 sudden_termination_disables_ = std::max(sudden_termination_disables_ - 1,
313 0); 315 0);
314 if (sudden_termination_disables_ != 0) 316 if (sudden_termination_disables_ != 0)
315 return; 317 return;
316 } else { 318 } else {
317 sudden_termination_disables_++; 319 sudden_termination_disables_++;
318 if (sudden_termination_disables_ != 1) 320 if (sudden_termination_disables_ != 1)
319 return; 321 return;
320 } 322 }
321 323
322 RenderThreadImpl* thread = RenderThreadImpl::current(); 324 RenderThread* thread = RenderThread::Get();
323 if (thread) // NULL in unittests. 325 if (thread) // NULL in unittests.
324 thread->Send(new ViewHostMsg_SuddenTerminationChanged(enabled)); 326 thread->Send(new ViewHostMsg_SuddenTerminationChanged(enabled));
325 } 327 }
326 328
327 WebStorageNamespace* 329 WebStorageNamespace*
328 RendererWebKitPlatformSupportImpl::createLocalStorageNamespace( 330 RendererWebKitPlatformSupportImpl::createLocalStorageNamespace(
329 const WebString& path, unsigned quota) { 331 const WebString& path, unsigned quota) {
330 return new WebStorageNamespaceImpl(); 332 return new WebStorageNamespaceImpl();
331 } 333 }
332 334
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 380
379 WebString 381 WebString
380 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( 382 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
381 const WebString& file_extension) { 383 const WebString& file_extension) {
382 if (IsPluginProcess()) 384 if (IsPluginProcess())
383 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); 385 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
384 386
385 // The sandbox restricts our access to the registry, so we need to proxy 387 // The sandbox restricts our access to the registry, so we need to proxy
386 // these calls over to the browser process. 388 // these calls over to the browser process.
387 std::string mime_type; 389 std::string mime_type;
388 RenderThreadImpl::current()->Send( 390 RenderThread::Get()->Send(
389 new MimeRegistryMsg_GetMimeTypeFromExtension( 391 new MimeRegistryMsg_GetMimeTypeFromExtension(
390 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); 392 webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
391 return ASCIIToUTF16(mime_type); 393 return ASCIIToUTF16(mime_type);
392 394
393 } 395 }
394 396
395 WebString RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeFromFile( 397 WebString RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeFromFile(
396 const WebString& file_path) { 398 const WebString& file_path) {
397 if (IsPluginProcess()) 399 if (IsPluginProcess())
398 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); 400 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path);
399 401
400 // The sandbox restricts our access to the registry, so we need to proxy 402 // The sandbox restricts our access to the registry, so we need to proxy
401 // these calls over to the browser process. 403 // these calls over to the browser process.
402 std::string mime_type; 404 std::string mime_type;
403 RenderThreadImpl::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( 405 RenderThread::Get()->Send(new MimeRegistryMsg_GetMimeTypeFromFile(
404 FilePath(webkit_glue::WebStringToFilePathString(file_path)), 406 FilePath(webkit_glue::WebStringToFilePathString(file_path)),
405 &mime_type)); 407 &mime_type));
406 return ASCIIToUTF16(mime_type); 408 return ASCIIToUTF16(mime_type);
407 409
408 } 410 }
409 411
410 WebString 412 WebString
411 RendererWebKitPlatformSupportImpl::MimeRegistry::preferredExtensionForMIMEType( 413 RendererWebKitPlatformSupportImpl::MimeRegistry::preferredExtensionForMIMEType(
412 const WebString& mime_type) { 414 const WebString& mime_type) {
413 if (IsPluginProcess()) 415 if (IsPluginProcess())
414 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); 416 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type);
415 417
416 // The sandbox restricts our access to the registry, so we need to proxy 418 // The sandbox restricts our access to the registry, so we need to proxy
417 // these calls over to the browser process. 419 // these calls over to the browser process.
418 FilePath::StringType file_extension; 420 FilePath::StringType file_extension;
419 RenderThreadImpl::current()->Send( 421 RenderThread::Get()->Send(
420 new MimeRegistryMsg_GetPreferredExtensionForMimeType( 422 new MimeRegistryMsg_GetPreferredExtensionForMimeType(
421 UTF16ToASCII(mime_type), &file_extension)); 423 UTF16ToASCII(mime_type), &file_extension));
422 return webkit_glue::FilePathStringToWebString(file_extension); 424 return webkit_glue::FilePathStringToWebString(file_extension);
423 } 425 }
424 426
425 //------------------------------------------------------------------------------ 427 //------------------------------------------------------------------------------
426 428
427 bool RendererWebKitPlatformSupportImpl::FileUtilities::getFileInfo( 429 bool RendererWebKitPlatformSupportImpl::FileUtilities::getFileInfo(
428 const WebString& path, 430 const WebString& path,
429 WebFileInfo& web_file_info) { 431 WebFileInfo& web_file_info) {
(...skipping 19 matching lines...) Expand all
449 } 451 }
450 452
451 //------------------------------------------------------------------------------ 453 //------------------------------------------------------------------------------
452 454
453 #if defined(OS_WIN) 455 #if defined(OS_WIN)
454 456
455 bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( 457 bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded(
456 HFONT font) { 458 HFONT font) {
457 LOGFONT logfont; 459 LOGFONT logfont;
458 GetObject(font, sizeof(LOGFONT), &logfont); 460 GetObject(font, sizeof(LOGFONT), &logfont);
459 RenderThreadImpl::current()->PreCacheFont(logfont); 461 RenderThread::Get()->PreCacheFont(logfont);
460 return true; 462 return true;
461 } 463 }
462 464
463 #elif defined(OS_MACOSX) 465 #elif defined(OS_MACOSX)
464 466
465 bool RendererWebKitPlatformSupportImpl::SandboxSupport::loadFont( 467 bool RendererWebKitPlatformSupportImpl::SandboxSupport::loadFont(
466 NSFont* src_font, CGFontRef* out, uint32* font_id) { 468 NSFont* src_font, CGFontRef* out, uint32* font_id) {
467 uint32 font_data_size; 469 uint32 font_data_size;
468 FontDescriptor src_font_descriptor(src_font); 470 FontDescriptor src_font_descriptor(src_font);
469 base::SharedMemoryHandle font_data; 471 base::SharedMemoryHandle font_data;
470 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_LoadFont( 472 if (!RenderThread::Get()->Send(new ViewHostMsg_LoadFont(
471 src_font_descriptor, &font_data_size, &font_data, font_id))) { 473 src_font_descriptor, &font_data_size, &font_data, font_id))) {
472 *out = NULL; 474 *out = NULL;
473 *font_id = 0; 475 *font_id = 0;
474 return false; 476 return false;
475 } 477 }
476 478
477 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() || 479 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() ||
478 *font_id == 0) { 480 *font_id == 0) {
479 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " << 481 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " <<
480 src_font_descriptor.font_name; 482 src_font_descriptor.font_name;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 643 }
642 644
643 //------------------------------------------------------------------------------ 645 //------------------------------------------------------------------------------
644 646
645 WebKit::WebString 647 WebKit::WebString
646 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( 648 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString(
647 unsigned key_size_index, 649 unsigned key_size_index,
648 const WebKit::WebString& challenge, 650 const WebKit::WebString& challenge,
649 const WebKit::WebURL& url) { 651 const WebKit::WebURL& url) {
650 std::string signed_public_key; 652 std::string signed_public_key;
651 RenderThreadImpl::current()->Send(new ViewHostMsg_Keygen( 653 RenderThread::Get()->Send(new ViewHostMsg_Keygen(
652 static_cast<uint32>(key_size_index), 654 static_cast<uint32>(key_size_index),
653 challenge.utf8(), 655 challenge.utf8(),
654 GURL(url), 656 GURL(url),
655 &signed_public_key)); 657 &signed_public_key));
656 return WebString::fromUTF8(signed_public_key); 658 return WebString::fromUTF8(signed_public_key);
657 } 659 }
658 660
659 //------------------------------------------------------------------------------ 661 //------------------------------------------------------------------------------
660 662
661 void RendererWebKitPlatformSupportImpl::screenColorProfile( 663 void RendererWebKitPlatformSupportImpl::screenColorProfile(
662 WebVector<char>* to_profile) { 664 WebVector<char>* to_profile) {
663 std::vector<char> profile; 665 std::vector<char> profile;
664 RenderThreadImpl::current()->Send( 666 RenderThread::Get()->Send(
665 new ViewHostMsg_GetMonitorColorProfile(&profile)); 667 new ViewHostMsg_GetMonitorColorProfile(&profile));
666 *to_profile = profile; 668 *to_profile = profile;
667 } 669 }
668 670
669 //------------------------------------------------------------------------------ 671 //------------------------------------------------------------------------------
670 672
671 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { 673 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() {
672 // ChildThread::current can be NULL when running some tests. 674 // ChildThread::current can be NULL when running some tests.
673 if (!blob_registry_.get() && ChildThread::current()) { 675 if (!blob_registry_.get() && ChildThread::current()) {
674 blob_registry_.reset(new WebBlobRegistryImpl(ChildThread::current())); 676 blob_registry_.reset(new WebBlobRegistryImpl(ChildThread::current()));
675 } 677 }
676 return blob_registry_.get(); 678 return blob_registry_.get();
677 } 679 }
678 680
679 //------------------------------------------------------------------------------ 681 //------------------------------------------------------------------------------
680 682
681 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { 683 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
682 if (!gamepad_shared_memory_reader_.get()) 684 if (!gamepad_shared_memory_reader_.get())
683 gamepad_shared_memory_reader_.reset(new content::GamepadSharedMemoryReader); 685 gamepad_shared_memory_reader_.reset(new content::GamepadSharedMemoryReader);
684 gamepad_shared_memory_reader_->SampleGamepads(gamepads); 686 gamepad_shared_memory_reader_->SampleGamepads(gamepads);
685 } 687 }
686 688
687 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( 689 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent(
688 const WebKit::WebURL& url) { 690 const WebKit::WebURL& url) {
689 return WebKitPlatformSupportImpl::userAgent(url); 691 return WebKitPlatformSupportImpl::userAgent(url);
690 } 692 }
691 693
692 void RendererWebKitPlatformSupportImpl::GetPlugins( 694 void RendererWebKitPlatformSupportImpl::GetPlugins(
693 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { 695 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) {
694 if (!RenderThreadImpl::current()->plugin_refresh_allowed()) 696 if (!plugin_refresh_allowed_)
695 refresh = false; 697 refresh = false;
696 RenderThreadImpl::current()->Send( 698 RenderThread::Get()->Send(
697 new ViewHostMsg_GetPlugins(refresh, plugins)); 699 new ViewHostMsg_GetPlugins(refresh, plugins));
698 } 700 }
699 701
700 //------------------------------------------------------------------------------ 702 //------------------------------------------------------------------------------
701 703
702 WebPeerConnection00Handler* 704 WebPeerConnection00Handler*
703 RendererWebKitPlatformSupportImpl::createPeerConnection00Handler( 705 RendererWebKitPlatformSupportImpl::createPeerConnection00Handler(
704 WebPeerConnection00HandlerClient* client) { 706 WebPeerConnection00HandlerClient* client) {
705 WebFrame* web_frame = WebFrame::frameForCurrentContext(); 707 WebFrame* web_frame = WebFrame::frameForCurrentContext();
706 if (!web_frame) 708 if (!web_frame)
(...skipping 21 matching lines...) Expand all
728 bool enable) { 730 bool enable) {
729 bool was_enabled = g_sandbox_enabled; 731 bool was_enabled = g_sandbox_enabled;
730 g_sandbox_enabled = enable; 732 g_sandbox_enabled = enable;
731 return was_enabled; 733 return was_enabled;
732 } 734 }
733 735
734 GpuChannelHostFactory* 736 GpuChannelHostFactory*
735 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() { 737 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
736 return RenderThreadImpl::current(); 738 return RenderThreadImpl::current();
737 } 739 }
OLDNEW
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698