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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/renderer_host/pepper/pepper_output_protection_host.h"
6
7 #include "build/build_config.h"
8 #include "content/public/browser/browser_ppapi_host.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "ipc/ipc_message.h"
11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/private/ppb_output_protection_private.h"
13 #include "ppapi/host/dispatch_host_message.h"
14 #include "ppapi/host/host_message_context.h"
15 #include "ppapi/host/ppapi_host.h"
16 #include "ppapi/proxy/ppapi_messages.h"
17
18 #if defined(USE_ASH) && defined(OS_CHROMEOS)
19 #include "ash/shell.h"
20 #include "ash/shell_delegate.h"
21 #include "chromeos/display/output_configurator.h"
22 #endif
23
24 namespace chrome {
25
26 PepperOutputProtectionHost::PepperOutputProtectionHost(
27 content::BrowserPpapiHost* host,
28 PP_Instance instance,
29 PP_Resource resource)
30 : ResourceHost(host->GetPpapiHost(), instance, resource),
31 renderer_ppapi_host_(host) {
32 }
33
34 PepperOutputProtectionHost::~PepperOutputProtectionHost() {
35 #if defined(USE_ASH) && defined(OS_CHROMEOS)
36 content::BrowserThread::PostTask(
37 content::BrowserThread::UI,
38 FROM_HERE,
39 base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
40 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
41 ppapi::host::ReplyMessageContext(),
42 PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE,
43 false));
44 #endif
45 }
46
47 int32_t PepperOutputProtectionHost::OnResourceMessageReceived(
48 const IPC::Message& msg,
49 ppapi::host::HostMessageContext* context) {
50 IPC_BEGIN_MESSAGE_MAP(PepperOutputProtectionHost, msg)
51 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
52 PpapiHostMsg_OutputProtection_QueryStatus,
53 OnQueryStatus);
54 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
55 PpapiHostMsg_OutputProtection_EnableProtection,
56 OnEnableProtection);
57 IPC_END_MESSAGE_MAP()
58 return PP_ERROR_FAILED;
59 }
60
61 void PepperOutputProtectionHost::QueryStatusOnUIThread(
62 ppapi::host::ReplyMessageContext reply_context) {
63 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
64
65 #if defined(USE_ASH) && defined(OS_CHROMEOS)
66 chromeos::OutputConfigurator* configurator =
67 ash::Shell::GetInstance()->output_configurator();
68 uint32_t link_mask = 0, protection_mask = 0;
69 bool result = configurator->QueryOutputProtectionStatus(
70 this, &link_mask, &protection_mask);
71 #else
72 bool result = false;
73 #endif
74
75 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
76 host()->SendReply(reply_context,
77 PpapiPluginMsg_OutputProtection_QueryStatusReply(
78 link_mask, protection_mask));
79 }
80
81 int32_t PepperOutputProtectionHost::OnQueryStatus(
82 ppapi::host::HostMessageContext* context) {
83
84 content::BrowserThread::PostTask(
85 content::BrowserThread::UI,
86 FROM_HERE,
87 base::Bind(&PepperOutputProtectionHost::QueryStatusOnUIThread,
88 base::Unretained(this),
89 context->MakeReplyMessageContext()));
90
91 return PP_OK_COMPLETIONPENDING;
92 }
93
94 void PepperOutputProtectionHost::EnableProtectionOnUIThread(
95 ppapi::host::ReplyMessageContext reply_context,
96 uint32_t desired_method_mask,
97 bool with_callback) {
98 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
99
100 #if defined(USE_ASH) && defined(OS_CHROMEOS)
101 chromeos::OutputConfigurator* configurator =
102 ash::Shell::GetInstance()->output_configurator();
103 bool result = configurator->EnableOutputProtection(
104 this, desired_method_mask);
105 #else
106 bool result = false;
107 #endif
108
109 if (with_callback) {
110 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
111 host()->SendReply(reply_context,
112 PpapiPluginMsg_OutputProtection_EnableProtectionReply());
113 }
114 }
115
116 int32_t
117 PepperOutputProtectionHost::OnEnableProtection(
118 ppapi::host::HostMessageContext* context,
119 uint32_t desired_method_mask) {
120
121 content::BrowserThread::PostTask(
122 content::BrowserThread::UI,
123 FROM_HERE,
124 base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
125 base::Unretained(this),
126 context->MakeReplyMessageContext(),
127 desired_method_mask,
128 true));
129
130 return PP_OK_COMPLETIONPENDING;
131 }
132
133 } // namespace content
134
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698