Commit 88c0194a authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Commit Bot

display: Remove OutputProtectionControllerAsh

The controller interface is a remnant from Mus.

Bug: 929449
Test: Build
Change-Id: Ia1cafc13fb404e7f80e31eafa9257acd7b8913d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1686039
Commit-Queue: Dominik Laskowski <domlaskowski@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675870}
parent ec84b1b8
...@@ -253,8 +253,6 @@ component("ash") { ...@@ -253,8 +253,6 @@ component("ash") {
"display/mouse_warp_controller.h", "display/mouse_warp_controller.h",
"display/null_mouse_warp_controller.cc", "display/null_mouse_warp_controller.cc",
"display/null_mouse_warp_controller.h", "display/null_mouse_warp_controller.h",
"display/output_protection_controller_ash.cc",
"display/output_protection_controller_ash.h",
"display/output_protection_delegate.cc", "display/output_protection_delegate.cc",
"display/output_protection_delegate.h", "display/output_protection_delegate.h",
"display/overscan_calibrator.cc", "display/overscan_calibrator.cc",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/display/output_protection_controller_ash.h"
#include "ui/display/manager/display_configurator.h"
#include "ash/shell.h"
namespace {
display::ContentProtectionManager* manager() {
return ash::Shell::Get()
->display_configurator()
->content_protection_manager();
}
} // namespace
namespace ash {
OutputProtectionControllerAsh::OutputProtectionControllerAsh()
: client_id_(manager()->RegisterClient()) {}
OutputProtectionControllerAsh::~OutputProtectionControllerAsh() {
DCHECK(thread_checker_.CalledOnValidThread());
manager()->UnregisterClient(client_id_);
}
void OutputProtectionControllerAsh::QueryStatus(int64_t display_id,
QueryStatusCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
manager()->QueryContentProtection(client_id_, display_id,
std::move(callback));
}
void OutputProtectionControllerAsh::SetProtection(
int64_t display_id,
uint32_t protection_mask,
SetProtectionCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
manager()->ApplyContentProtection(client_id_, display_id, protection_mask,
std::move(callback));
}
} // namespace ash
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_ASH_H_
#define ASH_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_ASH_H_
#include "ash/display/output_protection_delegate.h"
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "ui/display/manager/content_protection_manager.h"
namespace ash {
// Display content protection controller for running with ash.
class OutputProtectionControllerAsh
: public OutputProtectionDelegate::Controller {
public:
OutputProtectionControllerAsh();
~OutputProtectionControllerAsh() override;
// OutputProtectionDelegate::Controller:
void QueryStatus(int64_t display_id, QueryStatusCallback callback) override;
void SetProtection(int64_t display_id,
uint32_t protection_mask,
SetProtectionCallback callback) override;
private:
const display::ContentProtectionManager::ClientId client_id_;
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(OutputProtectionControllerAsh);
};
} // namespace ash
#endif // ASH_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_ASH_H_
...@@ -4,16 +4,30 @@ ...@@ -4,16 +4,30 @@
#include "ash/display/output_protection_delegate.h" #include "ash/display/output_protection_delegate.h"
#include "ash/display/output_protection_controller_ash.h" #include "ash/shell.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/manager/content_protection_manager.h"
#include "ui/display/manager/display_configurator.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
namespace ash { namespace ash {
OutputProtectionDelegate::Controller::Controller() = default; namespace {
OutputProtectionDelegate::Controller::~Controller() = default;
display::ContentProtectionManager* manager() {
return Shell::Get()->display_configurator()->content_protection_manager();
}
} // namespace
struct OutputProtectionDelegate::ClientIdHolder {
ClientIdHolder() : id(manager()->RegisterClient()) {}
~ClientIdHolder() { manager()->UnregisterClient(id); }
const display::ContentProtectionManager::ClientId id;
};
OutputProtectionDelegate::OutputProtectionDelegate(aura::Window* window) OutputProtectionDelegate::OutputProtectionDelegate(aura::Window* window)
: window_(window), : window_(window),
...@@ -62,27 +76,27 @@ void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { ...@@ -62,27 +76,27 @@ void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) {
window_ = nullptr; window_ = nullptr;
} }
void OutputProtectionDelegate::QueryStatus( void OutputProtectionDelegate::QueryStatus(QueryStatusCallback callback) {
Controller::QueryStatusCallback callback) { if (!RegisterClientIfNecessary()) {
if (!InitializeControllerIfNecessary()) {
std::move(callback).Run(/*success=*/false, std::move(callback).Run(/*success=*/false,
display::DISPLAY_CONNECTION_TYPE_NONE, display::DISPLAY_CONNECTION_TYPE_NONE,
display::CONTENT_PROTECTION_METHOD_NONE); display::CONTENT_PROTECTION_METHOD_NONE);
return; return;
} }
controller_->QueryStatus(display_id_, std::move(callback)); manager()->QueryContentProtection(client_->id, display_id_,
std::move(callback));
} }
void OutputProtectionDelegate::SetProtection( void OutputProtectionDelegate::SetProtection(uint32_t protection_mask,
uint32_t protection_mask, SetProtectionCallback callback) {
Controller::SetProtectionCallback callback) { if (!RegisterClientIfNecessary()) {
if (!InitializeControllerIfNecessary()) {
std::move(callback).Run(/*success=*/false); std::move(callback).Run(/*success=*/false);
return; return;
} }
controller_->SetProtection(display_id_, protection_mask, std::move(callback)); manager()->ApplyContentProtection(client_->id, display_id_, protection_mask,
std::move(callback));
protection_mask_ = protection_mask; protection_mask_ = protection_mask;
} }
...@@ -95,22 +109,22 @@ void OutputProtectionDelegate::OnWindowMayHaveMovedToAnotherDisplay() { ...@@ -95,22 +109,22 @@ void OutputProtectionDelegate::OnWindowMayHaveMovedToAnotherDisplay() {
return; return;
if (protection_mask_ != display::CONTENT_PROTECTION_METHOD_NONE) { if (protection_mask_ != display::CONTENT_PROTECTION_METHOD_NONE) {
DCHECK(controller_); DCHECK(client_);
controller_->SetProtection(new_display_id, protection_mask_, manager()->ApplyContentProtection(client_->id, new_display_id,
base::DoNothing()); protection_mask_, base::DoNothing());
controller_->SetProtection(display_id_, manager()->ApplyContentProtection(client_->id, display_id_,
display::CONTENT_PROTECTION_METHOD_NONE, display::CONTENT_PROTECTION_METHOD_NONE,
base::DoNothing()); base::DoNothing());
} }
display_id_ = new_display_id; display_id_ = new_display_id;
} }
bool OutputProtectionDelegate::InitializeControllerIfNecessary() { bool OutputProtectionDelegate::RegisterClientIfNecessary() {
if (!window_) if (!window_)
return false; return false;
if (!controller_) if (!client_)
controller_ = std::make_unique<OutputProtectionControllerAsh>(); client_ = std::make_unique<ClientIdHolder>();
return true; return true;
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/display/display_observer.h" #include "ui/display/display_observer.h"
...@@ -19,32 +18,22 @@ ...@@ -19,32 +18,22 @@
namespace ash { namespace ash {
// A class to query output protection status and/or enable output protection. // Proxies output protection requests for an associated window, and renews them
// All methods except constructor should be invoked in UI thread. // when the window is reparented to another display.
class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver, class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver,
public display::DisplayObserver { public display::DisplayObserver {
public:
class Controller {
public: public:
using QueryStatusCallback = base::OnceCallback< using QueryStatusCallback = base::OnceCallback<
void(bool success, uint32_t connection_mask, uint32_t protection_mask)>; void(bool success, uint32_t connection_mask, uint32_t protection_mask)>;
using SetProtectionCallback = base::OnceCallback<void(bool success)>; using SetProtectionCallback = base::OnceCallback<void(bool success)>;
Controller();
virtual ~Controller();
virtual void QueryStatus(int64_t display_id,
QueryStatusCallback callback) = 0;
virtual void SetProtection(int64_t display_id,
uint32_t protection_mask,
SetProtectionCallback callback) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Controller);
};
explicit OutputProtectionDelegate(aura::Window* window); explicit OutputProtectionDelegate(aura::Window* window);
~OutputProtectionDelegate() override; ~OutputProtectionDelegate() override;
void QueryStatus(QueryStatusCallback callback);
void SetProtection(uint32_t protection_mask, SetProtectionCallback callback);
private:
// display::DisplayObserver: // display::DisplayObserver:
void OnDisplayMetricsChanged(const display::Display& display, void OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) override; uint32_t changed_metrics) override;
...@@ -54,14 +43,9 @@ class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver, ...@@ -54,14 +43,9 @@ class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver,
const aura::WindowObserver::HierarchyChangeParams& params) override; const aura::WindowObserver::HierarchyChangeParams& params) override;
void OnWindowDestroying(aura::Window* window) override; void OnWindowDestroying(aura::Window* window) override;
void QueryStatus(Controller::QueryStatusCallback callback);
void SetProtection(uint32_t protection_mask,
Controller::SetProtectionCallback callback);
private:
void OnWindowMayHaveMovedToAnotherDisplay(); void OnWindowMayHaveMovedToAnotherDisplay();
bool InitializeControllerIfNecessary(); bool RegisterClientIfNecessary();
// Native window being observed. // Native window being observed.
aura::Window* window_ = nullptr; aura::Window* window_ = nullptr;
...@@ -73,10 +57,9 @@ class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver, ...@@ -73,10 +57,9 @@ class ASH_EXPORT OutputProtectionDelegate : public aura::WindowObserver,
// window moves to another display. // window moves to another display.
uint32_t protection_mask_ = display::CONTENT_PROTECTION_METHOD_NONE; uint32_t protection_mask_ = display::CONTENT_PROTECTION_METHOD_NONE;
// The display content protection controller. // RAII wrapper to register/unregister ContentProtectionManager client.
std::unique_ptr<Controller> controller_; struct ClientIdHolder;
std::unique_ptr<ClientIdHolder> client_;
base::WeakPtrFactory<OutputProtectionDelegate> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(OutputProtectionDelegate); DISALLOW_COPY_AND_ASSIGN(OutputProtectionDelegate);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment