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

Side by Side Diff: chrome/browser/chromeos/display/output_protection_delegate.cc

Issue 1139923006: Move PepperOutputProtectionMessageFilter::Delegate to OutputProtectionDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 7 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
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 #if !defined(OS_CHROMEOS)
21 #include "ash/shell.h" 17 #error This file is ChromeOS only.
Jun Mukai 2015/05/19 04:10:31 You don't have to have this, it's in chrome/browse
xhwang 2015/05/19 05:29:44 Done.
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 18 #endif
27 19
28 namespace chrome { 20 namespace chromeos {
29 21
30 namespace { 22 namespace {
31 23
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) { 24 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
70 gfx::NativeView native_view = rfh->GetNativeView(); 26 gfx::NativeView native_view = rfh->GetNativeView();
71 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); 27 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
72 if (!screen) 28 if (!screen)
73 return false; 29 return false;
74 gfx::Display display = screen->GetDisplayNearestWindow(native_view); 30 gfx::Display display = screen->GetDisplayNearestWindow(native_view);
75 *display_id = display.id(); 31 *display_id = display.id();
76 return true; 32 return true;
77 } 33 }
78 34
79 void DoNothing(bool status) { 35 void DoNothing(bool status) {
80 } 36 }
81 37
82 #endif
83
84 } // namespace 38 } // namespace
85 39
86 #if defined(OS_CHROMEOS) 40 OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id,
87 // Output protection delegate. All methods except constructor should be 41 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), 42 : render_process_id_(render_process_id),
142 render_frame_id_(render_frame_id), 43 render_frame_id_(render_frame_id),
143 window_(NULL), 44 window_(NULL),
Jun Mukai 2015/05/19 04:10:31 nit: nullptr
xhwang 2015/05/19 05:29:44 Done.
144 client_id_(ui::DisplayConfigurator::kInvalidClientId), 45 client_id_(ui::DisplayConfigurator::kInvalidClientId),
145 display_id_(0), 46 display_id_(0),
146 weak_ptr_factory_(this) { 47 weak_ptr_factory_(this) {
147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 48 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
148 } 49 }
149 50
150 PepperOutputProtectionMessageFilter::Delegate::~Delegate() { 51 OutputProtectionDelegate::~OutputProtectionDelegate() {
151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
152 53
153 ui::DisplayConfigurator* configurator = 54 ui::DisplayConfigurator* configurator =
154 ash::Shell::GetInstance()->display_configurator(); 55 ash::Shell::GetInstance()->display_configurator();
155 configurator->UnregisterContentProtectionClient(client_id_); 56 configurator->UnregisterContentProtectionClient(client_id_);
156 57
157 if (window_) 58 if (window_)
158 window_->RemoveObserver(this); 59 window_->RemoveObserver(this);
159 } 60 }
160 61
161 ui::DisplayConfigurator::ContentProtectionClientId 62 ui::DisplayConfigurator::ContentProtectionClientId
162 PepperOutputProtectionMessageFilter::Delegate::GetClientId() { 63 OutputProtectionDelegate::GetClientId() {
163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
164 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { 65 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) {
165 content::RenderFrameHost* rfh = 66 content::RenderFrameHost* rfh =
166 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 67 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
167 if (!GetCurrentDisplayId(rfh, &display_id_)) 68 if (!GetCurrentDisplayId(rfh, &display_id_))
168 return ui::DisplayConfigurator::kInvalidClientId; 69 return ui::DisplayConfigurator::kInvalidClientId;
169 70
170 window_ = rfh->GetNativeView(); 71 window_ = rfh->GetNativeView();
171 if (!window_) 72 if (!window_)
172 return ui::DisplayConfigurator::kInvalidClientId; 73 return ui::DisplayConfigurator::kInvalidClientId;
173 74
174 ui::DisplayConfigurator* configurator = 75 ui::DisplayConfigurator* configurator =
175 ash::Shell::GetInstance()->display_configurator(); 76 ash::Shell::GetInstance()->display_configurator();
176 client_id_ = configurator->RegisterContentProtectionClient(); 77 client_id_ = configurator->RegisterContentProtectionClient();
177 78
178 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) 79 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId)
179 window_->AddObserver(this); 80 window_->AddObserver(this);
180 } 81 }
181 return client_id_; 82 return client_id_;
182 } 83 }
183 84
184 void PepperOutputProtectionMessageFilter::Delegate::QueryStatus( 85 void OutputProtectionDelegate::QueryStatus(
185 const QueryStatusCallback& callback) { 86 const QueryStatusCallback& callback) {
186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
187 88
188 content::RenderFrameHost* rfh = 89 content::RenderFrameHost* rfh =
189 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 90 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
190 if (!rfh) { 91 if (!rfh) {
191 LOG(WARNING) << "RenderFrameHost is not alive."; 92 LOG(WARNING) << "RenderFrameHost is not alive.";
192 callback.Run(PP_ERROR_FAILED, 0, 0); 93 callback.Run(false, 0, 0);
193 return; 94 return;
194 } 95 }
195 96
196 ui::DisplayConfigurator* configurator = 97 ui::DisplayConfigurator* configurator =
197 ash::Shell::GetInstance()->display_configurator(); 98 ash::Shell::GetInstance()->display_configurator();
198 configurator->QueryContentProtectionStatus( 99 configurator->QueryContentProtectionStatus(
199 GetClientId(), display_id_, 100 GetClientId(), display_id_,
200 base::Bind( 101 base::Bind(&OutputProtectionDelegate::QueryStatusComplete,
201 &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete, 102 weak_ptr_factory_.GetWeakPtr(), callback));
202 weak_ptr_factory_.GetWeakPtr(), callback));
203 } 103 }
204 104
205 void PepperOutputProtectionMessageFilter::Delegate::EnableProtection( 105 void OutputProtectionDelegate::EnableProtection(
206 uint32_t desired_method_mask, 106 uint32_t desired_method_mask,
207 const EnableProtectionCallback& callback) { 107 const EnableProtectionCallback& callback) {
208 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
209 109
210 ui::DisplayConfigurator* configurator = 110 ui::DisplayConfigurator* configurator =
211 ash::Shell::GetInstance()->display_configurator(); 111 ash::Shell::GetInstance()->display_configurator();
212 configurator->EnableContentProtection( 112 configurator->EnableContentProtection(
213 GetClientId(), display_id_, desired_method_mask, 113 GetClientId(), display_id_, desired_method_mask,
214 base::Bind(&PepperOutputProtectionMessageFilter::Delegate:: 114 base::Bind(&OutputProtectionDelegate::EnableProtectionComplete,
215 EnableProtectionComplete,
216 weak_ptr_factory_.GetWeakPtr(), callback)); 115 weak_ptr_factory_.GetWeakPtr(), callback));
217 desired_method_mask_ = desired_method_mask; 116 desired_method_mask_ = desired_method_mask;
218 } 117 }
219 118
220 void PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete( 119 void OutputProtectionDelegate::QueryStatusComplete(
221 const QueryStatusCallback& callback, 120 const QueryStatusCallback& callback,
222 const ui::DisplayConfigurator::QueryProtectionResponse& response) { 121 const ui::DisplayConfigurator::QueryProtectionResponse& response) {
Jun Mukai 2015/05/19 04:10:31 Why not DCHECK_CURRENTLY_ON?
xhwang 2015/05/19 05:29:44 Done.
223 content::RenderFrameHost* rfh = 122 content::RenderFrameHost* rfh =
224 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 123 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
225 if (!rfh) { 124 if (!rfh) {
226 LOG(WARNING) << "RenderFrameHost is not alive."; 125 LOG(WARNING) << "RenderFrameHost is not alive.";
227 callback.Run(PP_ERROR_FAILED, 0, 0); 126 callback.Run(false, 0, 0);
228 return; 127 return;
229 } 128 }
230 129
231 uint32_t link_mask = response.link_mask; 130 uint32_t link_mask = response.link_mask;
232 // If we successfully retrieved the device level status, check for capturers. 131 // If we successfully retrieved the device level status, check for capturers.
233 if (response.success) { 132 if (response.success) {
234 const bool capture_detected = 133 const bool capture_detected =
235 // Check for tab capture on the current tab. 134 // Check for tab capture on the current tab.
236 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > 135 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() >
237 0 || 136 0 ||
238 // Check for desktop capture. 137 // Check for desktop capture.
239 MediaCaptureDevicesDispatcher::GetInstance() 138 MediaCaptureDevicesDispatcher::GetInstance()
240 ->IsDesktopCaptureInProgress(); 139 ->IsDesktopCaptureInProgress();
241 if (capture_detected) 140 if (capture_detected)
242 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; 141 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK;
243 } 142 }
244 143
245 callback.Run(response.success ? PP_OK : PP_ERROR_FAILED, link_mask, 144 callback.Run(response.success, link_mask, response.protection_mask);
246 response.protection_mask);
247 } 145 }
248 146
249 void PepperOutputProtectionMessageFilter::Delegate::EnableProtectionComplete( 147 void OutputProtectionDelegate::EnableProtectionComplete(
250 const EnableProtectionCallback& callback, 148 const EnableProtectionCallback& callback,
251 bool result) { 149 bool success) {
252 callback.Run(result ? PP_OK : PP_ERROR_FAILED); 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_ = NULL;
Jun Mukai 2015/05/19 04:10:31 nullptr
xhwang 2015/05/19 05:29:44 Done.
289 } 186 }
290 #endif // defined(OS_CHROMEOS)
291 187
292 PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter( 188 } // namespace chromeos
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 }
307
308 PepperOutputProtectionMessageFilter::~PepperOutputProtectionMessageFilter() {
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698