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

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

Issue 7990005: Use a placeholder instead of the default plugin for missing plug-ins on Mac and Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/render_view.h" 5 #include "content/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 if (load_progress_tracker_ == NULL) 576 if (load_progress_tracker_ == NULL)
577 load_progress_tracker_.reset(new LoadProgressTracker(this)); 577 load_progress_tracker_.reset(new LoadProgressTracker(this));
578 } 578 }
579 579
580 void RenderView::PluginCrashed(const FilePath& plugin_path) { 580 void RenderView::PluginCrashed(const FilePath& plugin_path) {
581 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); 581 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path));
582 } 582 }
583 583
584 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, 584 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
585 const WebPluginParams& params) { 585 const WebPluginParams& params) {
586 webkit::WebPluginInfo info; 586 std::vector<webkit::WebPluginInfo> plugins;
587 std::string mime_type; 587 std::vector<std::string> mime_types;
588 bool found = GetPluginInfo(params.url, frame->top()->document().url(), 588 std::vector<bool> allowed;
589 params.mimeType.utf8(), &info, &mime_type); 589 GetMatchingPlugins(
590 if (!found) 590 params.url, frame->top()->document().url(),
591 return NULL; 591 params.mimeType.utf8(), &plugins, &mime_types, &allowed);
592 592 for (size_t i = 0; i < plugins.size(); ++i) {
593 bool pepper_plugin_was_registered = false; 593 if (allowed[i]) {
594 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( 594 bool pepper_plugin_was_registered = false;
595 pepper_delegate_.CreatePepperPluginModule(info, 595 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
596 &pepper_plugin_was_registered)); 596 pepper_delegate_.CreatePepperPluginModule(
597 if (pepper_plugin_was_registered) { 597 plugins[i], &pepper_plugin_was_registered));
598 if (pepper_module) 598 if (pepper_plugin_was_registered) {
599 return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); 599 if (pepper_module)
600 return NULL; 600 return CreatePepperPlugin(frame, params, plugins[i].path,
601 pepper_module.get());
602 return NULL;
603 }
604 return CreateNPAPIPlugin(frame, params, plugins[i].path, mime_types[i]);
605 }
601 } 606 }
602 return CreateNPAPIPlugin(frame, params, info.path, mime_type); 607 NOTREACHED() << "No allowed plug-in found";
608 return NULL;
603 } 609 }
604 610
605 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { 611 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) {
606 plugin_delegates_.insert(delegate); 612 plugin_delegates_.insert(delegate);
607 // If the renderer is visible, set initial visibility and focus state. 613 // If the renderer is visible, set initial visibility and focus state.
608 if (!is_hidden()) { 614 if (!is_hidden()) {
609 #if defined(OS_MACOSX) 615 #if defined(OS_MACOSX)
610 delegate->SetContainerVisibility(true); 616 delegate->SetContainerVisibility(true);
611 if (webview() && webview()->isActive()) 617 if (webview() && webview()->isActive())
612 delegate->SetWindowFocus(true); 618 delegate->SetWindowFocus(true);
613 #endif 619 #endif
614 } 620 }
615 // Plugins start assuming the content has focus (so that they work in 621 // Plugins start assuming the content has focus (so that they work in
616 // environments where RenderView isn't hosting them), so we always have to 622 // environments where RenderView isn't hosting them), so we always have to
617 // set the initial state. See webplugin_delegate_impl.h for details. 623 // set the initial state. See webplugin_delegate_impl.h for details.
618 delegate->SetContentAreaFocus(has_focus()); 624 delegate->SetContentAreaFocus(has_focus());
619 } 625 }
620 626
621 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { 627 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) {
622 plugin_delegates_.erase(delegate); 628 plugin_delegates_.erase(delegate);
623 } 629 }
624 630
625 bool RenderView::GetPluginInfo(const GURL& url, 631 void RenderView::GetMatchingPlugins(
626 const GURL& page_url, 632 const GURL& url,
627 const std::string& mime_type, 633 const GURL& page_url,
628 webkit::WebPluginInfo* plugin_info, 634 const std::string& mime_type,
629 std::string* actual_mime_type) { 635 std::vector<webkit::WebPluginInfo>* plugins,
630 bool found = false; 636 std::vector<std::string>* mime_types,
631 Send(new ViewHostMsg_GetPluginInfo( 637 std::vector<bool>* allowed) {
632 routing_id_, url, page_url, mime_type, &found, plugin_info, 638 Send(new ViewHostMsg_GetMatchingPlugins(
633 actual_mime_type)); 639 routing_id_, url, page_url, mime_type, plugins, mime_types, allowed));
634 return found;
635 } 640 }
636 641
637 base::SharedMemoryHandle RenderView::HostAllocateSharedMemoryBuffer( 642 base::SharedMemoryHandle RenderView::HostAllocateSharedMemoryBuffer(
638 uint32 buffer_size) { 643 uint32 buffer_size) {
639 base::SharedMemoryHandle mem_handle; 644 base::SharedMemoryHandle mem_handle;
640 Send(new ViewHostMsg_AllocateSharedMemoryBuffer(buffer_size, &mem_handle)); 645 Send(new ViewHostMsg_AllocateSharedMemoryBuffer(buffer_size, &mem_handle));
641 return mem_handle; 646 return mem_handle;
642 } 647 }
643 648
644 bool RenderView::OnMessageReceived(const IPC::Message& message) { 649 bool RenderView::OnMessageReceived(const IPC::Message& message) {
(...skipping 3993 matching lines...) Expand 10 before | Expand all | Expand 10 after
4638 } 4643 }
4639 4644
4640 void RenderView::OnLockMouseACK(bool succeeded) { 4645 void RenderView::OnLockMouseACK(bool succeeded) {
4641 pepper_delegate_.OnLockMouseACK(succeeded); 4646 pepper_delegate_.OnLockMouseACK(succeeded);
4642 } 4647 }
4643 4648
4644 void RenderView::OnMouseLockLost() { 4649 void RenderView::OnMouseLockLost() {
4645 pepper_delegate_.OnMouseLockLost(); 4650 pepper_delegate_.OnMouseLockLost();
4646 } 4651 }
4647 4652
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698