OLD | NEW |
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/pepper_flash_drm_renderer_host.h" | 5 #include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "content/public/renderer/pepper_plugin_instance.h" | 8 #include "content/public/renderer/pepper_plugin_instance.h" |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/host/dispatch_host_message.h" | 11 #include "ppapi/host/dispatch_host_message.h" |
12 #include "ppapi/host/host_message_context.h" | 12 #include "ppapi/host/host_message_context.h" |
13 #include "ppapi/host/ppapi_host.h" | 13 #include "ppapi/host/ppapi_host.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/proxy/ppb_file_ref_proxy.h" |
15 | 16 |
16 namespace chrome { | 17 namespace chrome { |
17 | 18 |
18 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once | 19 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once |
19 // FileRef is refactored to the browser, it won't need to be. | 20 // FileRef is refactored to the browser, it won't need to be. |
20 namespace { | 21 namespace { |
21 const base::FilePath::CharType kVoucherFilename[] = | 22 const base::FilePath::CharType kVoucherFilename[] = |
22 FILE_PATH_LITERAL("plugin.vch"); | 23 FILE_PATH_LITERAL("plugin.vch"); |
23 } // namespace | 24 } // namespace |
24 | 25 |
25 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost( | 26 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost( |
26 content::RendererPpapiHost* host, | 27 content::RendererPpapiHost* host, |
27 PP_Instance instance, | 28 PP_Instance instance, |
28 PP_Resource resource) | 29 PP_Resource resource) |
29 : ResourceHost(host->GetPpapiHost(), instance, resource), | 30 : ResourceHost(host->GetPpapiHost(), instance, resource), |
30 renderer_ppapi_host_(host), | 31 renderer_ppapi_host_(host) { |
31 weak_factory_(this) { | |
32 } | 32 } |
33 | 33 |
34 PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() { | 34 PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() { |
35 } | 35 } |
36 | 36 |
37 int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived( | 37 int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived( |
38 const IPC::Message& msg, | 38 const IPC::Message& msg, |
39 ppapi::host::HostMessageContext* context) { | 39 ppapi::host::HostMessageContext* context) { |
40 IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg) | 40 IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg) |
41 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile, | 41 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile, |
42 OnGetVoucherFile) | 42 OnGetVoucherFile) |
43 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
44 return PP_ERROR_FAILED; | 44 return PP_ERROR_FAILED; |
45 } | 45 } |
46 | 46 |
47 int32_t PepperFlashDRMRendererHost::OnGetVoucherFile( | 47 int32_t PepperFlashDRMRendererHost::OnGetVoucherFile( |
48 ppapi::host::HostMessageContext* context) { | 48 ppapi::host::HostMessageContext* context) { |
49 content::PepperPluginInstance* plugin_instance = | 49 content::PepperPluginInstance* plugin_instance = |
50 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 50 renderer_ppapi_host_->GetPluginInstance(pp_instance()); |
51 if (!plugin_instance) | 51 if (!plugin_instance) |
52 return PP_ERROR_FAILED; | 52 return PP_ERROR_FAILED; |
53 | 53 |
54 base::FilePath plugin_dir = plugin_instance->GetModulePath().DirName(); | 54 base::FilePath plugin_dir = plugin_instance->GetModulePath().DirName(); |
55 DCHECK(!plugin_dir.empty()); | 55 DCHECK(!plugin_dir.empty()); |
56 base::FilePath voucher_file = plugin_dir.Append( | 56 base::FilePath voucher_file = plugin_dir.Append( |
57 base::FilePath(kVoucherFilename)); | 57 base::FilePath(kVoucherFilename)); |
58 | 58 |
59 renderer_ppapi_host_->CreateBrowserResourceHost( | 59 ppapi::PPB_FileRef_CreateInfo create_info; |
60 pp_instance(), | 60 ppapi::proxy::PPB_FileRef_Proxy::SerializeFileRef( |
61 PpapiHostMsg_FileRef_CreateExternal(voucher_file), | 61 plugin_instance->CreateExternalFileReference(voucher_file), |
62 base::Bind(&PepperFlashDRMRendererHost::DidCreateFileRefHost, | 62 &create_info); |
63 weak_factory_.GetWeakPtr(), | 63 context->reply_msg = |
64 context->MakeReplyMessageContext(), | 64 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info); |
65 voucher_file)); | 65 return PP_OK; |
66 return PP_OK_COMPLETIONPENDING; | |
67 } | |
68 | |
69 void PepperFlashDRMRendererHost::DidCreateFileRefHost( | |
70 const ppapi::host::ReplyMessageContext& reply_context, | |
71 const base::FilePath& external_path, | |
72 int pending_resource_id) { | |
73 ppapi::FileRefCreateInfo create_info = | |
74 ppapi::MakeExternalFileRefCreateInfo(external_path, | |
75 std::string(), | |
76 pending_resource_id); | |
77 host()->SendReply(reply_context, | |
78 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info)); | |
79 } | 66 } |
80 | 67 |
81 } // namespace chrome | 68 } // namespace chrome |
82 | 69 |
OLD | NEW |