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

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

Issue 24039002: Pepper API implementation for output protection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix test on chromeos 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_message_filter.cc
diff --git a/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..75df9757f7f62c5533109d5c62e70603dc82683c
--- /dev/null
+++ b/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc
@@ -0,0 +1,181 @@
+// 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_message_filter.h"
+
+#include "build/build_config.h"
+#include "content/public/browser/browser_ppapi_host.h"
dmichael (off chromium) 2013/09/17 17:25:33 You may not need this include?
kcwu 2013/09/17 23:15:32 Done.
+#include "content/public/browser/browser_thread.h"
+#include "ipc/ipc_message.h"
dmichael (off chromium) 2013/09/17 17:25:33 nit: you don't need this include
kcwu 2013/09/17 23:15:32 Done.
+#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)
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "chromeos/display/output_configurator.h"
+#endif
+
+using content::BrowserThread;
+
+namespace chrome {
+
+namespace {
+
+#if defined(OS_CHROMEOS)
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_NONE),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_UNKNOWN),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_INTERNAL),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_VGA),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_HDMI),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_DVI),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT) ==
+ static_cast<int>(chromeos::OUTPUT_LINK_TYPE_DISPLAYPORT),
+ PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) ==
+ static_cast<int>(chromeos::OUTPUT_PROTECTION_METHOD_NONE),
+ PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE);
+COMPILE_ASSERT(
+ static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) ==
+ static_cast<int>(chromeos::OUTPUT_PROTECTION_METHOD_HDCP),
+ PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP);
+#endif
+
+} // namespace
+
+PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter() {
dmichael (off chromium) 2013/09/17 23:48:57 Please initialize client_id_
kcwu 2013/09/17 23:55:11 It's already done in next patch.
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+#else
+ NOTIMPLEMENTED();
+#endif
+}
+
+PepperOutputProtectionMessageFilter::~PepperOutputProtectionMessageFilter() {
+}
+
+scoped_refptr<base::TaskRunner>
+PepperOutputProtectionMessageFilter::OverrideTaskRunnerForMessage(
+ const IPC::Message& message) {
+ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
+}
+
+int32_t PepperOutputProtectionMessageFilter::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperOutputProtectionMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+ PpapiHostMsg_OutputProtection_Init,
+ OnInit);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+ PpapiHostMsg_OutputProtection_Terminate,
+ OnTerminate);
+ 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;
+}
+
+int32_t PepperOutputProtectionMessageFilter::OnInit(
+ ppapi::host::HostMessageContext* context) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
dmichael (off chromium) 2013/09/17 17:25:33 nit: please be consistent about usage of BrowserTh
kcwu 2013/09/17 23:15:32 Done.
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ client_id_ = configurator->RegisterOutputProtectionClient();
dmichael (off chromium) 2013/09/17 17:25:33 suggestion: Can you just do this in the constructo
kcwu 2013/09/17 23:15:32 Done.
+#else
+ NOTIMPLEMENTED();
dmichael (off chromium) 2013/09/17 17:25:33 Maybe return PP_ERROR_FAILED here, and move the "r
kcwu 2013/09/17 23:15:32 I extracted GetOutputConfigurator() to make it les
kcwu 2013/09/17 23:17:05 (please ignore the first sentence)
dmichael (off chromium) 2013/09/17 23:48:57 Good point, PP_ERROR_NOTSUPPORTED is probably bett
+#endif
+ return PP_OK;
+}
+
+int32_t PepperOutputProtectionMessageFilter::OnTerminate(
+ ppapi::host::HostMessageContext* context) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ configurator->UnregisterOutputProtectionClient(client_id_);
dmichael (off chromium) 2013/09/17 17:25:33 suggestion: I think you could do this Unregister i
kcwu 2013/09/17 23:15:32 Done.
+#else
+ NOTIMPLEMENTED();
+#endif
+ return PP_OK;
+}
+
+int32_t PepperOutputProtectionMessageFilter::OnQueryStatus(
+ ppapi::host::HostMessageContext* context) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ ppapi::host::ReplyMessageContext reply_context =
+ context->MakeReplyMessageContext();
+ uint32_t link_mask = 0, protection_mask = 0;
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ bool result = configurator->QueryOutputProtectionStatus(
+ client_id_, &link_mask, &protection_mask);
+ reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
+#else
+ NOTIMPLEMENTED();
+ reply_context.params.set_result(PP_ERROR_NOTSUPPORTED);
+#endif
+ SendReply(
+ reply_context,
+ PpapiPluginMsg_OutputProtection_QueryStatusReply(
+ link_mask, protection_mask));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t PepperOutputProtectionMessageFilter::OnEnableProtection(
+ ppapi::host::HostMessageContext* context,
+ uint32_t desired_method_mask) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ ppapi::host::ReplyMessageContext reply_context =
+ context->MakeReplyMessageContext();
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ bool result = configurator->EnableOutputProtection(
+ client_id_, desired_method_mask);
+ reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
+#else
+ NOTIMPLEMENTED();
+ reply_context.params.set_result(PP_ERROR_NOTSUPPORTED);
+#endif
+ SendReply(
+ reply_context,
+ PpapiPluginMsg_OutputProtection_EnableProtectionReply());
+ return PP_OK_COMPLETIONPENDING;
+}
+
+} // namespace chrome
+

Powered by Google App Engine
This is Rietveld 408576698