| Index: chrome/browser/chromeos/display/output_protection_delegate.cc
|
| diff --git a/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc b/chrome/browser/chromeos/display/output_protection_delegate.cc
|
| similarity index 36%
|
| copy from chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc
|
| copy to chrome/browser/chromeos/display/output_protection_delegate.cc
|
| index b999d075051d286de5d74a97bc2c41eeb0bbe285..53c1af1d2c5510e80a745df2115a372a31b19cb7 100644
|
| --- a/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc
|
| +++ b/chrome/browser/chromeos/display/output_protection_delegate.cc
|
| @@ -2,69 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.h"
|
| +#include "chrome/browser/chromeos/display/output_protection_delegate.h"
|
|
|
| +#include "ash/shell.h"
|
| +#include "ash/shell_delegate.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/media/media_capture_devices_dispatcher.h"
|
| -#include "content/public/browser/browser_ppapi_host.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| -#include "ppapi/c/pp_errors.h"
|
| -#include "ppapi/c/private/ppb_output_protection_private.h"
|
| -#include "ppapi/host/dispatch_host_message.h"
|
| -#include "ppapi/host/host_message_context.h"
|
| -#include "ppapi/host/ppapi_host.h"
|
| -#include "ppapi/proxy/ppapi_messages.h"
|
| -
|
| -#if defined(OS_CHROMEOS)
|
| -#include "ash/shell.h"
|
| -#include "ash/shell_delegate.h"
|
| -#include "ui/aura/window.h"
|
| -#include "ui/display/chromeos/display_configurator.h"
|
| #include "ui/gfx/screen.h"
|
| -#endif
|
|
|
| -namespace chrome {
|
| +namespace chromeos {
|
|
|
| namespace {
|
|
|
| -#if defined(OS_CHROMEOS)
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NONE),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE value mismatch");
|
| -static_assert(
|
| - static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_UNKNOWN),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN value mismatch");
|
| -static_assert(
|
| - static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_INTERNAL),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL value mismatch");
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_VGA),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA value mismatch");
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_HDMI),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI value mismatch");
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_DVI),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI value mismatch");
|
| -static_assert(
|
| - static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_DISPLAYPORT),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT value mismatch");
|
| -static_assert(
|
| - static_cast<int>(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK) ==
|
| - static_cast<int>(ui::DISPLAY_CONNECTION_TYPE_NETWORK),
|
| - "PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK value mismatch");
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) ==
|
| - static_cast<int>(ui::CONTENT_PROTECTION_METHOD_NONE),
|
| - "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE value mismatch");
|
| -static_assert(static_cast<int>(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) ==
|
| - static_cast<int>(ui::CONTENT_PROTECTION_METHOD_HDCP),
|
| - "PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP value mismatch");
|
| -
|
| bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| gfx::NativeView native_view = rfh->GetNativeView();
|
| @@ -79,75 +31,20 @@ bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
|
| void DoNothing(bool status) {
|
| }
|
|
|
| -#endif
|
| -
|
| } // namespace
|
|
|
| -#if defined(OS_CHROMEOS)
|
| -// Output protection delegate. All methods except constructor should be
|
| -// invoked in UI thread.
|
| -class PepperOutputProtectionMessageFilter::Delegate
|
| - : public aura::WindowObserver {
|
| - public:
|
| - typedef base::Callback<void(int32_t /* result */,
|
| - uint32_t /* link_mask */,
|
| - uint32_t /* protection_mask*/)>
|
| - QueryStatusCallback;
|
| - typedef base::Callback<void(int32_t /* result */)> EnableProtectionCallback;
|
| -
|
| - Delegate(int render_process_id, int render_frame_id);
|
| - ~Delegate() override;
|
| -
|
| - // aura::WindowObserver overrides.
|
| - void OnWindowHierarchyChanged(
|
| - const aura::WindowObserver::HierarchyChangeParams& params) override;
|
| - void OnWindowDestroying(aura::Window* window) override;
|
| -
|
| - void QueryStatus(const QueryStatusCallback& callback);
|
| - void EnableProtection(uint32_t desired_method_mask,
|
| - const EnableProtectionCallback& callback);
|
| -
|
| - private:
|
| - ui::DisplayConfigurator::ContentProtectionClientId GetClientId();
|
| -
|
| - void QueryStatusComplete(
|
| - const QueryStatusCallback& callback,
|
| - const ui::DisplayConfigurator::QueryProtectionResponse& response);
|
| - void EnableProtectionComplete(const EnableProtectionCallback& callback,
|
| - bool success);
|
| -
|
| - // Used to lookup the WebContents associated with this PP_Instance.
|
| - int render_process_id_;
|
| - int render_frame_id_;
|
| -
|
| - // Native window being observed.
|
| - aura::Window* window_;
|
| -
|
| - ui::DisplayConfigurator::ContentProtectionClientId client_id_;
|
| -
|
| - // The display id which the renderer currently uses.
|
| - int64 display_id_;
|
| -
|
| - // The last desired method mask. Will enable this mask on new display if
|
| - // renderer changes display.
|
| - uint32_t desired_method_mask_;
|
| -
|
| - base::WeakPtrFactory<PepperOutputProtectionMessageFilter::Delegate>
|
| - weak_ptr_factory_;
|
| -};
|
| -
|
| -PepperOutputProtectionMessageFilter::Delegate::Delegate(int render_process_id,
|
| - int render_frame_id)
|
| +OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id,
|
| + int render_frame_id)
|
| : render_process_id_(render_process_id),
|
| render_frame_id_(render_frame_id),
|
| - window_(NULL),
|
| + window_(nullptr),
|
| client_id_(ui::DisplayConfigurator::kInvalidClientId),
|
| display_id_(0),
|
| weak_ptr_factory_(this) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
| }
|
|
|
| -PepperOutputProtectionMessageFilter::Delegate::~Delegate() {
|
| +OutputProtectionDelegate::~OutputProtectionDelegate() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| ui::DisplayConfigurator* configurator =
|
| @@ -159,7 +56,7 @@ PepperOutputProtectionMessageFilter::Delegate::~Delegate() {
|
| }
|
|
|
| ui::DisplayConfigurator::ContentProtectionClientId
|
| -PepperOutputProtectionMessageFilter::Delegate::GetClientId() {
|
| +OutputProtectionDelegate::GetClientId() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) {
|
| content::RenderFrameHost* rfh =
|
| @@ -181,7 +78,7 @@ PepperOutputProtectionMessageFilter::Delegate::GetClientId() {
|
| return client_id_;
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::QueryStatus(
|
| +void OutputProtectionDelegate::QueryStatus(
|
| const QueryStatusCallback& callback) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| @@ -189,7 +86,7 @@ void PepperOutputProtectionMessageFilter::Delegate::QueryStatus(
|
| content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
| if (!rfh) {
|
| LOG(WARNING) << "RenderFrameHost is not alive.";
|
| - callback.Run(PP_ERROR_FAILED, 0, 0);
|
| + callback.Run(false, 0, 0);
|
| return;
|
| }
|
|
|
| @@ -197,12 +94,11 @@ void PepperOutputProtectionMessageFilter::Delegate::QueryStatus(
|
| ash::Shell::GetInstance()->display_configurator();
|
| configurator->QueryContentProtectionStatus(
|
| GetClientId(), display_id_,
|
| - base::Bind(
|
| - &PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete,
|
| - weak_ptr_factory_.GetWeakPtr(), callback));
|
| + base::Bind(&OutputProtectionDelegate::QueryStatusComplete,
|
| + weak_ptr_factory_.GetWeakPtr(), callback));
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::EnableProtection(
|
| +void OutputProtectionDelegate::EnableProtection(
|
| uint32_t desired_method_mask,
|
| const EnableProtectionCallback& callback) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| @@ -211,20 +107,21 @@ void PepperOutputProtectionMessageFilter::Delegate::EnableProtection(
|
| ash::Shell::GetInstance()->display_configurator();
|
| configurator->EnableContentProtection(
|
| GetClientId(), display_id_, desired_method_mask,
|
| - base::Bind(&PepperOutputProtectionMessageFilter::Delegate::
|
| - EnableProtectionComplete,
|
| + base::Bind(&OutputProtectionDelegate::EnableProtectionComplete,
|
| weak_ptr_factory_.GetWeakPtr(), callback));
|
| desired_method_mask_ = desired_method_mask;
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete(
|
| +void OutputProtectionDelegate::QueryStatusComplete(
|
| const QueryStatusCallback& callback,
|
| const ui::DisplayConfigurator::QueryProtectionResponse& response) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| content::RenderFrameHost* rfh =
|
| content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
| if (!rfh) {
|
| LOG(WARNING) << "RenderFrameHost is not alive.";
|
| - callback.Run(PP_ERROR_FAILED, 0, 0);
|
| + callback.Run(false, 0, 0);
|
| return;
|
| }
|
|
|
| @@ -242,17 +139,18 @@ void PepperOutputProtectionMessageFilter::Delegate::QueryStatusComplete(
|
| link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK;
|
| }
|
|
|
| - callback.Run(response.success ? PP_OK : PP_ERROR_FAILED, link_mask,
|
| - response.protection_mask);
|
| + callback.Run(response.success, link_mask, response.protection_mask);
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::EnableProtectionComplete(
|
| +void OutputProtectionDelegate::EnableProtectionComplete(
|
| const EnableProtectionCallback& callback,
|
| - bool result) {
|
| - callback.Run(result ? PP_OK : PP_ERROR_FAILED);
|
| + bool success) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + callback.Run(success);
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::OnWindowHierarchyChanged(
|
| +void OutputProtectionDelegate::OnWindowHierarchyChanged(
|
| const aura::WindowObserver::HierarchyChangeParams& params) {
|
| content::RenderFrameHost* rfh =
|
| content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
| @@ -281,106 +179,10 @@ void PepperOutputProtectionMessageFilter::Delegate::OnWindowHierarchyChanged(
|
| display_id_ = new_display_id;
|
| }
|
|
|
| -void PepperOutputProtectionMessageFilter::Delegate::OnWindowDestroying(
|
| - aura::Window* window) {
|
| +void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) {
|
| DCHECK_EQ(window, window_);
|
| window_->RemoveObserver(this);
|
| - window_ = NULL;
|
| -}
|
| -#endif // defined(OS_CHROMEOS)
|
| -
|
| -PepperOutputProtectionMessageFilter::PepperOutputProtectionMessageFilter(
|
| - content::BrowserPpapiHost* host,
|
| - PP_Instance instance)
|
| - : weak_ptr_factory_(this) {
|
| -#if defined(OS_CHROMEOS)
|
| - DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
| - int render_process_id = 0;
|
| - int render_frame_id = 0;
|
| - host->GetRenderFrameIDsForInstance(
|
| - instance, &render_process_id, &render_frame_id);
|
| - delegate_ = new Delegate(render_process_id, render_frame_id);
|
| -#else
|
| - NOTIMPLEMENTED();
|
| -#endif
|
| -}
|
| -
|
| -PepperOutputProtectionMessageFilter::~PepperOutputProtectionMessageFilter() {
|
| -#if defined(OS_CHROMEOS)
|
| - content::BrowserThread::DeleteSoon(
|
| - content::BrowserThread::UI, FROM_HERE, delegate_);
|
| - delegate_ = NULL;
|
| -#endif
|
| -}
|
| -
|
| -scoped_refptr<base::TaskRunner>
|
| -PepperOutputProtectionMessageFilter::OverrideTaskRunnerForMessage(
|
| - const IPC::Message& message) {
|
| - return content::BrowserThread::GetMessageLoopProxyForThread(
|
| - content::BrowserThread::UI);
|
| -}
|
| -
|
| -int32_t PepperOutputProtectionMessageFilter::OnResourceMessageReceived(
|
| - const IPC::Message& msg,
|
| - ppapi::host::HostMessageContext* context) {
|
| - PPAPI_BEGIN_MESSAGE_MAP(PepperOutputProtectionMessageFilter, msg)
|
| - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
|
| - PpapiHostMsg_OutputProtection_QueryStatus, OnQueryStatus);
|
| - PPAPI_DISPATCH_HOST_RESOURCE_CALL(
|
| - PpapiHostMsg_OutputProtection_EnableProtection, OnEnableProtection);
|
| - PPAPI_END_MESSAGE_MAP()
|
| - return PP_ERROR_FAILED;
|
| -}
|
| -
|
| -int32_t PepperOutputProtectionMessageFilter::OnQueryStatus(
|
| - ppapi::host::HostMessageContext* context) {
|
| -#if defined(OS_CHROMEOS)
|
| - ppapi::host::ReplyMessageContext reply_context =
|
| - context->MakeReplyMessageContext();
|
| - delegate_->QueryStatus(
|
| - base::Bind(&PepperOutputProtectionMessageFilter::OnQueryStatusComplete,
|
| - weak_ptr_factory_.GetWeakPtr(), reply_context));
|
| - return PP_OK_COMPLETIONPENDING;
|
| -#else
|
| - NOTIMPLEMENTED();
|
| - return PP_ERROR_NOTSUPPORTED;
|
| -#endif
|
| -}
|
| -
|
| -int32_t PepperOutputProtectionMessageFilter::OnEnableProtection(
|
| - ppapi::host::HostMessageContext* context,
|
| - uint32_t desired_method_mask) {
|
| -#if defined(OS_CHROMEOS)
|
| - ppapi::host::ReplyMessageContext reply_context =
|
| - context->MakeReplyMessageContext();
|
| - delegate_->EnableProtection(
|
| - desired_method_mask,
|
| - base::Bind(
|
| - &PepperOutputProtectionMessageFilter::OnEnableProtectionComplete,
|
| - weak_ptr_factory_.GetWeakPtr(), reply_context));
|
| - return PP_OK_COMPLETIONPENDING;
|
| -#else
|
| - NOTIMPLEMENTED();
|
| - return PP_ERROR_NOTSUPPORTED;
|
| -#endif
|
| -}
|
| -
|
| -void PepperOutputProtectionMessageFilter::OnQueryStatusComplete(
|
| - ppapi::host::ReplyMessageContext reply_context,
|
| - int32_t result,
|
| - uint32_t link_mask,
|
| - uint32_t protection_mask) {
|
| - reply_context.params.set_result(result);
|
| - SendReply(reply_context, PpapiPluginMsg_OutputProtection_QueryStatusReply(
|
| - link_mask, protection_mask));
|
| -}
|
| -
|
| -void PepperOutputProtectionMessageFilter::OnEnableProtectionComplete(
|
| - ppapi::host::ReplyMessageContext reply_context,
|
| - int32_t result) {
|
| - reply_context.params.set_result(result);
|
| - SendReply(reply_context,
|
| - PpapiPluginMsg_OutputProtection_EnableProtectionReply());
|
| + window_ = nullptr;
|
| }
|
|
|
| -} // namespace chrome
|
| +} // namespace chromeos
|
|
|