[Eraser strings] Remove unused Supervised User infobar and corresponding strings
[chromium-blink-merge.git] / chrome / renderer / pepper / chrome_renderer_pepper_host_factory.cc
bloba78d9ea330400373855380d5f7d958b8c10c165e
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 "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
7 #include "base/logging.h"
8 #include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
9 #include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
10 #include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
11 #include "chrome/renderer/pepper/pepper_flash_menu_host.h"
12 #include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
13 #include "chrome/renderer/pepper/pepper_uma_host.h"
14 #include "components/pdf/renderer/pepper_pdf_host.h"
15 #include "content/public/renderer/renderer_ppapi_host.h"
16 #include "ppapi/host/ppapi_host.h"
17 #include "ppapi/host/resource_host.h"
18 #include "ppapi/proxy/ppapi_message_utils.h"
19 #include "ppapi/proxy/ppapi_messages.h"
20 #include "ppapi/shared_impl/ppapi_permissions.h"
22 using ppapi::host::ResourceHost;
24 ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory(
25 content::RendererPpapiHost* host)
26 : host_(host) {}
28 ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() {}
30 scoped_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHost(
31 ppapi::host::PpapiHost* host,
32 PP_Resource resource,
33 PP_Instance instance,
34 const IPC::Message& message) {
35 DCHECK_EQ(host_->GetPpapiHost(), host);
37 // Make sure the plugin is giving us a valid instance for this resource.
38 if (!host_->IsValidInstance(instance))
39 return scoped_ptr<ResourceHost>();
41 if (host_->GetPpapiHost()->permissions().HasPermission(
42 ppapi::PERMISSION_FLASH)) {
43 switch (message.type()) {
44 case PpapiHostMsg_Flash_Create::ID: {
45 return scoped_ptr<ResourceHost>(
46 new PepperFlashRendererHost(host_, instance, resource));
48 case PpapiHostMsg_FlashFullscreen_Create::ID: {
49 return scoped_ptr<ResourceHost>(
50 new PepperFlashFullscreenHost(host_, instance, resource));
52 case PpapiHostMsg_FlashMenu_Create::ID: {
53 ppapi::proxy::SerializedFlashMenu serialized_menu;
54 if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>(
55 message, &serialized_menu)) {
56 return scoped_ptr<ResourceHost>(new PepperFlashMenuHost(
57 host_, instance, resource, serialized_menu));
59 break;
64 // TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
65 // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
66 // rid of its use in PDF if possible.
67 if (host_->GetPpapiHost()->permissions().HasPermission(
68 ppapi::PERMISSION_FLASH) ||
69 host_->GetPpapiHost()->permissions().HasPermission(
70 ppapi::PERMISSION_PRIVATE)) {
71 switch (message.type()) {
72 case PpapiHostMsg_FlashFontFile_Create::ID: {
73 ppapi::proxy::SerializedFontDescription description;
74 PP_PrivateFontCharset charset;
75 if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(
76 message, &description, &charset)) {
77 return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost(
78 host_, instance, resource, description, charset));
80 break;
82 case PpapiHostMsg_FlashDRM_Create::ID:
83 return scoped_ptr<ResourceHost>(
84 new PepperFlashDRMRendererHost(host_, instance, resource));
88 if (host_->GetPpapiHost()->permissions().HasPermission(
89 ppapi::PERMISSION_PRIVATE)) {
90 switch (message.type()) {
91 case PpapiHostMsg_PDF_Create::ID: {
92 return scoped_ptr<ResourceHost>(
93 new pdf::PepperPDFHost(host_, instance, resource));
98 // Permissions for the following interfaces will be checked at the
99 // time of the corresponding instance's method calls. Currently these
100 // interfaces are available only for whitelisted apps which may not have
101 // access to the other private interfaces.
102 switch (message.type()) {
103 case PpapiHostMsg_UMA_Create::ID: {
104 return scoped_ptr<ResourceHost>(
105 new PepperUMAHost(host_, instance, resource));
109 return scoped_ptr<ResourceHost>();