summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc28
-rw-r--r--chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h3
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc4
-rw-r--r--chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc73
-rw-r--r--chrome/renderer/pepper/pepper_flash_drm_renderer_host.h42
-rw-r--r--chrome/test/ppapi/ppapi_browsertest.cc10
-rw-r--r--content/browser/ppapi_plugin_process_host.cc13
-rw-r--r--content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc15
-rw-r--r--content/browser/renderer_host/pepper/browser_ppapi_host_impl.h3
-rw-r--r--content/browser/renderer_host/pepper/browser_ppapi_host_test.cc1
-rw-r--r--content/public/browser/browser_ppapi_host.h3
-rw-r--r--ppapi/api/private/ppb_flash_drm.idl17
-rw-r--r--ppapi/c/private/ppb_flash_drm.h16
-rw-r--r--ppapi/cpp/private/flash_drm.cc20
-rw-r--r--ppapi/cpp/private/flash_drm.h9
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c14
-rw-r--r--ppapi/proxy/flash_drm_resource.cc43
-rw-r--r--ppapi/proxy/flash_drm_resource.h12
-rw-r--r--ppapi/proxy/ppapi_messages.h16
-rw-r--r--ppapi/tests/test_flash_drm.cc46
-rw-r--r--ppapi/tests/test_flash_drm.h2
-rw-r--r--ppapi/thunk/ppb_flash_drm_api.h4
-rw-r--r--ppapi/thunk/ppb_flash_drm_thunk.cc25
24 files changed, 398 insertions, 23 deletions
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
index efc493d..4b85639 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
@@ -8,6 +8,8 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/host_message_context.h"
@@ -18,13 +20,28 @@ using content::BrowserPpapiHost;
namespace chrome {
+namespace {
+const base::FilePath::CharType kVoucherFilename[] =
+ FILE_PATH_LITERAL("plugin.vch");
+}
+
PepperFlashDRMHost::PepperFlashDRMHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
weak_factory_(this){
+ // Grant permissions to read the flash voucher file.
int render_process_id, unused;
- host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused);
+ bool success =
+ host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused);
+ base::FilePath plugin_dir = host->GetPluginPath().DirName();
+ DCHECK(!plugin_dir.empty() && success);
+ base::FilePath voucher_file = plugin_dir.Append(
+ base::FilePath(kVoucherFilename));
+ content::ChildProcessSecurityPolicy::GetInstance()->GrantReadFile(
+ render_process_id, voucher_file);
+
+ // Init the DeviceIDFetcher.
fetcher_ = new DeviceIDFetcher(render_process_id);
}
@@ -37,6 +54,8 @@ int32_t PepperFlashDRMHost::OnResourceMessageReceived(
IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetDeviceID,
OnHostMsgGetDeviceID)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetHmonitor,
+ OnHostMsgGetHmonitor)
IPC_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -51,6 +70,13 @@ int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID(
return PP_OK_COMPLETIONPENDING;
}
+int32_t PepperFlashDRMHost::OnHostMsgGetHmonitor(
+ ppapi::host::HostMessageContext* context) {
+ // TODO(cpu): Get the HMONITOR.
+ context->reply_msg = PpapiPluginMsg_FlashDRM_GetHmonitorReply(0);
+ return PP_OK;
+}
+
void PepperFlashDRMHost::GotDeviceID(
ppapi::host::ReplyMessageContext reply_context,
const std::string& id) {
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h
index e461e90..0ed607b 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 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.
@@ -37,6 +37,7 @@ class PepperFlashDRMHost : public ppapi::host::ResourceHost {
private:
// IPC message handler.
int32_t OnHostMsgGetDeviceID(ppapi::host::HostMessageContext* context);
+ int32_t OnHostMsgGetHmonitor(ppapi::host::HostMessageContext* context);
// Called by the fetcher when the device ID was retrieved, or the empty string
// on error.
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 51b5070..d21c7f7 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -228,6 +228,8 @@
'renderer/pepper/chrome_renderer_pepper_host_factory.h',
'renderer/pepper/pepper_extensions_common_host.cc',
'renderer/pepper/pepper_extensions_common_host.h',
+ 'renderer/pepper/pepper_flash_drm_renderer_host.cc',
+ 'renderer/pepper/pepper_flash_drm_renderer_host.h',
'renderer/pepper/pepper_flash_font_file_host.cc',
'renderer/pepper/pepper_flash_font_file_host.h',
'renderer/pepper/pepper_flash_fullscreen_host.cc',
diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
index d96000e..b7ca8b5 100644
--- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
+++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/renderer/pepper/pepper_extensions_common_host.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"
@@ -94,6 +95,9 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
}
break;
}
+ case PpapiHostMsg_FlashDRM_Create::ID:
+ return scoped_ptr<ResourceHost>(new PepperFlashDRMRendererHost(
+ host_, instance, params.pp_resource()));
}
}
diff --git a/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc b/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc
new file mode 100644
index 0000000..863bde9
--- /dev/null
+++ b/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc
@@ -0,0 +1,73 @@
+// 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 "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
+
+#include "base/files/file_path.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppb_file_ref_proxy.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
+
+namespace chrome {
+
+// TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once
+// FileRef is refactored to the browser, it won't need to be.
+namespace {
+const base::FilePath::CharType kVoucherFilename[] =
+ FILE_PATH_LITERAL("plugin.vch");
+} // namespace
+
+PepperFlashDRMRendererHost::PepperFlashDRMRendererHost(
+ content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ renderer_ppapi_host_(host) {
+}
+
+PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() {
+}
+
+int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile,
+ OnGetVoucherFile)
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashDRMRendererHost::OnGetVoucherFile(
+ ppapi::host::HostMessageContext* context) {
+ webkit::ppapi::PluginInstance* plugin_instance =
+ renderer_ppapi_host_->GetPluginInstance(pp_instance());
+ if (!plugin_instance)
+ return PP_ERROR_FAILED;
+
+ base::FilePath plugin_dir = plugin_instance->module()->path().DirName();
+ DCHECK(!plugin_dir.empty());
+ base::FilePath voucher_file = plugin_dir.Append(
+ base::FilePath(kVoucherFilename));
+
+ webkit::ppapi::PPB_FileRef_Impl* ref =
+ webkit::ppapi::PPB_FileRef_Impl::CreateExternal(
+ pp_instance(), voucher_file, "");
+ ppapi::PPB_FileRef_CreateInfo create_info;
+ ppapi::proxy::PPB_FileRef_Proxy::SerializeFileRef(ref->GetReference(),
+ &create_info);
+ context->reply_msg =
+ PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info);
+ return PP_OK;
+}
+
+} // namespace chrome
+
diff --git a/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h b/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h
new file mode 100644
index 0000000..f7247d6
--- /dev/null
+++ b/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/host/resource_host.h"
+
+namespace content {
+class RendererPpapiHost;
+}
+
+namespace chrome {
+
+// TODO(raymes): This is only needed until we move FileRef resources to the
+// browser. After that, get rid of this class altogether.
+class PepperFlashDRMRendererHost : public ppapi::host::ResourceHost {
+ public:
+ PepperFlashDRMRendererHost(content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+ virtual ~PepperFlashDRMRendererHost();
+
+ virtual int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) OVERRIDE;
+
+ private:
+ int32_t OnGetVoucherFile(ppapi::host::HostMessageContext* context);
+
+ // Non-owning pointer.
+ content::RendererPpapiHost* renderer_ppapi_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashDRMRendererHost);
+};
+
+} // namespace chrome
+
+#endif // CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 1149f66..abdad6c 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -1350,10 +1350,16 @@ TEST_PPAPI_OUT_OF_PROCESS(FlashFile)
TEST_PPAPI_OUT_OF_PROCESS(MAYBE_FlashFullscreen)
TEST_PPAPI_OUT_OF_PROCESS(PDF)
-// Only implemented on Windows and ChromeOS currently.
+
+IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FlashDRM) {
+ RunTest(
#if (defined(OS_WIN) && defined(ENABLE_RLZ)) || defined(OS_CHROMEOS)
-TEST_PPAPI_OUT_OF_PROCESS(FlashDRM)
+ // Only implemented on Windows and ChromeOS currently.
+ LIST_TEST(FlashDRM_GetDeviceID)
#endif
+ LIST_TEST(FlashDRM_GetHmonitor)
+ LIST_TEST(FlashDRM_GetVoucherFile));
+}
TEST_PPAPI_IN_PROCESS(TalkPrivate)
TEST_PPAPI_OUT_OF_PROCESS(TalkPrivate)
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index 73de9c1..093a08b 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -218,7 +218,7 @@ PpapiPluginProcessHost::PpapiPluginProcessHost(
filter_ = new PepperMessageFilter(permissions_, host_resolver);
host_impl_.reset(new BrowserPpapiHostImpl(this, permissions_, info.name,
- profile_data_directory,
+ info.path, profile_data_directory,
false));
process_->GetHost()->AddFilter(filter_.get());
@@ -237,12 +237,11 @@ PpapiPluginProcessHost::PpapiPluginProcessHost()
PROCESS_TYPE_PPAPI_BROKER, this));
ppapi::PpapiPermissions permissions; // No permissions.
- // The plugin name and profile data directory shouldn't be needed for the
- // broker.
- std::string plugin_name;
- base::FilePath profile_data_directory;
- host_impl_.reset(new BrowserPpapiHostImpl(this, permissions, plugin_name,
- profile_data_directory,
+ // The plugin name, path and profile data directory shouldn't be needed for
+ // the broker.
+ host_impl_.reset(new BrowserPpapiHostImpl(this, permissions,
+ std::string(), base::FilePath(),
+ base::FilePath(),
false));
}
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
index ff6b93d..f386656 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
@@ -23,13 +23,10 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
int render_process_id,
int render_view_id,
const base::FilePath& profile_directory) {
- // TODO(raymes): Figure out how to plumb plugin_name through for NaCl. It is
- // currently only needed for PPB_Flash_File interfaces so it doesn't matter.
- std::string plugin_name;
+ // The plugin name and path shouldn't be needed for NaCl apps.
BrowserPpapiHostImpl* browser_ppapi_host =
- new BrowserPpapiHostImpl(sender, permissions, plugin_name,
- profile_directory,
- true);
+ new BrowserPpapiHostImpl(sender, permissions, std::string(),
+ base::FilePath(), profile_directory, true);
browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
channel->AddFilter(
@@ -47,11 +44,13 @@ BrowserPpapiHostImpl::BrowserPpapiHostImpl(
IPC::Sender* sender,
const ppapi::PpapiPermissions& permissions,
const std::string& plugin_name,
+ const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
bool external_plugin)
: ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)),
plugin_process_handle_(base::kNullProcessHandle),
plugin_name_(plugin_name),
+ plugin_path_(plugin_path),
profile_data_directory_(profile_data_directory),
external_plugin_(external_plugin) {
message_filter_ = new HostMessageFilter(ppapi_host_.get());
@@ -103,6 +102,10 @@ const std::string& BrowserPpapiHostImpl::GetPluginName() {
return plugin_name_;
}
+const base::FilePath& BrowserPpapiHostImpl::GetPluginPath() {
+ return plugin_path_;
+}
+
const base::FilePath& BrowserPpapiHostImpl::GetProfileDataDirectory() {
return profile_data_directory_;
}
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
index 4254833..8019d3e 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -32,6 +32,7 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
BrowserPpapiHostImpl(IPC::Sender* sender,
const ppapi::PpapiPermissions& permissions,
const std::string& plugin_name,
+ const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
bool external_plugin);
virtual ~BrowserPpapiHostImpl();
@@ -44,6 +45,7 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
int* render_process_id,
int* render_view_id) const OVERRIDE;
virtual const std::string& GetPluginName() OVERRIDE;
+ virtual const base::FilePath& GetPluginPath() OVERRIDE;
virtual const base::FilePath& GetProfileDataDirectory() OVERRIDE;
virtual GURL GetDocumentURLForInstance(PP_Instance instance) OVERRIDE;
virtual GURL GetPluginURLForInstance(PP_Instance instance) OVERRIDE;
@@ -89,6 +91,7 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
scoped_ptr<ppapi::host::PpapiHost> ppapi_host_;
base::ProcessHandle plugin_process_handle_;
std::string plugin_name_;
+ base::FilePath plugin_path_;
base::FilePath profile_data_directory_;
// If true, this is an external plugin, i.e. created by the embedder using
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
index 75a2725..af30a13 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
@@ -16,6 +16,7 @@ BrowserPpapiHostTest::BrowserPpapiHostTest()
ppapi::PpapiPermissions::AllPermissions(),
std::string(),
base::FilePath(),
+ base::FilePath(),
false));
ppapi_host_->set_plugin_process_handle(base::GetCurrentProcessHandle());
}
diff --git a/content/public/browser/browser_ppapi_host.h b/content/public/browser/browser_ppapi_host.h
index b831e09..dbf09bb 100644
--- a/content/public/browser/browser_ppapi_host.h
+++ b/content/public/browser/browser_ppapi_host.h
@@ -77,6 +77,9 @@ class CONTENT_EXPORT BrowserPpapiHost {
// Returns the name of the plugin.
virtual const std::string& GetPluginName() = 0;
+ // Returns the path of the plugin.
+ virtual const base::FilePath& GetPluginPath() = 0;
+
// Returns the user's profile data directory.
virtual const base::FilePath& GetProfileDataDirectory() = 0;
diff --git a/ppapi/api/private/ppb_flash_drm.idl b/ppapi/api/private/ppb_flash_drm.idl
index 8438114..3131972 100644
--- a/ppapi/api/private/ppb_flash_drm.idl
+++ b/ppapi/api/private/ppb_flash_drm.idl
@@ -31,5 +31,22 @@ interface PPB_Flash_DRM {
int32_t GetDeviceID([in] PP_Resource drm,
[out] PP_Var id,
[in] PP_CompletionCallback callback);
+
+ /**
+ * Windows only. Synchronously outputs the HMONITOR corresponding to the
+ * monitor on which the plugin instance is displayed in |hmonitor|. PP_TRUE is
+ * returned on success.
+ */
+ PP_Bool GetHmonitor([in] PP_Resource drm,
+ [out] int64_t hmonitor);
+
+ /**
+ * Asynchronously returns a PPB_FileRef resource in |file_ref| which points to
+ * the Voucher file for performing DRM verification. |callback| will be called
+ * upon completion.
+ */
+ int32_t GetVoucherFile([in] PP_Resource drm,
+ [out] PP_Resource file_ref,
+ [in] PP_CompletionCallback callback);
};
diff --git a/ppapi/c/private/ppb_flash_drm.h b/ppapi/c/private/ppb_flash_drm.h
index ed41593b..85033a4 100644
--- a/ppapi/c/private/ppb_flash_drm.h
+++ b/ppapi/c/private/ppb_flash_drm.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From private/ppb_flash_drm.idl modified Tue May 21 09:34:07 2013. */
+/* From private/ppb_flash_drm.idl modified Sat Jun 8 16:45:26 2013. */
#ifndef PPAPI_C_PRIVATE_PPB_FLASH_DRM_H_
#define PPAPI_C_PRIVATE_PPB_FLASH_DRM_H_
@@ -46,6 +46,20 @@ struct PPB_Flash_DRM_1_0 {
int32_t (*GetDeviceID)(PP_Resource drm,
struct PP_Var* id,
struct PP_CompletionCallback callback);
+ /**
+ * Windows only. Synchronously outputs the HMONITOR corresponding to the
+ * monitor on which the plugin instance is displayed in |hmonitor|. PP_TRUE is
+ * returned on success.
+ */
+ PP_Bool (*GetHmonitor)(PP_Resource drm, int64_t* hmonitor);
+ /**
+ * Asynchronously returns a PPB_FileRef resource in |file_ref| which points to
+ * the Voucher file for performing DRM verification. |callback| will be called
+ * upon completion.
+ */
+ int32_t (*GetVoucherFile)(PP_Resource drm,
+ PP_Resource* file_ref,
+ struct PP_CompletionCallback callback);
};
typedef struct PPB_Flash_DRM_1_0 PPB_Flash_DRM;
diff --git a/ppapi/cpp/private/flash_drm.cc b/ppapi/cpp/private/flash_drm.cc
index 7307445..44887ab 100644
--- a/ppapi/cpp/private/flash_drm.cc
+++ b/ppapi/cpp/private/flash_drm.cc
@@ -54,5 +54,25 @@ int32_t DRM::GetDeviceID(const CompletionCallbackWithOutput<Var>& callback) {
return callback.MayForce(PP_ERROR_NOINTERFACE);
}
+bool DRM::GetHmonitor(int64_t* hmonitor) {
+ if (has_interface<PPB_Flash_DRM_1_0>()) {
+ return PP_ToBool(get_interface<PPB_Flash_DRM_1_0>()->GetHmonitor(
+ pp_resource(),
+ hmonitor));
+ }
+ return 0;
+}
+
+int32_t DRM::GetVoucherFile(
+ const CompletionCallbackWithOutput<FileRef>& callback) {
+ if (has_interface<PPB_Flash_DRM_1_0>()) {
+ return get_interface<PPB_Flash_DRM_1_0>()->GetVoucherFile(
+ pp_resource(),
+ callback.output(),
+ callback.pp_completion_callback());
+ }
+ return PP_ERROR_FAILED;
+}
+
} // namespace flash
} // namespace pp
diff --git a/ppapi/cpp/private/flash_drm.h b/ppapi/cpp/private/flash_drm.h
index 49e37c2..45ecde8 100644
--- a/ppapi/cpp/private/flash_drm.h
+++ b/ppapi/cpp/private/flash_drm.h
@@ -6,9 +6,13 @@
#define PPAPI_CPP_PRIVATE_FLASH_DRM_H_
#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/resource.h"
namespace pp {
+
+class FileRef;
+
namespace flash {
class DRM : public Resource {
@@ -18,6 +22,11 @@ class DRM : public Resource {
// On success, returns a string var.
int32_t GetDeviceID(const CompletionCallbackWithOutput<Var>& callback);
+ // Outputs the HMONITOR associated with the current plugin instance in
+ // |hmonitor|. True is returned upon success.
+ bool GetHmonitor(int64_t* hmonitor);
+ // Returns the voucher file as a FileRef or an invalid resource on failure.
+ int32_t GetVoucherFile(const CompletionCallbackWithOutput<FileRef>& callback);
};
} // namespace flash
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 78d359f..5f45879 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -2651,6 +2651,16 @@ static int32_t Pnacl_M29_PPB_Flash_DRM_GetDeviceID(PP_Resource drm, struct PP_Va
return iface->GetDeviceID(drm, id, *callback);
}
+static PP_Bool Pnacl_M29_PPB_Flash_DRM_GetHmonitor(PP_Resource drm, int64_t* hmonitor) {
+ const struct PPB_Flash_DRM_1_0 *iface = Pnacl_WrapperInfo_PPB_Flash_DRM_1_0.real_iface;
+ return iface->GetHmonitor(drm, hmonitor);
+}
+
+static int32_t Pnacl_M29_PPB_Flash_DRM_GetVoucherFile(PP_Resource drm, PP_Resource* file_ref, struct PP_CompletionCallback* callback) {
+ const struct PPB_Flash_DRM_1_0 *iface = Pnacl_WrapperInfo_PPB_Flash_DRM_1_0.real_iface;
+ return iface->GetVoucherFile(drm, file_ref, *callback);
+}
+
/* End wrapper methods for PPB_Flash_DRM_1_0 */
/* Not generating wrapper methods for PPB_Flash_FontFile_0_1 */
@@ -4439,7 +4449,9 @@ struct PPB_Flash_DeviceID_1_0 Pnacl_Wrappers_PPB_Flash_DeviceID_1_0 = {
struct PPB_Flash_DRM_1_0 Pnacl_Wrappers_PPB_Flash_DRM_1_0 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M29_PPB_Flash_DRM_Create,
- .GetDeviceID = (int32_t (*)(PP_Resource drm, struct PP_Var* id, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Flash_DRM_GetDeviceID
+ .GetDeviceID = (int32_t (*)(PP_Resource drm, struct PP_Var* id, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Flash_DRM_GetDeviceID,
+ .GetHmonitor = (PP_Bool (*)(PP_Resource drm, int64_t* hmonitor))&Pnacl_M29_PPB_Flash_DRM_GetHmonitor,
+ .GetVoucherFile = (int32_t (*)(PP_Resource drm, PP_Resource* file_ref, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Flash_DRM_GetVoucherFile
};
/* Not generating wrapper interface for PPB_Flash_FontFile_0_1 */
diff --git a/ppapi/proxy/flash_drm_resource.cc b/ppapi/proxy/flash_drm_resource.cc
index c066b65..a4be23b 100644
--- a/ppapi/proxy/flash_drm_resource.cc
+++ b/ppapi/proxy/flash_drm_resource.cc
@@ -8,6 +8,8 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/dispatch_reply_message.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppb_file_ref_proxy.h"
+#include "ppapi/shared_impl/ppb_file_ref_shared.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
@@ -17,6 +19,7 @@ FlashDRMResource::FlashDRMResource(Connection connection,
PP_Instance instance)
: PluginResource(connection, instance) {
SendCreate(BROWSER, PpapiHostMsg_FlashDRM_Create());
+ SendCreate(RENDERER, PpapiHostMsg_FlashDRM_Create());
}
FlashDRMResource::~FlashDRMResource() {
@@ -41,6 +44,34 @@ int32_t FlashDRMResource::GetDeviceID(PP_Var* id,
return PP_OK_COMPLETIONPENDING;
}
+PP_Bool FlashDRMResource::GetHmonitor(int64_t* hmonitor) {
+ int64_t hmonitor_out;
+ int32_t result = SyncCall<PpapiPluginMsg_FlashDRM_GetHmonitorReply>(
+ BROWSER,
+ PpapiHostMsg_FlashDRM_GetHmonitor(),
+ &hmonitor_out);
+ if (result != PP_OK)
+ return PP_FALSE;
+ *hmonitor = hmonitor_out;
+ return PP_TRUE;
+}
+
+int32_t FlashDRMResource::GetVoucherFile(
+ PP_Resource* file_ref,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!file_ref)
+ return PP_ERROR_BADARGUMENT;
+
+ *file_ref = 0;
+
+ Call<PpapiPluginMsg_FlashDRM_GetVoucherFileReply>(
+ RENDERER,
+ PpapiHostMsg_FlashDRM_GetVoucherFile(),
+ base::Bind(&FlashDRMResource::OnPluginMsgGetVoucherFileReply, this,
+ file_ref, callback));
+ return PP_OK_COMPLETIONPENDING;
+}
+
void FlashDRMResource::OnPluginMsgGetDeviceIDReply(
PP_Var* dest,
scoped_refptr<TrackedCallback> callback,
@@ -53,5 +84,17 @@ void FlashDRMResource::OnPluginMsgGetDeviceIDReply(
}
}
+void FlashDRMResource::OnPluginMsgGetVoucherFileReply(
+ PP_Resource* dest,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params,
+ const PPB_FileRef_CreateInfo& file_info) {
+ if (TrackedCallback::IsPending(callback)) {
+ if (params.result() == PP_OK)
+ *dest = PPB_FileRef_Proxy::DeserializeFileRef(file_info);
+ callback->Run(params.result());
+ }
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/flash_drm_resource.h b/ppapi/proxy/flash_drm_resource.h
index d85db0c..12c71e8 100644
--- a/ppapi/proxy/flash_drm_resource.h
+++ b/ppapi/proxy/flash_drm_resource.h
@@ -11,6 +11,10 @@
#include "ppapi/thunk/ppb_flash_drm_api.h"
namespace ppapi {
+struct PPB_FileRef_CreateInfo;
+}
+
+namespace ppapi {
namespace proxy {
class FlashDRMResource
@@ -27,12 +31,20 @@ class FlashDRMResource
// PPB_Flash_DRM_API implementation.
virtual int32_t GetDeviceID(PP_Var* id,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual PP_Bool GetHmonitor(int64_t* hmonitor) OVERRIDE;
+ virtual int32_t GetVoucherFile(
+ PP_Resource* file_ref,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
private:
void OnPluginMsgGetDeviceIDReply(PP_Var* dest,
scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params,
const std::string& id);
+ void OnPluginMsgGetVoucherFileReply(PP_Resource* dest,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params,
+ const PPB_FileRef_CreateInfo& file_info);
DISALLOW_COPY_AND_ASSIGN(FlashDRMResource);
};
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 22e45d1..3a9a993 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -45,7 +45,6 @@
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppp_flash_browser_operations.h"
-#include "ppapi/c/private/ppb_flash_drm.h"
#include "ppapi/c/private/ppb_talk_private.h"
#include "ppapi/proxy/host_resolver_private_resource.h"
#include "ppapi/proxy/ppapi_param_traits.h"
@@ -1419,6 +1418,21 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_GetDeviceID)
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashDRM_GetDeviceIDReply,
std::string /* id */)
+// Requests the HMONITOR corresponding to the monitor on which the instance is
+// displayed.
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_GetHmonitor)
+// Reply message for GetHmonitor which contains the HMONITOR as an int64_t.
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashDRM_GetHmonitorReply,
+ int64_t /* hmonitor */)
+
+// Requests the voucher file which is used to verify the integrity of the Flash
+// module. A PPB_FileRef resource will be created.
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_GetVoucherFile)
+// Reply message for GetVoucherFile which contains the CreateInfo for a
+// PPB_FileRef which points to the voucher file.
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashDRM_GetVoucherFileReply,
+ ppapi::PPB_FileRef_CreateInfo /* file_info */)
+
// Gamepad.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Gamepad_Create)
diff --git a/ppapi/tests/test_flash_drm.cc b/ppapi/tests/test_flash_drm.cc
index 94b6f26..fee9891 100644
--- a/ppapi/tests/test_flash_drm.cc
+++ b/ppapi/tests/test_flash_drm.cc
@@ -5,6 +5,7 @@
#include "ppapi/tests/test_flash_drm.h"
#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/private/ppb_file_ref_private.h"
#include "ppapi/c/private/ppb_flash_drm.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
@@ -17,8 +18,14 @@ REGISTER_TEST_CASE(FlashDRM);
using pp::flash::DeviceID;
using pp::flash::DRM;
+using pp::FileRef;
+using pp::PassRef;
using pp::Var;
+namespace {
+ const char kExepectedVoucherFilename[] = "plugin.vch";
+}
+
TestFlashDRM::TestFlashDRM(TestingInstance* instance)
: TestCase(instance),
PP_ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
@@ -26,6 +33,8 @@ TestFlashDRM::TestFlashDRM(TestingInstance* instance)
void TestFlashDRM::RunTests(const std::string& filter) {
RUN_TEST(GetDeviceID, filter);
+ RUN_TEST(GetHmonitor, filter);
+ RUN_TEST(GetVoucherFile, filter);
}
std::string TestFlashDRM::TestGetDeviceID() {
@@ -59,3 +68,40 @@ std::string TestFlashDRM::TestGetDeviceID() {
PASS();
}
+
+std::string TestFlashDRM::TestGetHmonitor() {
+ // TODO(raymes): Replace this with a real test once this is implemented.
+ DRM drm(instance_);
+ int64_t hmonitor;
+ bool success = drm.GetHmonitor(&hmonitor);
+ ASSERT_TRUE(success);
+ ASSERT_EQ(0, hmonitor);
+
+ PASS();
+}
+
+std::string TestFlashDRM::TestGetVoucherFile() {
+ DRM drm(instance_);
+ TestCompletionCallbackWithOutput<FileRef> output_callback(
+ instance_->pp_instance());
+ int32_t rv = drm.GetVoucherFile(output_callback.GetCallback());
+ output_callback.WaitForResult(rv);
+ ASSERT_EQ(PP_OK, output_callback.result());
+ FileRef result = output_callback.output();
+ ASSERT_EQ(PP_FILESYSTEMTYPE_EXTERNAL, result.GetFileSystemType());
+
+ // The PPB_FileRefPrivate interface doesn't have a C++ wrapper yet, so just
+ // use the C interface.
+ const PPB_FileRefPrivate* file_ref_private =
+ static_cast<const PPB_FileRefPrivate*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_FILEREFPRIVATE_INTERFACE));
+ ASSERT_TRUE(file_ref_private);
+ Var path(PassRef(), file_ref_private->GetAbsolutePath(result.pp_resource()));
+ ASSERT_TRUE(path.is_string());
+ std::string path_string = path.AsString();
+ std::string expected_filename = std::string(kExepectedVoucherFilename);
+ ASSERT_EQ(expected_filename,
+ path_string.substr(path_string.size() - expected_filename.size()));
+
+ PASS();
+}
diff --git a/ppapi/tests/test_flash_drm.h b/ppapi/tests/test_flash_drm.h
index 964a80e..87f4a65 100644
--- a/ppapi/tests/test_flash_drm.h
+++ b/ppapi/tests/test_flash_drm.h
@@ -19,6 +19,8 @@ class TestFlashDRM : public TestCase {
private:
std::string TestGetDeviceID();
+ std::string TestGetHmonitor();
+ std::string TestGetVoucherFile();
pp::CompletionCallbackFactory<TestFlashDRM> callback_factory_;
};
diff --git a/ppapi/thunk/ppb_flash_drm_api.h b/ppapi/thunk/ppb_flash_drm_api.h
index 28d91be..87712b9 100644
--- a/ppapi/thunk/ppb_flash_drm_api.h
+++ b/ppapi/thunk/ppb_flash_drm_api.h
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/memory/ref_counted.h"
-#include "ppapi/c/private/ppb_flash_drm.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
namespace ppapi {
@@ -18,6 +17,9 @@ class PPAPI_THUNK_EXPORT PPB_Flash_DRM_API {
virtual int32_t GetDeviceID(PP_Var* id,
scoped_refptr<TrackedCallback> callback) = 0;
+ virtual PP_Bool GetHmonitor(int64_t* hmonitor) = 0;
+ virtual int32_t GetVoucherFile(PP_Resource* file_ref,
+ scoped_refptr<TrackedCallback> callback) = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_flash_drm_thunk.cc b/ppapi/thunk/ppb_flash_drm_thunk.cc
index 5d1176d..eff2fdf 100644
--- a/ppapi/thunk/ppb_flash_drm_thunk.cc
+++ b/ppapi/thunk/ppb_flash_drm_thunk.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// From private/ppb_flash_drm.idl modified Mon May 20 13:45:09 2013.
+// From private/ppb_flash_drm.idl modified Sat Jun 8 16:45:26 2013.
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
@@ -37,9 +37,30 @@ int32_t GetDeviceID(PP_Resource drm,
return enter.SetResult(enter.object()->GetDeviceID(id, enter.callback()));
}
+PP_Bool GetHmonitor(PP_Resource drm, int64_t* hmonitor) {
+ VLOG(4) << "PPB_Flash_DRM::GetHmonitor()";
+ EnterResource<PPB_Flash_DRM_API> enter(drm, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.object()->GetHmonitor(hmonitor);
+}
+
+int32_t GetVoucherFile(PP_Resource drm,
+ PP_Resource* file_ref,
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_Flash_DRM::GetVoucherFile()";
+ EnterResource<PPB_Flash_DRM_API> enter(drm, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->GetVoucherFile(file_ref,
+ enter.callback()));
+}
+
const PPB_Flash_DRM_1_0 g_ppb_flash_drm_thunk_1_0 = {
&Create,
- &GetDeviceID
+ &GetDeviceID,
+ &GetHmonitor,
+ &GetVoucherFile
};
} // namespace