Commit 95eec716 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Make LogoView::Create() return std::unique_ptr<>

Bug: 648382
Change-Id: I6a1d9075ee889b3d31b169b3f4c12bb4192ded38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001223
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Auto-Submit: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731700}
parent d3759214
......@@ -288,12 +288,11 @@ void AssistantDialogPlate::InitLayout() {
views::BoxLayout::CrossAxisAlignment::kCenter);
// Molecule icon.
molecule_icon_ = LogoView::Create();
molecule_icon_ = AddChildView(LogoView::Create());
molecule_icon_->SetID(AssistantViewID::kModuleIcon);
molecule_icon_->SetPreferredSize(gfx::Size(kIconSizeDip, kIconSizeDip));
molecule_icon_->SetState(LogoView::State::kMoleculeWavy,
/*animate=*/false);
AddChildView(molecule_icon_);
// Input modality layout container.
input_modality_layout_container_ = new views::View();
......
......@@ -76,11 +76,11 @@ void AssistantMiniView::InitLayout() {
views::BoxLayout::CrossAxisAlignment::kCenter);
// Molecule icon.
LogoView* molecule_icon = LogoView::Create();
std::unique_ptr<LogoView> molecule_icon = LogoView::Create();
molecule_icon->SetPreferredSize(gfx::Size(kIconSizeDip, kIconSizeDip));
molecule_icon->SetState(LogoView::State::kMoleculeWavy,
/*animate=*/false);
AddChildView(molecule_icon);
AddChildView(std::move(molecule_icon));
// Label.
label_->SetAutoColorReadabilityEnabled(false);
......
......@@ -72,9 +72,8 @@ void MicView::InitLayout() {
views::BoxLayout::MainAxisAlignment::kCenter);
// Logo view.
logo_view_ = LogoView::Create();
logo_view_ = logo_view_container->AddChildView(LogoView::Create());
logo_view_->SetPreferredSize(gfx::Size(kIconSizeDip, kIconSizeDip));
logo_view_container->AddChildView(logo_view_);
// Initialize state.
UpdateState(/*animate=*/false);
......
......@@ -18,11 +18,11 @@ LogoView::LogoView() = default;
LogoView::~LogoView() = default;
// static
LogoView* LogoView::Create() {
std::unique_ptr<LogoView> LogoView::Create() {
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
return new LogoViewImpl();
return std::make_unique<LogoViewImpl>();
#else
return new LogoView();
return std::make_unique<LogoView>();
#endif
}
......
......@@ -5,6 +5,8 @@
#ifndef ASH_ASSISTANT_UI_LOGO_VIEW_LOGO_VIEW_H_
#define ASH_ASSISTANT_UI_LOGO_VIEW_LOGO_VIEW_H_
#include <memory>
#include "base/component_export.h"
#include "base/macros.h"
#include "ui/views/view.h"
......@@ -32,7 +34,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) LogoView : public views::View {
virtual void SetSpeechLevel(float speech_level) {}
// Creates LogoView based on the build flag ENABLE_CROS_LIBASSISTANT.
static LogoView* Create();
static std::unique_ptr<LogoView> Create();
private:
DISALLOW_COPY_AND_ASSIGN(LogoView);
......
......@@ -80,7 +80,7 @@ void AssistantHeaderView::InitLayout() {
views::BoxLayout::CrossAxisAlignment::kCenter);
// Molecule icon.
molecule_icon_ = LogoView::Create();
molecule_icon_ = AddChildView(LogoView::Create());
molecule_icon_->SetPreferredSize(gfx::Size(kIconSizeDip, kIconSizeDip));
molecule_icon_->SetState(LogoView::State::kMoleculeWavy,
/*animate=*/false);
......@@ -88,8 +88,6 @@ void AssistantHeaderView::InitLayout() {
// The molecule icon will be animated on its own layer.
molecule_icon_->SetPaintToLayer();
molecule_icon_->layer()->SetFillsBoundsOpaquely(false);
AddChildView(molecule_icon_);
}
void AssistantHeaderView::OnResponseChanged(
......
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