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

Unified Diff: chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc

Issue 24039002: Pepper API implementation for output protection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc
diff --git a/chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc b/chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bec5cba7b296ef460bffb99761bea175fdf78968
--- /dev/null
+++ b/chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc
@@ -0,0 +1,134 @@
+// Copyright 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.
+
+#include "chrome/browser/renderer_host/pepper/pepper_output_protection_host.h"
+
+#include "build/build_config.h"
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_output_protection_private.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"
+
+#if defined(USE_ASH) && defined(OS_CHROMEOS)
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "chromeos/display/output_configurator.h"
+#endif
+
+namespace chrome {
+
+PepperOutputProtectionHost::PepperOutputProtectionHost(
+ content::BrowserPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ renderer_ppapi_host_(host) {
+}
+
+PepperOutputProtectionHost::~PepperOutputProtectionHost() {
+#if defined(USE_ASH) && defined(OS_CHROMEOS)
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
+ base::Unretained(this),
DaleCurtis 2013/09/07 01:14:38 Can't post tasks to "this" during destruction -- t
kcwu 2013/09/09 07:58:16 Done. post tasks to the underlying call.
DaleCurtis 2013/09/09 20:53:24 I don't think this is fixed? You can't post task t
+ ppapi::host::ReplyMessageContext(),
+ PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE,
+ false));
+#endif
+}
+
+int32_t PepperOutputProtectionHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperOutputProtectionHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+ PpapiHostMsg_OutputProtection_QueryStatus,
+ OnQueryStatus);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+ PpapiHostMsg_OutputProtection_EnableProtection,
+ OnEnableProtection);
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+void PepperOutputProtectionHost::QueryStatusOnUIThread(
+ ppapi::host::ReplyMessageContext reply_context) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+#if defined(USE_ASH) && defined(OS_CHROMEOS)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ uint32_t link_mask = 0, protection_mask = 0;
+ bool result = configurator->QueryOutputProtectionStatus(
+ this, &link_mask, &protection_mask);
+#else
+ bool result = false;
+#endif
+
+ reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
+ host()->SendReply(reply_context,
+ PpapiPluginMsg_OutputProtection_QueryStatusReply(
+ link_mask, protection_mask));
+}
+
+int32_t PepperOutputProtectionHost::OnQueryStatus(
+ ppapi::host::HostMessageContext* context) {
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&PepperOutputProtectionHost::QueryStatusOnUIThread,
+ base::Unretained(this),
+ context->MakeReplyMessageContext()));
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperOutputProtectionHost::EnableProtectionOnUIThread(
+ ppapi::host::ReplyMessageContext reply_context,
+ uint32_t desired_method_mask,
+ bool with_callback) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+#if defined(USE_ASH) && defined(OS_CHROMEOS)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ bool result = configurator->EnableOutputProtection(
+ this, desired_method_mask);
+#else
+ bool result = false;
+#endif
+
+ if (with_callback) {
+ reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
+ host()->SendReply(reply_context,
+ PpapiPluginMsg_OutputProtection_EnableProtectionReply());
+ }
+}
+
+int32_t
+PepperOutputProtectionHost::OnEnableProtection(
+ ppapi::host::HostMessageContext* context,
+ uint32_t desired_method_mask) {
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
+ base::Unretained(this),
+ context->MakeReplyMessageContext(),
+ desired_method_mask,
+ true));
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+} // namespace content
+

Powered by Google App Engine
This is Rietveld 408576698