OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/pepper/pepper_output_protection_message_f
ilter.h" | 5 #include "chrome/browser/chromeos/display/output_protection_delegate.h" |
6 | 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" |
7 #include "build/build_config.h" | 9 #include "build/build_config.h" |
8 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
9 #include "content/public/browser/browser_ppapi_host.h" | |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "ppapi/c/pp_errors.h" | 14 #include "ui/gfx/screen.h" |
14 #include "ppapi/c/private/ppb_output_protection_private.h" | |
15 #include "ppapi/host/dispatch_host_message.h" | |
16 #include "ppapi/host/host_message_context.h" | |
17 #include "ppapi/host/ppapi_host.h" | |
18 #include "ppapi/proxy/ppapi_messages.h" | |
19 | 15 |
20 #if defined(OS_CHROMEOS) | 16 namespace chromeos { |
21 #include "ash/shell.h" | |
22 #include "ash/shell_delegate.h" | |
23 #include "ui/aura/window.h" | |
24 #include "ui/display/chromeos/display_configurator.h" | |
25 #include "ui/gfx/screen.h" | |
26 #endif | |
27 | |
28 namespace chrome { | |
29 | 17 |
30 namespace { | 18 namespace { |
31 | 19 |
32 #if defined(OS_CHROMEOS) | |
33 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE) == | |
34 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NONE), | |
35 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE value mismatch"); | |
36 static_assert( | |
37 static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN) == | |
38 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_UNKNOWN), | |
39 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN value mismatch"); | |
40 static_assert( | |
41 static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL) == | |
42 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_INTERNAL), | |
43 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL value mismatch"); | |
44 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA) == | |
45 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_VGA), | |
46 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA value mismatch"); | |
47 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) == | |
48 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_HDMI), | |
49 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI value mismatch"); | |
50 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI) == | |
51 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_DVI), | |
52 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI value mismatch"); | |
53 static_assert( | |
54 static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT) == | |
55 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_DISPLAYPORT), | |
56 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT value mismatch"); | |
57 static_assert( | |
58 static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK) == | |
59 static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NETWORK), | |
60 "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK value mismatch"); | |
61 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) == | |
62 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_NONE), | |
63 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE value mismatch"); | |
64 static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) == | |
65 static_cast<int>(ui::CONTENT_PROTECTION_METHOD_HDCP), | |
66 "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP value mismatch"); | |
67 | |
68 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { | 20 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { |
69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
70 gfx::NativeView native_view = rfh->GetNativeView(); | 22 gfx::NativeView native_view = rfh->GetNativeView(); |
71 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 23 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
72 if (!screen) | 24 if (!screen) |
73 return false; | 25 return false; |
74 gfx::Display display = screen->GetDisplayNearestWindow(native_view); | 26 gfx::Display display = screen->GetDisplayNearestWindow(native_view); |
75 *display_id = display.id(); | 27 *display_id = display.id(); |
76 return true; | 28 return true; |
77 } | 29 } |
78 | 30 |
79 void DoNothing(bool status) { | 31 void DoNothing(bool status) { |
80 } | 32 } |
81 | 33 |
82 #endif | |
83 | |
84 } // namespace | 34 } // namespace |
85 | 35 |
86 #if defined(OS_CHROMEOS) | 36 OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id, |
87 // Output protection delegate. All methods except constructor should be | 37 int render_frame_id) |
88 // invoked in UI thread. | |
89 class PepperOutputProtectionMessageFilter::Delegate | |
90 : public aura::WindowObserver { | |
91 public: | |
92 typedef base::Callback<void(int32_t /* result */, | |
93 uint32_t /* link_mask */, | |
94 uint32_t /* protection_mask*/)> | |
95 QueryStatusCallback; | |
96 typedef base::Callback<void(int32_t /* result */)> EnableProtectionCallback; | |
97 | |
98 Delegate(int render_process_id, int render_frame_id); | |
99 ~Delegate() override; | |
100 | |
101 // aura::WindowObserver overrides. | |
102 void OnWindowHierarchyChanged( | |
103 const aura::WindowObserver::HierarchyChangeParams& params) override; | |
104 void OnWindowDestroying(aura::Window* window) override; | |
105 | |
106 void QueryStatus(const QueryStatusCallback& callback); | |
107 void EnableProtection(uint32_t desired_method_mask, | |
108 const EnableProtectionCallback& callback); | |
109 | |
110 private: | |
111 ui::DisplayConfigurator::ContentProtectionClientId GetClientId(); | |
112 | |
113 void QueryStatusComplete( | |
114 const QueryStatusCallback& callback, | |
115 const ui::DisplayConfigurator::QueryProtectionResponse& response); | |
116 void EnableProtectionComplete(const EnableProtectionCallback& callback, | |
117 bool success); | |
118 | |
119 // Used to lookup the WebContents associated with this PP_Instance. | |
120 int render_process_id_; | |
121 int render_frame_id_; | |
122 | |
123 // Native window being observed. | |
124 aura::Window* window_; | |
125 | |
126 ui::DisplayConfigurator::ContentProtectionClientId client_id_; | |
127 | |
128 // The display id which the renderer currently uses. | |
129 int64 display_id_; | |
130 | |
131 // The last desired method mask. Will enable this mask on new display if | |
132 // renderer changes display. | |
133 uint32_t desired_method_mask_; | |
134 | |
135 base::WeakPtrFactory<PepperOutputProtectionMessageFilter::Delegate> | |
136 weak_ptr_factory_; | |
137 }; | |
138 | |
139 PepperOutputProtectionMessageFilter::Delegate::Delegate(int render_process_id, | |
140 int render_frame_id) | |
141 : render_process_id_(render_process_id), | 38 : render_process_id_(render_process_id), |
142 render_frame_id_(render_frame_id), | 39 render_frame_id_(render_frame_id), |
143 window_(NULL), | 40 window_(nullptr), |
144 client_id_(ui::DisplayConfigurator::kInvalidClientId), | 41 client_id_(ui::DisplayConfigurator::kInvalidClientId), |
145 display_id_(0), | 42 display_id_(0), |
146 weak_ptr_factory_(this) { | 43 weak_ptr_factory_(this) { |
147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 44 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
148 } | 45 } |
149 | 46 |
150 PepperOutputProtectionMessageFilter::Delegate::~Delegate() { | 47 OutputProtectionDelegate::~OutputProtectionDelegate() { |
151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
152 | 49 |
153 ui::DisplayConfigurator* configurator = | 50 ui::DisplayConfigurator* configurator = |
154 ash::Shell::GetInstance()->display_configurator(); | 51 ash::Shell::GetInstance()->display_configurator(); |
155 configurator->UnregisterContentProtectionClient(client_id_); | 52 configurator->UnregisterContentProtectionClient(client_id_); |
156 | 53 |
157 if (window_) | 54 if (window_) |
158 window_->RemoveObserver(this); | 55 window_->RemoveObserver(this); |
159 } | 56 } |
160 | 57 |
161 ui::DisplayConfigurator::ContentProtectionClientId | 58 ui::DisplayConfigurator::ContentProtectionClientId |
162 PepperOutputProtectionMessageFilter::Delegate::GetClientId() { | 59 OutputProtectionDelegate::GetClientId() { |
163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
164 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { | 61 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { |
165 content::RenderFrameHost* rfh = | 62 content::RenderFrameHost* rfh = |
166 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 63 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
167 if (!GetCurrentDisplayId(rfh, &display_id_)) | 64 if (!GetCurrentDisplayId(rfh, &display_id_)) |
168 return ui::DisplayConfigurator::kInvalidClientId; | 65 return ui::DisplayConfigurator::kInvalidClientId; |
169 | 66 |
170 window_ = rfh->GetNativeView(); | 67 window_ = rfh->GetNativeView(); |
171 if (!window_) | 68 if (!window_) |
172 return ui::DisplayConfigurator::kInvalidClientId; | 69 return ui::DisplayConfigurator::kInvalidClientId; |
173 | 70 |
174 ui::DisplayConfigurator* configurator = | 71 ui::DisplayConfigurator* configurator = |
175 ash::Shell::GetInstance()->display_configurator(); | 72 ash::Shell::GetInstance()->display_configurator(); |
176 client_id_ = configurator->RegisterContentProtectionClient(); | 73 client_id_ = configurator->RegisterContentProtectionClient(); |
177 | 74 |
178 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) | 75 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) |
179 window_->AddObserver(this); | 76 window_->AddObserver(this); |
180 } | 77 } |
181 return client_id_; | 78 return client_id_; |
182 } | 79 } |
183 | 80 |
184 void PepperOutputProtectionMessageFilter::Delegate::QueryStatus( | 81 void OutputProtectionDelegate::QueryStatus( |
185 const QueryStatusCallback& callback) { | 82 const QueryStatusCallback& callback) { |
186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
187 | 84 |
188 content::RenderFrameHost* rfh = | 85 content::RenderFrameHost* rfh = |
189 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 86 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
190 if (!rfh) { | 87 if (!rfh) { |
191 LOG(WARNING) << "RenderFrameHost is not alive."; | 88 LOG(WARNING) << "RenderFrameHost is not alive."; |
192 callback.Run(PP_ERROR_FAILED, 0, 0); | 89 callback.Run(false, 0, 0); |
193 return; | 90 return; |
194 } | 91 } |
195 | 92 |
196 ui::DisplayConfigurator* configurator = | 93 ui::DisplayConfigurator* configurator = |
197 ash::Shell::GetInstance()->display_configurator(); | 94 ash::Shell::GetInstance()->display_configurator(); |
198 configurator->QueryContentProtectionStatus( | 95 configurator->QueryContentProtectionStatus( |
199 GetClientId(), display_id_, | 96 GetClientId(), display_id_, |
200 base::Bind( | 97 base::Bind(&OutputProtectionDelegate::QueryStatusComplete, |
201 &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete, | 98 weak_ptr_factory_.GetWeakPtr(), callback)); |
202 weak_ptr_factory_.GetWeakPtr(), callback)); | |
203 } | 99 } |
204 | 100 |
205 void PepperOutputProtectionMessageFilter::Delegate::EnableProtection( | 101 void OutputProtectionDelegate::EnableProtection( |
206 uint32_t desired_method_mask, | 102 uint32_t desired_method_mask, |
207 const EnableProtectionCallback& callback) { | 103 const EnableProtectionCallback& callback) { |
208 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
209 | 105 |
210 ui::DisplayConfigurator* configurator = | 106 ui::DisplayConfigurator* configurator = |
211 ash::Shell::GetInstance()->display_configurator(); | 107 ash::Shell::GetInstance()->display_configurator(); |
212 configurator->EnableContentProtection( | 108 configurator->EnableContentProtection( |
213 GetClientId(), display_id_, desired_method_mask, | 109 GetClientId(), display_id_, desired_method_mask, |
214 base::Bind(&PepperOutputProtectionMessageFilter::Delegate:: | 110 base::Bind(&OutputProtectionDelegate::EnableProtectionComplete, |
215 EnableProtectionComplete, | |
216 weak_ptr_factory_.GetWeakPtr(), callback)); | 111 weak_ptr_factory_.GetWeakPtr(), callback)); |
217 desired_method_mask_ = desired_method_mask; | 112 desired_method_mask_ = desired_method_mask; |
218 } | 113 } |
219 | 114 |
220 void PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete( | 115 void OutputProtectionDelegate::QueryStatusComplete( |
221 const QueryStatusCallback& callback, | 116 const QueryStatusCallback& callback, |
222 const ui::DisplayConfigurator::QueryProtectionResponse& response) { | 117 const ui::DisplayConfigurator::QueryProtectionResponse& response) { |
| 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 119 |
223 content::RenderFrameHost* rfh = | 120 content::RenderFrameHost* rfh = |
224 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 121 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
225 if (!rfh) { | 122 if (!rfh) { |
226 LOG(WARNING) << "RenderFrameHost is not alive."; | 123 LOG(WARNING) << "RenderFrameHost is not alive."; |
227 callback.Run(PP_ERROR_FAILED, 0, 0); | 124 callback.Run(false, 0, 0); |
228 return; | 125 return; |
229 } | 126 } |
230 | 127 |
231 uint32_t link_mask = response.link_mask; | 128 uint32_t link_mask = response.link_mask; |
232 // If we successfully retrieved the device level status, check for capturers. | 129 // If we successfully retrieved the device level status, check for capturers. |
233 if (response.success) { | 130 if (response.success) { |
234 const bool capture_detected = | 131 const bool capture_detected = |
235 // Check for tab capture on the current tab. | 132 // Check for tab capture on the current tab. |
236 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > | 133 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > |
237 0 || | 134 0 || |
238 // Check for desktop capture. | 135 // Check for desktop capture. |
239 MediaCaptureDevicesDispatcher::GetInstance() | 136 MediaCaptureDevicesDispatcher::GetInstance() |
240 ->IsDesktopCaptureInProgress(); | 137 ->IsDesktopCaptureInProgress(); |
241 if (capture_detected) | 138 if (capture_detected) |
242 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; | 139 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; |
243 } | 140 } |
244 | 141 |
245 callback.Run(response.success ? PP_OK : PP_ERROR_FAILED, link_mask, | 142 callback.Run(response.success, link_mask, response.protection_mask); |
246 response.protection_mask); | |
247 } | 143 } |
248 | 144 |
249 void PepperOutputProtectionMessageFilter::Delegate::EnableProtectionComplete( | 145 void OutputProtectionDelegate::EnableProtectionComplete( |
250 const EnableProtectionCallback& callback, | 146 const EnableProtectionCallback& callback, |
251 bool result) { | 147 bool success) { |
252 callback.Run(result ? PP_OK : PP_ERROR_FAILED); | 148 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 149 |
| 150 callback.Run(success); |
253 } | 151 } |
254 | 152 |
255 void PepperOutputProtectionMessageFilter::Delegate::OnWindowHierarchyChanged( | 153 void OutputProtectionDelegate::OnWindowHierarchyChanged( |
256 const aura::WindowObserver::HierarchyChangeParams& params) { | 154 const aura::WindowObserver::HierarchyChangeParams& params) { |
257 content::RenderFrameHost* rfh = | 155 content::RenderFrameHost* rfh = |
258 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 156 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
259 if (!rfh) { | 157 if (!rfh) { |
260 LOG(WARNING) << "RenderFrameHost is not alive."; | 158 LOG(WARNING) << "RenderFrameHost is not alive."; |
261 return; | 159 return; |
262 } | 160 } |
263 | 161 |
264 int64 new_display_id = 0; | 162 int64 new_display_id = 0; |
265 if (!GetCurrentDisplayId(rfh, &new_display_id)) | 163 if (!GetCurrentDisplayId(rfh, &new_display_id)) |
266 return; | 164 return; |
267 if (display_id_ == new_display_id) | 165 if (display_id_ == new_display_id) |
268 return; | 166 return; |
269 | 167 |
270 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { | 168 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { |
271 // Display changed and should enable output protections on new display. | 169 // Display changed and should enable output protections on new display. |
272 ui::DisplayConfigurator* configurator = | 170 ui::DisplayConfigurator* configurator = |
273 ash::Shell::GetInstance()->display_configurator(); | 171 ash::Shell::GetInstance()->display_configurator(); |
274 configurator->EnableContentProtection(GetClientId(), new_display_id, | 172 configurator->EnableContentProtection(GetClientId(), new_display_id, |
275 desired_method_mask_, | 173 desired_method_mask_, |
276 base::Bind(&DoNothing)); | 174 base::Bind(&DoNothing)); |
277 configurator->EnableContentProtection(GetClientId(), display_id_, | 175 configurator->EnableContentProtection(GetClientId(), display_id_, |
278 ui::CONTENT_PROTECTION_METHOD_NONE, | 176 ui::CONTENT_PROTECTION_METHOD_NONE, |
279 base::Bind(&DoNothing)); | 177 base::Bind(&DoNothing)); |
280 } | 178 } |
281 display_id_ = new_display_id; | 179 display_id_ = new_display_id; |
282 } | 180 } |
283 | 181 |
284 void PepperOutputProtectionMessageFilter::Delegate::OnWindowDestroying( | 182 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { |
285 aura::Window* window) { | |
286 DCHECK_EQ(window, window_); | 183 DCHECK_EQ(window, window_); |
287 window_->RemoveObserver(this); | 184 window_->RemoveObserver(this); |
288 window_ = NULL; | 185 window_ = nullptr; |
289 } | |
290 #endif // defined(OS_CHROMEOS) | |
291 | |
292 PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter( | |
293 content::BrowserPpapiHost* host, | |
294 PP_Instance instance) | |
295 : weak_ptr_factory_(this) { | |
296 #if defined(OS_CHROMEOS) | |
297 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
298 int render_process_id = 0; | |
299 int render_frame_id = 0; | |
300 host->GetRenderFrameIDsForInstance( | |
301 instance, &render_process_id, &render_frame_id); | |
302 delegate_ = new Delegate(render_process_id, render_frame_id); | |
303 #else | |
304 NOTIMPLEMENTED(); | |
305 #endif | |
306 } | 186 } |
307 | 187 |
308 PepperOutputProtectionMessageFilter::~PepperOutputProtectionMessageFilter() { | 188 } // namespace chromeos |
309 #if defined(OS_CHROMEOS) | |
310 content::BrowserThread::DeleteSoon( | |
311 content::BrowserThread::UI, FROM_HERE, delegate_); | |
312 delegate_ = NULL; | |
313 #endif | |
314 } | |
315 | |
316 scoped_refptr<base::TaskRunner> | |
317 PepperOutputProtectionMessageFilter::OverrideTaskRunnerForMessage( | |
318 const IPC::Message& message) { | |
319 return content::BrowserThread::GetMessageLoopProxyForThread( | |
320 content::BrowserThread::UI); | |
321 } | |
322 | |
323 int32_t PepperOutputProtectionMessageFilter::OnResourceMessageReceived( | |
324 const IPC::Message& msg, | |
325 ppapi::host::HostMessageContext* context) { | |
326 PPAPI_BEGIN_MESSAGE_MAP(PepperOutputProtectionMessageFilter, msg) | |
327 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( | |
328 PpapiHostMsg_OutputProtection_QueryStatus, OnQueryStatus); | |
329 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | |
330 PpapiHostMsg_OutputProtection_EnableProtection, OnEnableProtection); | |
331 PPAPI_END_MESSAGE_MAP() | |
332 return PP_ERROR_FAILED; | |
333 } | |
334 | |
335 int32_t PepperOutputProtectionMessageFilter::OnQueryStatus( | |
336 ppapi::host::HostMessageContext* context) { | |
337 #if defined(OS_CHROMEOS) | |
338 ppapi::host::ReplyMessageContext reply_context = | |
339 context->MakeReplyMessageContext(); | |
340 delegate_->QueryStatus( | |
341 base::Bind(&PepperOutputProtectionMessageFilter::OnQueryStatusComplete, | |
342 weak_ptr_factory_.GetWeakPtr(), reply_context)); | |
343 return PP_OK_COMPLETIONPENDING; | |
344 #else | |
345 NOTIMPLEMENTED(); | |
346 return PP_ERROR_NOTSUPPORTED; | |
347 #endif | |
348 } | |
349 | |
350 int32_t PepperOutputProtectionMessageFilter::OnEnableProtection( | |
351 ppapi::host::HostMessageContext* context, | |
352 uint32_t desired_method_mask) { | |
353 #if defined(OS_CHROMEOS) | |
354 ppapi::host::ReplyMessageContext reply_context = | |
355 context->MakeReplyMessageContext(); | |
356 delegate_->EnableProtection( | |
357 desired_method_mask, | |
358 base::Bind( | |
359 &PepperOutputProtectionMessageFilter::OnEnableProtectionComplete, | |
360 weak_ptr_factory_.GetWeakPtr(), reply_context)); | |
361 return PP_OK_COMPLETIONPENDING; | |
362 #else | |
363 NOTIMPLEMENTED(); | |
364 return PP_ERROR_NOTSUPPORTED; | |
365 #endif | |
366 } | |
367 | |
368 void PepperOutputProtectionMessageFilter::OnQueryStatusComplete( | |
369 ppapi::host::ReplyMessageContext reply_context, | |
370 int32_t result, | |
371 uint32_t link_mask, | |
372 uint32_t protection_mask) { | |
373 reply_context.params.set_result(result); | |
374 SendReply(reply_context, PpapiPluginMsg_OutputProtection_QueryStatusReply( | |
375 link_mask, protection_mask)); | |
376 } | |
377 | |
378 void PepperOutputProtectionMessageFilter::OnEnableProtectionComplete( | |
379 ppapi::host::ReplyMessageContext reply_context, | |
380 int32_t result) { | |
381 reply_context.params.set_result(result); | |
382 SendReply(reply_context, | |
383 PpapiPluginMsg_OutputProtection_EnableProtectionReply()); | |
384 } | |
385 | |
386 } // namespace chrome | |
OLD | NEW |