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..f8b1fa9b4ced15c36892b09d8c6510f08bbbc428 |
--- /dev/null |
+++ b/chrome/browser/renderer_host/pepper/pepper_output_protection_host.cc |
@@ -0,0 +1,132 @@ |
+// 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) |
dmichael (off chromium)
2013/09/09 20:37:15
Why not use gyp or ifdef out the whole file? (and
kcwu
2013/09/10 12:50:21
If conditional build the whole file, this means I
dmichael (off chromium)
2013/09/11 18:22:45
I guess I was thinking that it would be ideal if t
kcwu
2013/09/12 18:22:08
IIUC how pepper works, in order to make it true in
|
+ chromeos::OutputConfigurator* configurator = |
+ ash::Shell::GetInstance()->output_configurator(); |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(base::IgnoreResult( |
+ &chromeos::OutputConfigurator::EnableOutputProtection), |
+ base::Unretained(configurator), |
+ base::Unretained(this), |
dmichael (off chromium)
2013/09/09 20:37:15
I don't know what EnableOutputProtection actually
kcwu
2013/09/10 12:50:21
I just pass the pointer "value" as client id and n
|
+ PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE)); |
+#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(); |
dmichael (off chromium)
2013/09/09 20:37:15
can this ever be NULL?
kcwu
2013/09/10 12:50:21
output_configurator will not be NULL if shell inst
|
+ 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) { |
+ |
dmichael (off chromium)
2013/09/09 20:37:15
nit: excess whitespace
kcwu
2013/09/10 12:50:21
Done.
|
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&PepperOutputProtectionHost::QueryStatusOnUIThread, |
+ base::Unretained(this), |
+ context->MakeReplyMessageContext())); |
+ |
dmichael (off chromium)
2013/09/09 20:37:15
nit: excess whitespace
kcwu
2013/09/10 12:50:21
Done.
|
+ return PP_OK_COMPLETIONPENDING; |
+} |
+ |
+void PepperOutputProtectionHost::EnableProtectionOnUIThread( |
+ ppapi::host::ReplyMessageContext reply_context, |
+ uint32_t desired_method_mask) { |
+ 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 |
+ |
+ reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED); |
+ host()->SendReply(reply_context, |
+ PpapiPluginMsg_OutputProtection_EnableProtectionReply()); |
+} |
+ |
+int32_t |
+PepperOutputProtectionHost::OnEnableProtection( |
dmichael (off chromium)
2013/09/09 20:37:15
nit: it looks like this line should fit with the r
kcwu
2013/09/10 12:50:21
Done.
|
+ ppapi::host::HostMessageContext* context, |
+ uint32_t desired_method_mask) { |
+ |
dmichael (off chromium)
2013/09/09 20:37:15
nit: excess whitespace in this function body too.
kcwu
2013/09/10 12:50:21
Done.
|
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread, |
+ base::Unretained(this), |
+ context->MakeReplyMessageContext(), |
+ desired_method_mask)); |
+ |
+ return PP_OK_COMPLETIONPENDING; |
+} |
+ |
+} // namespace content |
+ |