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

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: avoid PostTask methods in dtor 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)
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
36 chromeos::OutputConfigurator* configurator =
37 ash::Shell::GetInstance()->output_configurator();
38 content::BrowserThread::PostTask(
39 content::BrowserThread::UI,
40 FROM_HERE,
41 base::Bind(base::IgnoreResult(
42 &chromeos::OutputConfigurator::EnableOutputProtection),
43 base::Unretained(configurator),
44 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
45 PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE));
46 #endif
47 }
48
49 int32_t PepperOutputProtectionHost::OnResourceMessageReceived(
50 const IPC::Message& msg,
51 ppapi::host::HostMessageContext* context) {
52 IPC_BEGIN_MESSAGE_MAP(PepperOutputProtectionHost, msg)
53 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
54 PpapiHostMsg_OutputProtection_QueryStatus,
55 OnQueryStatus);
56 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
57 PpapiHostMsg_OutputProtection_EnableProtection,
58 OnEnableProtection);
59 IPC_END_MESSAGE_MAP()
60 return PP_ERROR_FAILED;
61 }
62
63 void PepperOutputProtectionHost::QueryStatusOnUIThread(
64 ppapi::host::ReplyMessageContext reply_context) {
65 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
66
67 #if defined(USE_ASH) && defined(OS_CHROMEOS)
68 chromeos::OutputConfigurator* configurator =
69 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
70 uint32_t link_mask = 0, protection_mask = 0;
71 bool result = configurator->QueryOutputProtectionStatus(
72 this, &link_mask, &protection_mask);
73 #else
74 bool result = false;
75 #endif
76
77 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
78 host()->SendReply(reply_context,
79 PpapiPluginMsg_OutputProtection_QueryStatusReply(
80 link_mask, protection_mask));
81 }
82
83 int32_t PepperOutputProtectionHost::OnQueryStatus(
84 ppapi::host::HostMessageContext* context) {
85
dmichael (off chromium) 2013/09/09 20:37:15 nit: excess whitespace
kcwu 2013/09/10 12:50:21 Done.
86 content::BrowserThread::PostTask(
87 content::BrowserThread::UI,
88 FROM_HERE,
89 base::Bind(&PepperOutputProtectionHost::QueryStatusOnUIThread,
90 base::Unretained(this),
91 context->MakeReplyMessageContext()));
92
dmichael (off chromium) 2013/09/09 20:37:15 nit: excess whitespace
kcwu 2013/09/10 12:50:21 Done.
93 return PP_OK_COMPLETIONPENDING;
94 }
95
96 void PepperOutputProtectionHost::EnableProtectionOnUIThread(
97 ppapi::host::ReplyMessageContext reply_context,
98 uint32_t desired_method_mask) {
99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
100
101 #if defined(USE_ASH) && defined(OS_CHROMEOS)
102 chromeos::OutputConfigurator* configurator =
103 ash::Shell::GetInstance()->output_configurator();
104 bool result = configurator->EnableOutputProtection(
105 this, desired_method_mask);
106 #else
107 bool result = false;
108 #endif
109
110 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
111 host()->SendReply(reply_context,
112 PpapiPluginMsg_OutputProtection_EnableProtectionReply());
113 }
114
115 int32_t
116 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.
117 ppapi::host::HostMessageContext* context,
118 uint32_t desired_method_mask) {
119
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.
120 content::BrowserThread::PostTask(
121 content::BrowserThread::UI,
122 FROM_HERE,
123 base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
124 base::Unretained(this),
125 context->MakeReplyMessageContext(),
126 desired_method_mask));
127
128 return PP_OK_COMPLETIONPENDING;
129 }
130
131 } // namespace content
132
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698