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

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: modify pepper host as message filter. rewrite methods in real_output_configurator_delegate. 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..4ea5801d4925beb8452b76a9fe28f68a15fda53a
--- /dev/null
+++ b/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc
@@ -0,0 +1,122 @@
+// 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"
+#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)
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "chromeos/display/output_configurator.h"
+#endif
+
+using content::BrowserThread;
+
+namespace chrome {
+
+PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter(
+ ppapi::host::PpapiHost* host)
+ : host_(host) {
+#if !(defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11))
+ NOTIMPLEMENTED();
+#endif
+}
+
+PepperOutputProtectionMessageFilter::~PepperOutputProtectionMessageFilter() {
+#if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
+ chromeos::OutputConfigurator* configurator =
+ ash::Shell::GetInstance()->output_configurator();
+ // |this| is only used as a key and not dereferenced.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(
+ &chromeos::OutputConfigurator::EnableOutputProtection),
+ base::Unretained(configurator),
+ base::Unretained(this),
+ PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE));
+#else
+ NOTIMPLEMENTED();
+#endif
+}
+
+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_QueryStatus,
+ OnQueryStatus);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+ PpapiHostMsg_OutputProtection_EnableProtection,
+ OnEnableProtection);
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+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(
+ this, &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
+ host_->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(
+ this, 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
+ host_->SendReply(
DaleCurtis 2013/09/13 22:08:33 SendReply() works w/o host_-> so you can stop stor
kcwu 2013/09/16 11:57:37 Done.
+ reply_context,
+ PpapiPluginMsg_OutputProtection_EnableProtectionReply());
+ return PP_OK_COMPLETIONPENDING;
+}
+
+} // namespace chrome
+

Powered by Google App Engine
This is Rietveld 408576698