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

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: tweaks conditional compile conditions 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)
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(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
ddorwin 2013/09/12 04:22:13 What is the purpose of ASH and X11? Is there a bet
kcwu 2013/09/12 18:22:08 USE_X11: Output protection implementation requires
36 chromeos::OutputConfigurator* configurator =
DaleCurtis 2013/09/12 01:23:13 Is it safe to call this from any thread? I don't
kcwu 2013/09/16 11:57:37 After check the code, I feel they assume all run i
DaleCurtis 2013/09/16 18:07:08 I don't understand why you added those two new IPC
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),
DaleCurtis 2013/09/12 01:23:13 A comment indicating that this is only used as a k
ddorwin 2013/09/12 04:22:13 Passing |this| in the destructor seems dangerous.
kcwu 2013/09/12 18:22:08 No. That will be a small memory leak.
kcwu 2013/09/12 18:22:08 Done.
45 PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE));
46 #else
47 NOTIMPLEMENTED();
ddorwin 2013/09/12 04:22:13 Wouldn't it be better to indicate this when the ob
kcwu 2013/09/12 18:22:08 Done.
48 #endif
49 }
50
51 int32_t PepperOutputProtectionHost::OnResourceMessageReceived(
52 const IPC::Message& msg,
53 ppapi::host::HostMessageContext* context) {
54 IPC_BEGIN_MESSAGE_MAP(PepperOutputProtectionHost, msg)
55 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
56 PpapiHostMsg_OutputProtection_QueryStatus,
57 OnQueryStatus);
58 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
59 PpapiHostMsg_OutputProtection_EnableProtection,
60 OnEnableProtection);
61 IPC_END_MESSAGE_MAP()
62 return PP_ERROR_FAILED;
63 }
64
65 void PepperOutputProtectionHost::QueryStatusOnUIThread(
66 ppapi::host::ReplyMessageContext reply_context) {
67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
68
69 #if defined(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
70 chromeos::OutputConfigurator* configurator =
71 ash::Shell::GetInstance()->output_configurator();
72 uint32_t link_mask = 0, protection_mask = 0;
ddorwin 2013/09/12 04:22:13 These need to be defined outside the #if block or
kcwu 2013/09/12 18:22:08 Done.
73 bool result = configurator->QueryOutputProtectionStatus(
74 this, &link_mask, &protection_mask);
75 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
76 #else
77 NOTIMPLEMENTED();
78 reply_context.params.set_result(PP_ERROR_NOTSUPPORTED);
79 #endif
80 host()->SendReply(reply_context,
DaleCurtis 2013/09/12 01:23:13 invalid wrapping. reply_context must go on the ne
kcwu 2013/09/12 18:22:08 Done.
81 PpapiPluginMsg_OutputProtection_QueryStatusReply(
82 link_mask, protection_mask));
83 }
84
85 int32_t PepperOutputProtectionHost::OnQueryStatus(
86 ppapi::host::HostMessageContext* context) {
87 content::BrowserThread::PostTask(
88 content::BrowserThread::UI,
89 FROM_HERE,
90 base::Bind(&PepperOutputProtectionHost::QueryStatusOnUIThread,
91 base::Unretained(this),
92 context->MakeReplyMessageContext()));
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(OS_CHROMEOS) && defined(USE_ASH) && defined(USE_X11)
102 chromeos::OutputConfigurator* configurator =
103 ash::Shell::GetInstance()->output_configurator();
104 bool result = configurator->EnableOutputProtection(
105 this, desired_method_mask);
106 reply_context.params.set_result(result ? PP_OK : PP_ERROR_FAILED);
107 #else
108 NOTIMPLEMENTED();
109 reply_context.params.set_result(PP_ERROR_NOTSUPPORTED);
110 #endif
111 host()->SendReply(reply_context,
DaleCurtis 2013/09/12 01:23:13 Wrapping.
kcwu 2013/09/12 18:22:08 Done.
112 PpapiPluginMsg_OutputProtection_EnableProtectionReply());
113 }
114
115 int32_t PepperOutputProtectionHost::OnEnableProtection(
116 ppapi::host::HostMessageContext* context,
117 uint32_t desired_method_mask) {
118 content::BrowserThread::PostTask(
119 content::BrowserThread::UI,
120 FROM_HERE,
121 base::Bind(&PepperOutputProtectionHost::EnableProtectionOnUIThread,
122 base::Unretained(this),
123 context->MakeReplyMessageContext(),
124 desired_method_mask));
125 return PP_OK_COMPLETIONPENDING;
126 }
127
128 } // namespace chrome
129
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698