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

Side by Side Diff: chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 years, 8 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
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 "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h" 5 #include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
8 #include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h" 9 #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_font_file_host.h"
10 #include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h" 11 #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_menu_host.h"
12 #include "chrome/renderer/pepper/pepper_flash_renderer_host.h" 13 #include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
13 #include "chrome/renderer/pepper/pepper_uma_host.h" 14 #include "chrome/renderer/pepper/pepper_uma_host.h"
14 #include "components/pdf/renderer/pepper_pdf_host.h" 15 #include "components/pdf/renderer/pepper_pdf_host.h"
15 #include "content/public/renderer/renderer_ppapi_host.h" 16 #include "content/public/renderer/renderer_ppapi_host.h"
16 #include "ppapi/host/ppapi_host.h" 17 #include "ppapi/host/ppapi_host.h"
17 #include "ppapi/host/resource_host.h" 18 #include "ppapi/host/resource_host.h"
18 #include "ppapi/proxy/ppapi_message_utils.h" 19 #include "ppapi/proxy/ppapi_message_utils.h"
19 #include "ppapi/proxy/ppapi_messages.h" 20 #include "ppapi/proxy/ppapi_messages.h"
20 #include "ppapi/shared_impl/ppapi_permissions.h" 21 #include "ppapi/shared_impl/ppapi_permissions.h"
21 22
22 using ppapi::host::ResourceHost; 23 using ppapi::host::ResourceHost;
23 24
24 ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory( 25 ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory(
25 content::RendererPpapiHost* host) 26 content::RendererPpapiHost* host)
26 : host_(host) {} 27 : host_(host) {}
27 28
28 ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() {} 29 ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() {}
29 30
30 scoped_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHost( 31 std::unique_ptr<ResourceHost>
32 ChromeRendererPepperHostFactory::CreateResourceHost(
31 ppapi::host::PpapiHost* host, 33 ppapi::host::PpapiHost* host,
32 PP_Resource resource, 34 PP_Resource resource,
33 PP_Instance instance, 35 PP_Instance instance,
34 const IPC::Message& message) { 36 const IPC::Message& message) {
35 DCHECK_EQ(host_->GetPpapiHost(), host); 37 DCHECK_EQ(host_->GetPpapiHost(), host);
36 38
37 // Make sure the plugin is giving us a valid instance for this resource. 39 // Make sure the plugin is giving us a valid instance for this resource.
38 if (!host_->IsValidInstance(instance)) 40 if (!host_->IsValidInstance(instance))
39 return scoped_ptr<ResourceHost>(); 41 return nullptr;
40 42
41 if (host_->GetPpapiHost()->permissions().HasPermission( 43 if (host_->GetPpapiHost()->permissions().HasPermission(
42 ppapi::PERMISSION_FLASH)) { 44 ppapi::PERMISSION_FLASH)) {
43 switch (message.type()) { 45 switch (message.type()) {
44 case PpapiHostMsg_Flash_Create::ID: { 46 case PpapiHostMsg_Flash_Create::ID: {
45 return scoped_ptr<ResourceHost>( 47 return base::WrapUnique(
46 new PepperFlashRendererHost(host_, instance, resource)); 48 new PepperFlashRendererHost(host_, instance, resource));
47 } 49 }
48 case PpapiHostMsg_FlashFullscreen_Create::ID: { 50 case PpapiHostMsg_FlashFullscreen_Create::ID: {
49 return scoped_ptr<ResourceHost>( 51 return base::WrapUnique(
50 new PepperFlashFullscreenHost(host_, instance, resource)); 52 new PepperFlashFullscreenHost(host_, instance, resource));
51 } 53 }
52 case PpapiHostMsg_FlashMenu_Create::ID: { 54 case PpapiHostMsg_FlashMenu_Create::ID: {
53 ppapi::proxy::SerializedFlashMenu serialized_menu; 55 ppapi::proxy::SerializedFlashMenu serialized_menu;
54 if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>( 56 if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>(
55 message, &serialized_menu)) { 57 message, &serialized_menu)) {
56 return scoped_ptr<ResourceHost>(new PepperFlashMenuHost( 58 return base::WrapUnique(new PepperFlashMenuHost(
57 host_, instance, resource, serialized_menu)); 59 host_, instance, resource, serialized_menu));
58 } 60 }
59 break; 61 break;
60 } 62 }
61 } 63 }
62 } 64 }
63 65
64 // TODO(raymes): PDF also needs access to the FlashFontFileHost currently. 66 // TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
65 // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get 67 // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
66 // rid of its use in PDF if possible. 68 // rid of its use in PDF if possible.
67 if (host_->GetPpapiHost()->permissions().HasPermission( 69 if (host_->GetPpapiHost()->permissions().HasPermission(
68 ppapi::PERMISSION_FLASH) || 70 ppapi::PERMISSION_FLASH) ||
69 host_->GetPpapiHost()->permissions().HasPermission( 71 host_->GetPpapiHost()->permissions().HasPermission(
70 ppapi::PERMISSION_PRIVATE)) { 72 ppapi::PERMISSION_PRIVATE)) {
71 switch (message.type()) { 73 switch (message.type()) {
72 case PpapiHostMsg_FlashFontFile_Create::ID: { 74 case PpapiHostMsg_FlashFontFile_Create::ID: {
73 ppapi::proxy::SerializedFontDescription description; 75 ppapi::proxy::SerializedFontDescription description;
74 PP_PrivateFontCharset charset; 76 PP_PrivateFontCharset charset;
75 if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>( 77 if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(
76 message, &description, &charset)) { 78 message, &description, &charset)) {
77 return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost( 79 return base::WrapUnique(new PepperFlashFontFileHost(
78 host_, instance, resource, description, charset)); 80 host_, instance, resource, description, charset));
79 } 81 }
80 break; 82 break;
81 } 83 }
82 case PpapiHostMsg_FlashDRM_Create::ID: 84 case PpapiHostMsg_FlashDRM_Create::ID:
83 return scoped_ptr<ResourceHost>( 85 return base::WrapUnique(
84 new PepperFlashDRMRendererHost(host_, instance, resource)); 86 new PepperFlashDRMRendererHost(host_, instance, resource));
85 } 87 }
86 } 88 }
87 89
88 if (host_->GetPpapiHost()->permissions().HasPermission( 90 if (host_->GetPpapiHost()->permissions().HasPermission(
89 ppapi::PERMISSION_PRIVATE)) { 91 ppapi::PERMISSION_PRIVATE)) {
90 switch (message.type()) { 92 switch (message.type()) {
91 case PpapiHostMsg_PDF_Create::ID: { 93 case PpapiHostMsg_PDF_Create::ID: {
92 return scoped_ptr<ResourceHost>( 94 return base::WrapUnique(
93 new pdf::PepperPDFHost(host_, instance, resource)); 95 new pdf::PepperPDFHost(host_, instance, resource));
94 } 96 }
95 } 97 }
96 } 98 }
97 99
98 // Permissions for the following interfaces will be checked at the 100 // Permissions for the following interfaces will be checked at the
99 // time of the corresponding instance's method calls. Currently these 101 // time of the corresponding instance's method calls. Currently these
100 // interfaces are available only for whitelisted apps which may not have 102 // interfaces are available only for whitelisted apps which may not have
101 // access to the other private interfaces. 103 // access to the other private interfaces.
102 switch (message.type()) { 104 switch (message.type()) {
103 case PpapiHostMsg_UMA_Create::ID: { 105 case PpapiHostMsg_UMA_Create::ID: {
104 return scoped_ptr<ResourceHost>( 106 return base::WrapUnique(new PepperUMAHost(host_, instance, resource));
105 new PepperUMAHost(host_, instance, resource));
106 } 107 }
107 } 108 }
108 109
109 return scoped_ptr<ResourceHost>(); 110 return nullptr;
110 } 111 }
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h ('k') | chrome/renderer/pepper/pepper_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698