Commit ce3b8638 authored by Sean Topping's avatar Sean Topping Committed by Commit Bot

[Chromecast] Extend AuraComponents on Aura platforms

AuraComponents is intended only to expose virtual interfaces for objects
that only have valid implementations on Aura platforms. LayoutProvider
is not pure virtual, so it must live in a subclass of AuraComponents.

Bug: internal b/172316742
Test: CQ
Change-Id: Id66e6b19e55154437967b1df6260e45ac51b337e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561738Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Sean Topping <seantopping@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831237}
parent e033cdf6
...@@ -46,12 +46,21 @@ cast_source_set("display_settings_manager") { ...@@ -46,12 +46,21 @@ cast_source_set("display_settings_manager") {
} }
cast_source_set("aura_components") { cast_source_set("aura_components") {
sources = [ "aura_components.h" ] sources = [
"aura_components.cc",
"aura_components.h",
]
deps = [ ":public" ] deps = [
":public",
"//base",
]
if (use_aura) { if (use_aura) {
sources += [ "aura_components.cc" ] sources += [
"aura_components_impl.cc",
"aura_components_impl.h",
]
deps += [ deps += [
":media_overlay", ":media_overlay",
......
...@@ -4,17 +4,9 @@ ...@@ -4,17 +4,9 @@
#include "chromecast/ui/aura_components.h" #include "chromecast/ui/aura_components.h"
#include "chromecast/ui/media_overlay_impl.h"
namespace chromecast { namespace chromecast {
AuraComponents::AuraComponents(CastWindowManager* cast_window_manager) AuraComponents::AuraComponents() = default;
#if defined(ENABLE_MEDIA_OVERLAY)
: media_overlay_(std::make_unique<MediaOverlayImpl>(cast_window_manager))
#endif
{
}
AuraComponents::~AuraComponents() = default; AuraComponents::~AuraComponents() = default;
} // namespace chromecast } // namespace chromecast
...@@ -23,13 +23,15 @@ class CastWindowManager; ...@@ -23,13 +23,15 @@ class CastWindowManager;
// can therefore be written in a platform-agnostic way. // can therefore be written in a platform-agnostic way.
class AuraComponents { class AuraComponents {
public: public:
explicit AuraComponents(CastWindowManager* cast_window_manager); static std::unique_ptr<AuraComponents> Create(
~AuraComponents(); CastWindowManager* cast_window_manager);
AuraComponents();
virtual ~AuraComponents();
MediaOverlay* media_overlay() const { return media_overlay_.get(); } MediaOverlay* media_overlay() const { return media_overlay_.get(); }
private: protected:
views::LayoutProvider layout_provider_;
std::unique_ptr<MediaOverlay> media_overlay_; std::unique_ptr<MediaOverlay> media_overlay_;
}; };
......
// Copyright 2019 The Chromium Authors. All rights reserved. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
namespace chromecast { namespace chromecast {
AuraComponents::AuraComponents(CastWindowManager* cast_window_manager) // static
: media_overlay_(nullptr) {} std::unique_ptr<AuraComponents> AuraComponents::Create(
CastWindowManager* cast_window_manager) {
AuraComponents::~AuraComponents() = default; return std::make_unique<AuraComponents>();
}
} // namespace chromecast } // namespace chromecast
// Copyright 2019 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 "chromecast/ui/aura_components_impl.h"
#include <utility>
#include "chromecast/ui/media_overlay_impl.h"
namespace chromecast {
AuraComponentsImpl::AuraComponentsImpl(CastWindowManager* cast_window_manager)
: layout_provider_(std::make_unique<views::LayoutProvider>()) {
#if defined(ENABLE_MEDIA_OVERLAY)
media_overlay_ = std::make_unique<MediaOverlayImpl>(cast_window_manager);
#endif
}
AuraComponentsImpl::~AuraComponentsImpl(){};
// static
std::unique_ptr<AuraComponents> AuraComponents::Create(
CastWindowManager* cast_window_manager) {
return std::make_unique<AuraComponentsImpl>(cast_window_manager);
}
} // namespace chromecast
// Copyright 2020 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 CHROMECAST_UI_AURA_COMPONENTS_IMPL_H_
#define CHROMECAST_UI_AURA_COMPONENTS_IMPL_H_
#include <memory>
#include "chromecast/ui/aura_components.h"
#include "ui/views/layout/layout_provider.h"
namespace chromecast {
class CastWindowManager;
// Collection of Cast platform objects which only have valid implementations on
// Aura platforms. All getters to this class will return nullptr on non-Aura
// platforms.
//
// This class helps avoid usage of "#if defined(USE_AURA)" macros by using pure
// virtual interfaces to wrap Aura-specific code. Clients to these interfaces
// can therefore be written in a platform-agnostic way.
class AuraComponentsImpl : public AuraComponents {
public:
explicit AuraComponentsImpl(CastWindowManager* cast_window_manager);
~AuraComponentsImpl() override;
private:
std::unique_ptr<views::LayoutProvider> layout_provider_;
};
} // namespace chromecast
#endif // CHROMECAST_UI_AURA_COMPONENTS_IMPL_H_
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