| 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/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "ppapi/c/pp_errors.h" | 13 #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 | 14 |
| 20 #if defined(OS_CHROMEOS) | 15 #if !defined(OS_CHROMEOS) |
| 21 #include "ash/shell.h" | 16 #error This file is ChromeOS only. |
| 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 | 17 #endif |
| 27 | 18 |
| 28 namespace chrome { | 19 namespace chromeos { |
| 29 | 20 |
| 30 namespace { | 21 namespace { |
| 31 | 22 |
| 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) { | 23 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { |
| 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 70 gfx::NativeView native_view = rfh->GetNativeView(); | 25 gfx::NativeView native_view = rfh->GetNativeView(); |
| 71 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 26 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
| 72 if (!screen) | 27 if (!screen) |
| 73 return false; | 28 return false; |
| 74 gfx::Display display = screen->GetDisplayNearestWindow(native_view); | 29 gfx::Display display = screen->GetDisplayNearestWindow(native_view); |
| 75 *display_id = display.id(); | 30 *display_id = display.id(); |
| 76 return true; | 31 return true; |
| 77 } | 32 } |
| 78 | 33 |
| 79 void DoNothing(bool status) { | 34 void DoNothing(bool status) { |
| 80 } | 35 } |
| 81 | 36 |
| 82 #endif | |
| 83 | |
| 84 } // namespace | 37 } // namespace |
| 85 | 38 |
| 86 #if defined(OS_CHROMEOS) | 39 OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id, |
| 87 // Output protection delegate. All methods except constructor should be | 40 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), | 41 : render_process_id_(render_process_id), |
| 142 render_frame_id_(render_frame_id), | 42 render_frame_id_(render_frame_id), |
| 143 window_(NULL), | 43 window_(NULL), |
| 144 client_id_(ui::DisplayConfigurator::kInvalidClientId), | 44 client_id_(ui::DisplayConfigurator::kInvalidClientId), |
| 145 display_id_(0), | 45 display_id_(0), |
| 146 weak_ptr_factory_(this) { | 46 weak_ptr_factory_(this) { |
| 147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 47 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 148 } | 48 } |
| 149 | 49 |
| 150 PepperOutputProtectionMessageFilter::Delegate::~Delegate() { | 50 OutputProtectionDelegate::~OutputProtectionDelegate() { |
| 151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 152 | 52 |
| 153 ui::DisplayConfigurator* configurator = | 53 ui::DisplayConfigurator* configurator = |
| 154 ash::Shell::GetInstance()->display_configurator(); | 54 ash::Shell::GetInstance()->display_configurator(); |
| 155 configurator->UnregisterContentProtectionClient(client_id_); | 55 configurator->UnregisterContentProtectionClient(client_id_); |
| 156 | 56 |
| 157 if (window_) | 57 if (window_) |
| 158 window_->RemoveObserver(this); | 58 window_->RemoveObserver(this); |
| 159 } | 59 } |
| 160 | 60 |
| 161 ui::DisplayConfigurator::ContentProtectionClientId | 61 ui::DisplayConfigurator::ContentProtectionClientId |
| 162 PepperOutputProtectionMessageFilter::Delegate::GetClientId() { | 62 OutputProtectionDelegate::GetClientId() { |
| 163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 164 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { | 64 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { |
| 165 content::RenderFrameHost* rfh = | 65 content::RenderFrameHost* rfh = |
| 166 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 66 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 167 if (!GetCurrentDisplayId(rfh, &display_id_)) | 67 if (!GetCurrentDisplayId(rfh, &display_id_)) |
| 168 return ui::DisplayConfigurator::kInvalidClientId; | 68 return ui::DisplayConfigurator::kInvalidClientId; |
| 169 | 69 |
| 170 window_ = rfh->GetNativeView(); | 70 window_ = rfh->GetNativeView(); |
| 171 if (!window_) | 71 if (!window_) |
| 172 return ui::DisplayConfigurator::kInvalidClientId; | 72 return ui::DisplayConfigurator::kInvalidClientId; |
| 173 | 73 |
| 174 ui::DisplayConfigurator* configurator = | 74 ui::DisplayConfigurator* configurator = |
| 175 ash::Shell::GetInstance()->display_configurator(); | 75 ash::Shell::GetInstance()->display_configurator(); |
| 176 client_id_ = configurator->RegisterContentProtectionClient(); | 76 client_id_ = configurator->RegisterContentProtectionClient(); |
| 177 | 77 |
| 178 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) | 78 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) |
| 179 window_->AddObserver(this); | 79 window_->AddObserver(this); |
| 180 } | 80 } |
| 181 return client_id_; | 81 return client_id_; |
| 182 } | 82 } |
| 183 | 83 |
| 184 void PepperOutputProtectionMessageFilter::Delegate::QueryStatus( | 84 void OutputProtectionDelegate::QueryStatus( |
| 185 const QueryStatusCallback& callback) { | 85 const QueryStatusCallback& callback) { |
| 186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 187 | 87 |
| 188 content::RenderFrameHost* rfh = | 88 content::RenderFrameHost* rfh = |
| 189 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 89 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 190 if (!rfh) { | 90 if (!rfh) { |
| 191 LOG(WARNING) << "RenderFrameHost is not alive."; | 91 LOG(WARNING) << "RenderFrameHost is not alive."; |
| 192 callback.Run(PP_ERROR_FAILED, 0, 0); | 92 callback.Run(false, 0, 0); |
| 193 return; | 93 return; |
| 194 } | 94 } |
| 195 | 95 |
| 196 ui::DisplayConfigurator* configurator = | 96 ui::DisplayConfigurator* configurator = |
| 197 ash::Shell::GetInstance()->display_configurator(); | 97 ash::Shell::GetInstance()->display_configurator(); |
| 198 configurator->QueryContentProtectionStatus( | 98 configurator->QueryContentProtectionStatus( |
| 199 GetClientId(), display_id_, | 99 GetClientId(), display_id_, |
| 200 base::Bind( | 100 base::Bind(&OutputProtectionDelegate::QueryStatusComplete, |
| 201 &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete, | 101 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 202 weak_ptr_factory_.GetWeakPtr(), callback)); | |
| 203 } | 102 } |
| 204 | 103 |
| 205 void PepperOutputProtectionMessageFilter::Delegate::EnableProtection( | 104 void OutputProtectionDelegate::EnableProtection( |
| 206 uint32_t desired_method_mask, | 105 uint32_t desired_method_mask, |
| 207 const EnableProtectionCallback& callback) { | 106 const EnableProtectionCallback& callback) { |
| 208 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 209 | 108 |
| 210 ui::DisplayConfigurator* configurator = | 109 ui::DisplayConfigurator* configurator = |
| 211 ash::Shell::GetInstance()->display_configurator(); | 110 ash::Shell::GetInstance()->display_configurator(); |
| 212 configurator->EnableContentProtection( | 111 configurator->EnableContentProtection( |
| 213 GetClientId(), display_id_, desired_method_mask, | 112 GetClientId(), display_id_, desired_method_mask, |
| 214 base::Bind(&PepperOutputProtectionMessageFilter::Delegate:: | 113 base::Bind(&OutputProtectionDelegate::EnableProtectionComplete, |
| 215 EnableProtectionComplete, | |
| 216 weak_ptr_factory_.GetWeakPtr(), callback)); | 114 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 217 desired_method_mask_ = desired_method_mask; | 115 desired_method_mask_ = desired_method_mask; |
| 218 } | 116 } |
| 219 | 117 |
| 220 void PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete( | 118 void OutputProtectionDelegate::QueryStatusComplete( |
| 221 const QueryStatusCallback& callback, | 119 const QueryStatusCallback& callback, |
| 222 const ui::DisplayConfigurator::QueryProtectionResponse& response) { | 120 const ui::DisplayConfigurator::QueryProtectionResponse& response) { |
| 223 content::RenderFrameHost* rfh = | 121 content::RenderFrameHost* rfh = |
| 224 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 122 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 225 if (!rfh) { | 123 if (!rfh) { |
| 226 LOG(WARNING) << "RenderFrameHost is not alive."; | 124 LOG(WARNING) << "RenderFrameHost is not alive."; |
| 227 callback.Run(PP_ERROR_FAILED, 0, 0); | 125 callback.Run(false, 0, 0); |
| 228 return; | 126 return; |
| 229 } | 127 } |
| 230 | 128 |
| 231 uint32_t link_mask = response.link_mask; | 129 uint32_t link_mask = response.link_mask; |
| 232 // If we successfully retrieved the device level status, check for capturers. | 130 // If we successfully retrieved the device level status, check for capturers. |
| 233 if (response.success) { | 131 if (response.success) { |
| 234 const bool capture_detected = | 132 const bool capture_detected = |
| 235 // Check for tab capture on the current tab. | 133 // Check for tab capture on the current tab. |
| 236 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > | 134 content::WebContents::FromRenderFrameHost(rfh)->GetCapturerCount() > |
| 237 0 || | 135 0 || |
| 238 // Check for desktop capture. | 136 // Check for desktop capture. |
| 239 MediaCaptureDevicesDispatcher::GetInstance() | 137 MediaCaptureDevicesDispatcher::GetInstance() |
| 240 ->IsDesktopCaptureInProgress(); | 138 ->IsDesktopCaptureInProgress(); |
| 241 if (capture_detected) | 139 if (capture_detected) |
| 242 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; | 140 link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; |
| 243 } | 141 } |
| 244 | 142 |
| 245 callback.Run(response.success ? PP_OK : PP_ERROR_FAILED, link_mask, | 143 callback.Run(response.success, link_mask, response.protection_mask); |
| 246 response.protection_mask); | |
| 247 } | 144 } |
| 248 | 145 |
| 249 void PepperOutputProtectionMessageFilter::Delegate::EnableProtectionComplete( | 146 void OutputProtectionDelegate::EnableProtectionComplete( |
| 250 const EnableProtectionCallback& callback, | 147 const EnableProtectionCallback& callback, |
| 251 bool result) { | 148 bool success) { |
| 252 callback.Run(result ? PP_OK : PP_ERROR_FAILED); | 149 callback.Run(success); |
| 253 } | 150 } |
| 254 | 151 |
| 255 void PepperOutputProtectionMessageFilter::Delegate::OnWindowHierarchyChanged( | 152 void OutputProtectionDelegate::OnWindowHierarchyChanged( |
| 256 const aura::WindowObserver::HierarchyChangeParams& params) { | 153 const aura::WindowObserver::HierarchyChangeParams& params) { |
| 257 content::RenderFrameHost* rfh = | 154 content::RenderFrameHost* rfh = |
| 258 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 155 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 259 if (!rfh) { | 156 if (!rfh) { |
| 260 LOG(WARNING) << "RenderFrameHost is not alive."; | 157 LOG(WARNING) << "RenderFrameHost is not alive."; |
| 261 return; | 158 return; |
| 262 } | 159 } |
| 263 | 160 |
| 264 int64 new_display_id = 0; | 161 int64 new_display_id = 0; |
| 265 if (!GetCurrentDisplayId(rfh, &new_display_id)) | 162 if (!GetCurrentDisplayId(rfh, &new_display_id)) |
| 266 return; | 163 return; |
| 267 if (display_id_ == new_display_id) | 164 if (display_id_ == new_display_id) |
| 268 return; | 165 return; |
| 269 | 166 |
| 270 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { | 167 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { |
| 271 // Display changed and should enable output protections on new display. | 168 // Display changed and should enable output protections on new display. |
| 272 ui::DisplayConfigurator* configurator = | 169 ui::DisplayConfigurator* configurator = |
| 273 ash::Shell::GetInstance()->display_configurator(); | 170 ash::Shell::GetInstance()->display_configurator(); |
| 274 configurator->EnableContentProtection(GetClientId(), new_display_id, | 171 configurator->EnableContentProtection(GetClientId(), new_display_id, |
| 275 desired_method_mask_, | 172 desired_method_mask_, |
| 276 base::Bind(&DoNothing)); | 173 base::Bind(&DoNothing)); |
| 277 configurator->EnableContentProtection(GetClientId(), display_id_, | 174 configurator->EnableContentProtection(GetClientId(), display_id_, |
| 278 ui::CONTENT_PROTECTION_METHOD_NONE, | 175 ui::CONTENT_PROTECTION_METHOD_NONE, |
| 279 base::Bind(&DoNothing)); | 176 base::Bind(&DoNothing)); |
| 280 } | 177 } |
| 281 display_id_ = new_display_id; | 178 display_id_ = new_display_id; |
| 282 } | 179 } |
| 283 | 180 |
| 284 void PepperOutputProtectionMessageFilter::Delegate::OnWindowDestroying( | 181 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { |
| 285 aura::Window* window) { | |
| 286 DCHECK_EQ(window, window_); | 182 DCHECK_EQ(window, window_); |
| 287 window_->RemoveObserver(this); | 183 window_->RemoveObserver(this); |
| 288 window_ = NULL; | 184 window_ = NULL; |
| 289 } | 185 } |
| 290 #endif // defined(OS_CHROMEOS) | |
| 291 | 186 |
| 292 PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter( | 187 } // 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 | |
| OLD | NEW |