cef/libcef/renderer/pepper/renderer_pepper_host_factory.cc
Marshall Greenblatt 2fe1d33239 Add Pepper Flash plugin support (issue #1586).
A system-wide installation of the Pepper Flash plugin is available from Adobe
for Windows and Mac OS X platforms as a separate download. To enable automatic
detection and loading of the system-wide installation pass the
`--enable-system-flash` command-line flag.

The Pepper Flash plugin can also be loaded by specifying the file path and
version via the `--ppapi-flash-path=<path> --ppapi-flash-version=<version>`
command-line flags. The version can be identified by viewing the
manifest.json file in the same directory as the Pepper Flash plugin library.
2015-03-26 17:00:30 -04:00

88 lines
3.3 KiB
C++

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/renderer/pepper/renderer_pepper_host_factory.h"
#include "base/logging.h"
#include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
using ppapi::host::ResourceHost;
CefRendererPepperHostFactory::CefRendererPepperHostFactory(
content::RendererPpapiHost* host)
: host_(host) {}
CefRendererPepperHostFactory::~CefRendererPepperHostFactory() {}
scoped_ptr<ResourceHost> CefRendererPepperHostFactory::CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message) {
DCHECK_EQ(host_->GetPpapiHost(), host);
// Make sure the plugin is giving us a valid instance for this resource.
if (!host_->IsValidInstance(instance))
return scoped_ptr<ResourceHost>();
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_FLASH)) {
switch (message.type()) {
case PpapiHostMsg_Flash_Create::ID: {
return scoped_ptr<ResourceHost>(
new PepperFlashRendererHost(host_, instance, resource));
}
case PpapiHostMsg_FlashFullscreen_Create::ID: {
return scoped_ptr<ResourceHost>(
new PepperFlashFullscreenHost(host_, instance, resource));
}
case PpapiHostMsg_FlashMenu_Create::ID: {
ppapi::proxy::SerializedFlashMenu serialized_menu;
if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>(
message, &serialized_menu)) {
return scoped_ptr<ResourceHost>(new PepperFlashMenuHost(
host_, instance, resource, serialized_menu));
}
break;
}
}
}
// TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
// We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
// rid of its use in PDF if possible.
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_FLASH) ||
host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PRIVATE)) {
switch (message.type()) {
case PpapiHostMsg_FlashFontFile_Create::ID: {
ppapi::proxy::SerializedFontDescription description;
PP_PrivateFontCharset charset;
if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(
message, &description, &charset)) {
return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost(
host_, instance, resource, description, charset));
}
break;
}
case PpapiHostMsg_FlashDRM_Create::ID:
return scoped_ptr<ResourceHost>(
new PepperFlashDRMRendererHost(host_, instance, resource));
}
}
return scoped_ptr<ResourceHost>();
}