Commit e14e1aed authored by Findit's avatar Findit

Revert "Mash - Support for browser themes in window frame."

This reverts commit 5d480c70.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 556549 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzVkNDgwYzcwNDk5NGVhODJjNGYzY2ExZmQ5NGIxNzYxNjY4YzY4NDkM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.chromiumos/linux-chromeos-dbg/5560

Sample Failed Step: browser_tests

Original change's description:
> Mash - Support for browser themes in window frame.
> 
> 1. Move BrowserFrameHeaderAsh to //ash/frame and rename to
>    CustomFrameHeader.
> 2. Use CustomFrameHeader for browser windows (in HeaderView).
>    Continue to use DefaultFrameHeader for other windows.
>    Possible TODO: share more code between the two FrameHeader classes.
> 3. Transport frame images over mojo so Mash can apply them
>    via CustomFrameHeader.
> 
> For now, only the active frame image is propagated (as a POC).
> The inactive image, overlay images, and frame colors are TODO.
> Ideally, there should be no behavioral changes in classic Ash.
> 
> BUG=704942,836992
> 
> Change-Id: I15b2d357bd3c8b60b6656ebce910d476ce107b44
> Reviewed-on: https://chromium-review.googlesource.com/1043221
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Commit-Queue: Evan Stade <estade@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#556549}

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
BUG=704942,836992

Change-Id: Ibe6fc13c61d33eac241fed00edb194cc248429de
Reviewed-on: https://chromium-review.googlesource.com/1049145
Cr-Commit-Position: refs/heads/master@{#556631}
parent 0b887fb9
...@@ -227,8 +227,6 @@ component("ash") { ...@@ -227,8 +227,6 @@ component("ash") {
"frame/caption_buttons/frame_size_button.cc", "frame/caption_buttons/frame_size_button.cc",
"frame/caption_buttons/frame_size_button.h", "frame/caption_buttons/frame_size_button.h",
"frame/caption_buttons/frame_size_button_delegate.h", "frame/caption_buttons/frame_size_button_delegate.h",
"frame/custom_frame_header.cc",
"frame/custom_frame_header.h",
"frame/custom_frame_view_ash.cc", "frame/custom_frame_view_ash.cc",
"frame/custom_frame_view_ash.h", "frame/custom_frame_view_ash.h",
"frame/default_frame_header.cc", "frame/default_frame_header.cc",
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "ash/frame/caption_buttons/frame_caption_button.h" #include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h" #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/default_frame_header.h"
#include "ash/frame/frame_border_hit_test.h" #include "ash/frame/frame_border_hit_test.h"
#include "ash/frame/header_view.h" #include "ash/frame/header_view.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller.h"
...@@ -179,6 +178,48 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate, ...@@ -179,6 +178,48 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
// static // static
bool CustomFrameViewAsh::use_empty_minimum_size_for_test_ = false; bool CustomFrameViewAsh::use_empty_minimum_size_for_test_ = false;
///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::AvatarObserver
// AvatarObserver watches the frame window's avatar icon property and updates
// HeaderView with it.
class CustomFrameViewAsh::AvatarObserver : public aura::WindowObserver {
public:
AvatarObserver(views::Widget* frame, HeaderView* header_view)
: frame_window_(frame->GetNativeWindow()), header_view_(header_view) {
frame_window_->AddObserver(this);
}
~AvatarObserver() override {
if (frame_window_)
frame_window_->RemoveObserver(this);
}
// aura::WindowObserver:
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) override {
DCHECK_EQ(frame_window_, window);
if (key != aura::client::kAvatarIconKey)
return;
gfx::ImageSkia* const avatar_icon =
frame_window_->GetProperty(aura::client::kAvatarIconKey);
header_view_->SetAvatarIcon(avatar_icon ? *avatar_icon : gfx::ImageSkia());
}
void OnWindowDestroyed(aura::Window* window) override {
DCHECK_EQ(frame_window_, window);
frame_window_ = nullptr;
}
private:
aura::Window* frame_window_;
HeaderView* const header_view_;
DISALLOW_COPY_AND_ASSIGN(AvatarObserver);
};
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::OverlayView // CustomFrameViewAsh::OverlayView
...@@ -276,18 +317,19 @@ CustomFrameViewAsh::CustomFrameViewAsh( ...@@ -276,18 +317,19 @@ CustomFrameViewAsh::CustomFrameViewAsh(
header_view_(new HeaderView(frame, window_style, std::move(model))), header_view_(new HeaderView(frame, window_style, std::move(model))),
overlay_view_(new OverlayView(header_view_)), overlay_view_(new OverlayView(header_view_)),
immersive_delegate_(immersive_delegate ? immersive_delegate immersive_delegate_(immersive_delegate ? immersive_delegate
: header_view_) { : header_view_),
avatar_observer_(std::make_unique<AvatarObserver>(frame_, header_view_)) {
aura::Window* frame_window = frame->GetNativeWindow(); aura::Window* frame_window = frame->GetNativeWindow();
wm::InstallResizeHandleWindowTargeterForWindow(frame_window, nullptr); wm::InstallResizeHandleWindowTargeterForWindow(frame_window, nullptr);
// |header_view_| is set as the non client view's overlay view so that it can // |header_view_| is set as the non client view's overlay view so that it can
// overlay the web contents in immersive fullscreen. // overlay the web contents in immersive fullscreen.
frame->non_client_view()->SetOverlayView(overlay_view_); frame->non_client_view()->SetOverlayView(overlay_view_);
frame_window->SetProperty(aura::client::kTopViewColor, frame_window->SetProperty(aura::client::kTopViewColor,
DefaultFrameHeader::GetDefaultFrameColor()); header_view_->GetInactiveFrameColor());
frame_window->SetProperty(ash::kFrameActiveColorKey, frame_window->SetProperty(ash::kFrameActiveColorKey,
DefaultFrameHeader::GetDefaultFrameColor()); header_view_->GetActiveFrameColor());
frame_window->SetProperty(ash::kFrameInactiveColorKey, frame_window->SetProperty(ash::kFrameInactiveColorKey,
DefaultFrameHeader::GetDefaultFrameColor()); header_view_->GetInactiveFrameColor());
frame_window->AddObserver(this); frame_window->AddObserver(this);
// A delegate for a more complex way of fullscreening the window may already // A delegate for a more complex way of fullscreening the window may already
...@@ -320,6 +362,7 @@ void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView( ...@@ -320,6 +362,7 @@ void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView(
void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color, void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) { SkColor inactive_frame_color) {
header_view_->SetFrameColors(active_frame_color, inactive_frame_color);
aura::Window* frame_window = frame_->GetNativeWindow(); aura::Window* frame_window = frame_->GetNativeWindow();
frame_window->SetProperty(aura::client::kTopViewColor, inactive_frame_color); frame_window->SetProperty(aura::client::kTopViewColor, inactive_frame_color);
frame_window->SetProperty(ash::kFrameActiveColorKey, active_frame_color); frame_window->SetProperty(ash::kFrameActiveColorKey, active_frame_color);
...@@ -385,6 +428,7 @@ void CustomFrameViewAsh::ResetWindowControls() { ...@@ -385,6 +428,7 @@ void CustomFrameViewAsh::ResetWindowControls() {
void CustomFrameViewAsh::UpdateWindowIcon() {} void CustomFrameViewAsh::UpdateWindowIcon() {}
void CustomFrameViewAsh::UpdateWindowTitle() { void CustomFrameViewAsh::UpdateWindowTitle() {
header_view_->set_title(GetFrameTitle());
header_view_->SchedulePaintForTitle(); header_view_->SchedulePaintForTitle();
} }
...@@ -483,6 +527,19 @@ void CustomFrameViewAsh::OnWindowPropertyChanged(aura::Window* window, ...@@ -483,6 +527,19 @@ void CustomFrameViewAsh::OnWindowPropertyChanged(aura::Window* window,
if (key == aura::client::kShowStateKey) { if (key == aura::client::kShowStateKey) {
header_view_->OnShowStateChanged( header_view_->OnShowStateChanged(
window->GetProperty(aura::client::kShowStateKey)); window->GetProperty(aura::client::kShowStateKey));
return;
}
if (key == ash::kFrameActiveColorKey) {
header_view_->SetFrameColors(window->GetProperty(ash::kFrameActiveColorKey),
header_view_->GetInactiveFrameColor());
return;
}
if (key == ash::kFrameInactiveColorKey) {
header_view_->SetFrameColors(
header_view_->GetActiveFrameColor(),
window->GetProperty(ash::kFrameInactiveColorKey));
} }
} }
...@@ -491,11 +548,11 @@ const views::View* CustomFrameViewAsh::GetAvatarIconViewForTest() const { ...@@ -491,11 +548,11 @@ const views::View* CustomFrameViewAsh::GetAvatarIconViewForTest() const {
} }
SkColor CustomFrameViewAsh::GetActiveFrameColorForTest() const { SkColor CustomFrameViewAsh::GetActiveFrameColorForTest() const {
return frame_->GetNativeWindow()->GetProperty(ash::kFrameActiveColorKey); return header_view_->GetActiveFrameColor();
} }
SkColor CustomFrameViewAsh::GetInactiveFrameColorForTest() const { SkColor CustomFrameViewAsh::GetInactiveFrameColorForTest() const {
return frame_->GetNativeWindow()->GetProperty(ash::kFrameInactiveColorKey); return header_view_->GetInactiveFrameColor();
} }
void CustomFrameViewAsh::UpdateHeaderView() { void CustomFrameViewAsh::UpdateHeaderView() {
......
...@@ -144,6 +144,7 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView, ...@@ -144,6 +144,7 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView,
void UpdateHeaderView(); void UpdateHeaderView();
private: private:
class AvatarObserver;
class OverlayView; class OverlayView;
friend class CustomFrameViewAshSizeLock; friend class CustomFrameViewAshSizeLock;
friend class CustomFrameTestWidgetDelegate; friend class CustomFrameTestWidgetDelegate;
...@@ -170,6 +171,9 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView, ...@@ -170,6 +171,9 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView,
ImmersiveFullscreenControllerDelegate* immersive_delegate_; ImmersiveFullscreenControllerDelegate* immersive_delegate_;
// Observes avatar icon change and updates |header_view_|.
std::unique_ptr<AvatarObserver> avatar_observer_;
static bool use_empty_minimum_size_for_test_; static bool use_empty_minimum_size_for_test_;
// Track whether the device is in overview mode. Set this to true when // Track whether the device is in overview mode. Set this to true when
......
...@@ -38,6 +38,8 @@ namespace { ...@@ -38,6 +38,8 @@ namespace {
// Color for the window title text. // Color for the window title text.
const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40);
const SkColor kLightTitleTextColor = SK_ColorWHITE; const SkColor kLightTitleTextColor = SK_ColorWHITE;
// The default color of the frame.
const SkColor kDefaultFrameColor = SkColorSetRGB(0xFD, 0xFE, 0xFF);
// Duration of crossfade animation for activating and deactivating frame. // Duration of crossfade animation for activating and deactivating frame.
const int kActivationCrossfadeDurationMs = 200; const int kActivationCrossfadeDurationMs = 200;
...@@ -71,13 +73,15 @@ namespace ash { ...@@ -71,13 +73,15 @@ namespace ash {
DefaultFrameHeader::DefaultFrameHeader( DefaultFrameHeader::DefaultFrameHeader(
views::Widget* frame, views::Widget* frame,
views::View* header_view, views::View* header_view,
FrameCaptionButtonContainerView* caption_button_container) FrameCaptionButtonContainerView* caption_button_container,
: frame_(frame), mojom::WindowStyle window_style)
: window_style_(window_style),
frame_(frame),
view_(header_view), view_(header_view),
back_button_(nullptr), back_button_(nullptr),
left_header_view_(nullptr), left_header_view_(nullptr),
active_frame_color_(GetDefaultFrameColor()), active_frame_color_(kDefaultFrameColor),
inactive_frame_color_(GetDefaultFrameColor()), inactive_frame_color_(kDefaultFrameColor),
caption_button_container_(caption_button_container), caption_button_container_(caption_button_container),
painted_height_(0), painted_height_(0),
mode_(MODE_INACTIVE), mode_(MODE_INACTIVE),
...@@ -136,11 +140,24 @@ void DefaultFrameHeader::PaintHeader(gfx::Canvas* canvas, Mode mode) { ...@@ -136,11 +140,24 @@ void DefaultFrameHeader::PaintHeader(gfx::Canvas* canvas, Mode mode) {
mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) {
PaintHighlightForInactiveRestoredWindow(canvas); PaintHighlightForInactiveRestoredWindow(canvas);
} }
if (frame_->widget_delegate()->ShouldShowWindowTitle() && !GetTitle().empty()) if (frame_->widget_delegate()->ShouldShowWindowTitle() && !title_.empty())
PaintTitleBar(canvas); PaintTitleBar(canvas);
} }
void DefaultFrameHeader::LayoutHeader() { void DefaultFrameHeader::LayoutHeader() {
// TODO(sky): this needs to reset images as well.
if (window_style_ == mojom::WindowStyle::BROWSER) {
const bool is_in_tablet_mode = Shell::Get()
->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled();
const bool use_maximized_size =
frame_->IsMaximized() || frame_->IsFullscreen() || is_in_tablet_mode;
const gfx::Size button_size(GetAshLayoutSize(
use_maximized_size ? AshLayoutSize::kBrowserCaptionMaximized
: AshLayoutSize::kBrowserCaptionRestored));
caption_button_container_->SetButtonSize(button_size);
}
caption_button_container_->SetBackgroundColor(GetCurrentFrameColor()); caption_button_container_->SetBackgroundColor(GetCurrentFrameColor());
caption_button_container_->SetColorMode(button_color_mode_); caption_button_container_->SetColorMode(button_color_mode_);
UpdateSizeButtonImages(); UpdateSizeButtonImages();
...@@ -205,18 +222,6 @@ void DefaultFrameHeader::OnShowStateChanged(ui::WindowShowState show_state) { ...@@ -205,18 +222,6 @@ void DefaultFrameHeader::OnShowStateChanged(ui::WindowShowState show_state) {
LayoutHeader(); LayoutHeader();
} }
void DefaultFrameHeader::SetLeftHeaderView(views::View* left_header_view) {
left_header_view_ = left_header_view;
}
void DefaultFrameHeader::SetBackButton(FrameCaptionButton* back_button) {
back_button_ = back_button;
}
FrameCaptionButton* DefaultFrameHeader::GetBackButton() const {
return back_button_;
}
void DefaultFrameHeader::SetFrameColors(SkColor active_frame_color, void DefaultFrameHeader::SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) { SkColor inactive_frame_color) {
button_color_mode_ = FrameCaptionButton::ColorMode::kDefault; button_color_mode_ = FrameCaptionButton::ColorMode::kDefault;
...@@ -228,6 +233,10 @@ void DefaultFrameHeader::SetThemeColor(SkColor theme_color) { ...@@ -228,6 +233,10 @@ void DefaultFrameHeader::SetThemeColor(SkColor theme_color) {
SetFrameColorsImpl(theme_color, theme_color); SetFrameColorsImpl(theme_color, theme_color);
} }
SkColor DefaultFrameHeader::GetCurrentFrameColor() const {
return mode_ == MODE_ACTIVE ? active_frame_color_ : inactive_frame_color_;
}
void DefaultFrameHeader::SetFrameColorsImpl(SkColor active_frame_color, void DefaultFrameHeader::SetFrameColorsImpl(SkColor active_frame_color,
SkColor inactive_frame_color) { SkColor inactive_frame_color) {
bool updated = false; bool updated = false;
...@@ -246,16 +255,19 @@ void DefaultFrameHeader::SetFrameColorsImpl(SkColor active_frame_color, ...@@ -246,16 +255,19 @@ void DefaultFrameHeader::SetFrameColorsImpl(SkColor active_frame_color,
} }
} }
SkColor DefaultFrameHeader::GetActiveFrameColor() const {
return active_frame_color_;
}
SkColor DefaultFrameHeader::GetInactiveFrameColor() const {
return inactive_frame_color_;
}
SkColor DefaultFrameHeader::GetTitleColor() const { SkColor DefaultFrameHeader::GetTitleColor() const {
return color_utils::IsDark(GetCurrentFrameColor()) ? kLightTitleTextColor return color_utils::IsDark(GetCurrentFrameColor()) ? kLightTitleTextColor
: kTitleTextColor; : kTitleTextColor;
} }
// static
SkColor DefaultFrameHeader::GetDefaultFrameColor() {
return SkColorSetRGB(0xFD, 0xFE, 0xFF);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// gfx::AnimationDelegate overrides: // gfx::AnimationDelegate overrides:
...@@ -298,7 +310,7 @@ void DefaultFrameHeader::PaintTitleBar(gfx::Canvas* canvas) { ...@@ -298,7 +310,7 @@ void DefaultFrameHeader::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by its own views::View. // The window icon is painted by its own views::View.
gfx::Rect title_bounds = GetAvailableTitleBounds(); gfx::Rect title_bounds = GetAvailableTitleBounds();
title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); title_bounds.set_x(view_->GetMirroredXForRect(title_bounds));
canvas->DrawStringRect(GetTitle(), canvas->DrawStringRect(title_,
views::NativeWidgetAura::GetWindowTitleFontList(), views::NativeWidgetAura::GetWindowTitleFontList(),
GetTitleColor(), title_bounds); GetTitleColor(), title_bounds);
} }
...@@ -359,17 +371,9 @@ gfx::Rect DefaultFrameHeader::GetAvailableTitleBounds() const { ...@@ -359,17 +371,9 @@ gfx::Rect DefaultFrameHeader::GetAvailableTitleBounds() const {
left_view, caption_button_container_, GetHeaderHeight()); left_view, caption_button_container_, GetHeaderHeight());
} }
base::string16 DefaultFrameHeader::GetTitle() const {
return frame_->widget_delegate()->GetWindowTitle();
}
bool DefaultFrameHeader::UsesCustomFrameColors() const { bool DefaultFrameHeader::UsesCustomFrameColors() const {
return active_frame_color_ != GetDefaultFrameColor() || return active_frame_color_ != kDefaultFrameColor ||
inactive_frame_color_ != GetDefaultFrameColor(); inactive_frame_color_ != kDefaultFrameColor;
}
SkColor DefaultFrameHeader::GetCurrentFrameColor() const {
return mode_ == MODE_ACTIVE ? active_frame_color_ : inactive_frame_color_;
} }
} // namespace ash } // namespace ash
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/frame/caption_buttons/frame_caption_button.h" #include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/frame_header.h" #include "ash/frame/frame_header.h"
#include "ash/public/interfaces/window_style.mojom.h"
#include "base/compiler_specific.h" // override #include "base/compiler_specific.h" // override
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -36,9 +37,11 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader, ...@@ -36,9 +37,11 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader,
public gfx::AnimationDelegate { public gfx::AnimationDelegate {
public: public:
// DefaultFrameHeader does not take ownership of any of the parameters. // DefaultFrameHeader does not take ownership of any of the parameters.
DefaultFrameHeader(views::Widget* frame, DefaultFrameHeader(
views::View* header_view, views::Widget* frame,
FrameCaptionButtonContainerView* caption_button_container); views::View* header_view,
FrameCaptionButtonContainerView* caption_button_container,
mojom::WindowStyle window_style = mojom::WindowStyle::DEFAULT);
~DefaultFrameHeader() override; ~DefaultFrameHeader() override;
// FrameHeader overrides: // FrameHeader overrides:
...@@ -51,23 +54,29 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader, ...@@ -51,23 +54,29 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader,
void SchedulePaintForTitle() override; void SchedulePaintForTitle() override;
void SetPaintAsActive(bool paint_as_active) override; void SetPaintAsActive(bool paint_as_active) override;
void OnShowStateChanged(ui::WindowShowState show_state) override; void OnShowStateChanged(ui::WindowShowState show_state) override;
void SetLeftHeaderView(views::View* left_header_view) override;
void SetBackButton(FrameCaptionButton* back_button) override;
FrameCaptionButton* GetBackButton() const override;
void SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) override;
void set_left_header_view(views::View* left_header_view) {
left_header_view_ = left_header_view;
}
void set_back_button(FrameCaptionButton* back_button) {
back_button_ = back_button;
}
FrameCaptionButton* back_button() { return back_button_; }
void set_title(const base::string16& title) { title_ = title; }
// Sets the active and inactive frame colors. Note the inactive frame color
// will have some transparency added when the frame is drawn.
void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
void SetThemeColor(SkColor theme_color); void SetThemeColor(SkColor theme_color);
SkColor GetActiveFrameColor() const;
SkColor GetInactiveFrameColor() const;
SkColor GetCurrentFrameColor() const;
// Gets the color of the title text. // Gets the color of the title text.
SkColor GetTitleColor() const; SkColor GetTitleColor() const;
// The default frame color for both active and inactive.
static SkColor GetDefaultFrameColor();
SkColor active_frame_color_for_testing() { return active_frame_color_; }
SkColor inactive_frame_color_for_testing() { return inactive_frame_color_; }
protected: protected:
// Updates the frame colors and ensures buttons are up to date. // Updates the frame colors and ensures buttons are up to date.
void SetFrameColorsImpl(SkColor active_frame_color, void SetFrameColorsImpl(SkColor active_frame_color,
...@@ -104,13 +113,10 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader, ...@@ -104,13 +113,10 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader,
// same width as |view_|. // same width as |view_|.
gfx::Rect GetLocalBounds() const; gfx::Rect GetLocalBounds() const;
base::string16 GetTitle() const;
// Returns whether the frame uses custom frame coloring. // Returns whether the frame uses custom frame coloring.
bool UsesCustomFrameColors() const; bool UsesCustomFrameColors() const;
SkColor GetCurrentFrameColor() const; const mojom::WindowStyle window_style_;
views::Widget* frame_; views::Widget* frame_;
views::View* view_; views::View* view_;
FrameCaptionButton* back_button_; // May be nullptr. FrameCaptionButton* back_button_; // May be nullptr.
...@@ -120,6 +126,7 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader, ...@@ -120,6 +126,7 @@ class ASH_EXPORT DefaultFrameHeader : public FrameHeader,
SkColor active_frame_color_; SkColor active_frame_color_;
SkColor inactive_frame_color_; SkColor inactive_frame_color_;
FrameCaptionButtonContainerView* caption_button_container_; FrameCaptionButtonContainerView* caption_button_container_;
base::string16 title_;
// The height of the header to paint. // The height of the header to paint.
int painted_height_; int painted_height_;
......
...@@ -33,7 +33,7 @@ TEST_F(DefaultFrameHeaderTest, TitleIconAlignment) { ...@@ -33,7 +33,7 @@ TEST_F(DefaultFrameHeaderTest, TitleIconAlignment) {
DefaultFrameHeader frame_header(w.get(), w->non_client_view()->frame_view(), DefaultFrameHeader frame_header(w.get(), w->non_client_view()->frame_view(),
&container); &container);
frame_header.SetLeftHeaderView(&window_icon); frame_header.set_left_header_view(&window_icon);
frame_header.LayoutHeader(); frame_header.LayoutHeader();
gfx::Rect title_bounds = frame_header.GetAvailableTitleBounds(); gfx::Rect title_bounds = frame_header.GetAvailableTitleBounds();
EXPECT_EQ(window_icon.bounds().CenterPoint().y(), EXPECT_EQ(window_icon.bounds().CenterPoint().y(),
...@@ -48,7 +48,7 @@ TEST_F(DefaultFrameHeaderTest, BackButtonAlignment) { ...@@ -48,7 +48,7 @@ TEST_F(DefaultFrameHeaderTest, BackButtonAlignment) {
DefaultFrameHeader frame_header(w.get(), w->non_client_view()->frame_view(), DefaultFrameHeader frame_header(w.get(), w->non_client_view()->frame_view(),
&container); &container);
frame_header.SetBackButton(&back); frame_header.set_back_button(&back);
frame_header.LayoutHeader(); frame_header.LayoutHeader();
gfx::Rect title_bounds = frame_header.GetAvailableTitleBounds(); gfx::Rect title_bounds = frame_header.GetAvailableTitleBounds();
// The back button should be positioned at the left edge, and // The back button should be positioned at the left edge, and
......
...@@ -6,21 +6,14 @@ ...@@ -6,21 +6,14 @@
#define ASH_FRAME_FRAME_HEADER_H_ #define ASH_FRAME_FRAME_HEADER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
namespace gfx { namespace gfx {
class Canvas; class Canvas;
} }
namespace views {
class View;
}
namespace ash { namespace ash {
class FrameCaptionButton;
// Helper class for managing the window header. // Helper class for managing the window header.
class ASH_EXPORT FrameHeader { class ASH_EXPORT FrameHeader {
public: public:
...@@ -55,15 +48,6 @@ class ASH_EXPORT FrameHeader { ...@@ -55,15 +48,6 @@ class ASH_EXPORT FrameHeader {
// Called when frame show state is changed. // Called when frame show state is changed.
virtual void OnShowStateChanged(ui::WindowShowState show_state) = 0; virtual void OnShowStateChanged(ui::WindowShowState show_state) = 0;
virtual void SetLeftHeaderView(views::View* view) = 0;
virtual void SetBackButton(FrameCaptionButton* view) = 0;
virtual FrameCaptionButton* GetBackButton() const = 0;
// Sets the active and inactive frame colors. Note the inactive frame color
// will have some transparency added when the frame is drawn.
virtual void SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) = 0;
}; };
} // namespace ash } // namespace ash
......
...@@ -11,59 +11,14 @@ ...@@ -11,59 +11,14 @@
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h" #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/custom_frame_view_ash.h" #include "ash/frame/custom_frame_view_ash.h"
#include "ash/frame/default_frame_header.h" #include "ash/frame/default_frame_header.h"
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace ash { namespace ash {
namespace {
// An appearance provider that relies on window properties which have been set
// by the client. Only used in Mash.
class WindowPropertyAppearanceProvider
: public CustomFrameHeader::AppearanceProvider {
public:
explicit WindowPropertyAppearanceProvider(aura::Window* window)
: window_(window) {}
~WindowPropertyAppearanceProvider() override = default;
SkColor GetFrameHeaderColor(bool active) override {
return window_->GetProperty(active ? ash::kFrameActiveColorKey
: ash::kFrameInactiveColorKey);
}
gfx::ImageSkia GetFrameHeaderImage(bool active) override {
// TODO(estade): handle !active.
gfx::ImageSkia* image = window_->GetProperty(kFrameImageActiveKey);
return image ? *image : gfx::ImageSkia();
}
gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) override {
// TODO(estade): implement.
return gfx::ImageSkia();
}
bool IsTabletMode() override {
return Shell::Get()
->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled();
}
private:
aura::Window* window_;
DISALLOW_COPY_AND_ASSIGN(WindowPropertyAppearanceProvider);
};
} // namespace
HeaderView::HeaderView(views::Widget* target_widget, HeaderView::HeaderView(views::Widget* target_widget,
mojom::WindowStyle window_style, mojom::WindowStyle window_style,
std::unique_ptr<CaptionButtonModel> model) std::unique_ptr<CaptionButtonModel> model)
...@@ -77,22 +32,9 @@ HeaderView::HeaderView(views::Widget* target_widget, ...@@ -77,22 +32,9 @@ HeaderView::HeaderView(views::Widget* target_widget,
caption_button_container_->UpdateCaptionButtonState(false /*=animate*/); caption_button_container_->UpdateCaptionButtonState(false /*=animate*/);
AddChildView(caption_button_container_); AddChildView(caption_button_container_);
if (window_style == mojom::WindowStyle::DEFAULT) { frame_header_ = std::make_unique<DefaultFrameHeader>(
frame_header_ = std::make_unique<DefaultFrameHeader>( target_widget_, this, caption_button_container_, window_style);
target_widget_, this, caption_button_container_);
} else {
DCHECK_EQ(mojom::WindowStyle::BROWSER, window_style);
DCHECK_EQ(Config::MASH, Shell::GetAshConfig());
appearance_provider_ = std::make_unique<WindowPropertyAppearanceProvider>(
target_widget_->GetNativeWindow());
auto frame_header = std::make_unique<CustomFrameHeader>();
// TODO(estade): pass correct value for |incognito|.
frame_header->Init(this, appearance_provider_.get(), false,
caption_button_container_);
frame_header_ = std::move(frame_header);
}
window_observer_.Add(target_widget_->GetNativeWindow());
Shell::Get()->tablet_mode_controller()->AddObserver(this); Shell::Get()->tablet_mode_controller()->AddObserver(this);
} }
...@@ -143,7 +85,7 @@ void HeaderView::SetAvatarIcon(const gfx::ImageSkia& avatar) { ...@@ -143,7 +85,7 @@ void HeaderView::SetAvatarIcon(const gfx::ImageSkia& avatar) {
} }
avatar_icon_->SetImage(avatar); avatar_icon_->SetImage(avatar);
} }
frame_header_->SetLeftHeaderView(avatar_icon_); frame_header_->set_left_header_view(avatar_icon_);
Layout(); Layout();
} }
...@@ -153,23 +95,36 @@ void HeaderView::UpdateCaptionButtons() { ...@@ -153,23 +95,36 @@ void HeaderView::UpdateCaptionButtons() {
bool has_back_button = bool has_back_button =
caption_button_container_->model()->IsVisible(CAPTION_BUTTON_ICON_BACK); caption_button_container_->model()->IsVisible(CAPTION_BUTTON_ICON_BACK);
FrameCaptionButton* back_button = frame_header_->GetBackButton(); FrameCaptionButton* back_button = frame_header_->back_button();
if (has_back_button) { if (has_back_button) {
if (!back_button) { if (!back_button) {
back_button = new FrameBackButton(); back_button = new FrameBackButton();
AddChildView(back_button); AddChildView(back_button);
frame_header_->SetBackButton(back_button); frame_header_->set_back_button(back_button);
} }
back_button->SetEnabled(caption_button_container_->model()->IsEnabled( back_button->SetEnabled(caption_button_container_->model()->IsEnabled(
CAPTION_BUTTON_ICON_BACK)); CAPTION_BUTTON_ICON_BACK));
} else { } else {
delete back_button; delete back_button;
frame_header_->SetBackButton(nullptr); frame_header_->set_back_button(nullptr);
} }
Layout(); Layout();
} }
void HeaderView::SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) {
frame_header_->SetFrameColors(active_frame_color, inactive_frame_color);
}
SkColor HeaderView::GetActiveFrameColor() const {
return frame_header_->GetActiveFrameColor();
}
SkColor HeaderView::GetInactiveFrameColor() const {
return frame_header_->GetInactiveFrameColor();
}
void HeaderView::OnShowStateChanged(ui::WindowShowState show_state) { void HeaderView::OnShowStateChanged(ui::WindowShowState show_state) {
frame_header_->OnShowStateChanged(show_state); frame_header_->OnShowStateChanged(show_state);
} }
...@@ -219,28 +174,6 @@ void HeaderView::OnTabletModeEnded() { ...@@ -219,28 +174,6 @@ void HeaderView::OnTabletModeEnded() {
target_widget_->non_client_view()->Layout(); target_widget_->non_client_view()->Layout();
} }
void HeaderView::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
DCHECK_EQ(target_widget_->GetNativeWindow(), window);
if (key == kFrameImageActiveKey) {
SchedulePaint();
} else if (key == aura::client::kAvatarIconKey) {
gfx::ImageSkia* const avatar_icon =
window->GetProperty(aura::client::kAvatarIconKey);
SetAvatarIcon(avatar_icon ? *avatar_icon : gfx::ImageSkia());
} else if (key == ash::kFrameActiveColorKey ||
key == ash::kFrameInactiveColorKey) {
frame_header_->SetFrameColors(
window->GetProperty(ash::kFrameActiveColorKey),
window->GetProperty(ash::kFrameInactiveColorKey));
}
}
void HeaderView::OnWindowDestroying(aura::Window* window) {
window_observer_.Remove(window);
}
views::View* HeaderView::avatar_icon() const { views::View* HeaderView::avatar_icon() const {
return avatar_icon_; return avatar_icon_;
} }
...@@ -255,7 +188,7 @@ void HeaderView::SetShouldPaintHeader(bool paint) { ...@@ -255,7 +188,7 @@ void HeaderView::SetShouldPaintHeader(bool paint) {
} }
FrameCaptionButton* HeaderView::GetBackButton() { FrameCaptionButton* HeaderView::GetBackButton() {
return frame_header_->GetBackButton(); return frame_header_->back_button();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -8,15 +8,12 @@ ...@@ -8,15 +8,12 @@
#include <memory> #include <memory>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/frame/custom_frame_header.h" #include "ash/frame/default_frame_header.h"
#include "ash/frame/frame_header.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h"
#include "ash/public/interfaces/window_style.mojom.h" #include "ash/public/interfaces/window_style.mojom.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h" #include "ash/wm/tablet_mode/tablet_mode_observer.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window_observer.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -41,8 +38,7 @@ enum class FrameBackButtonState; ...@@ -41,8 +38,7 @@ enum class FrameBackButtonState;
// and on screen in immersive fullscreen. // and on screen in immersive fullscreen.
class ASH_EXPORT HeaderView : public views::View, class ASH_EXPORT HeaderView : public views::View,
public ImmersiveFullscreenControllerDelegate, public ImmersiveFullscreenControllerDelegate,
public TabletModeObserver, public TabletModeObserver {
public aura::WindowObserver {
public: public:
// |target_widget| is the widget that the caption buttons act on. // |target_widget| is the widget that the caption buttons act on.
// |target_widget| is not necessarily the same as the widget the header is // |target_widget| is not necessarily the same as the widget the header is
...@@ -79,6 +75,10 @@ class ASH_EXPORT HeaderView : public views::View, ...@@ -79,6 +75,10 @@ class ASH_EXPORT HeaderView : public views::View,
void UpdateCaptionButtons(); void UpdateCaptionButtons();
void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
SkColor GetActiveFrameColor() const;
SkColor GetInactiveFrameColor() const;
// Called when the target widget show state changed. // Called when the target widget show state changed.
void OnShowStateChanged(ui::WindowShowState show_state); void OnShowStateChanged(ui::WindowShowState show_state);
...@@ -91,12 +91,6 @@ class ASH_EXPORT HeaderView : public views::View, ...@@ -91,12 +91,6 @@ class ASH_EXPORT HeaderView : public views::View,
void OnTabletModeStarted() override; void OnTabletModeStarted() override;
void OnTabletModeEnded() override; void OnTabletModeEnded() override;
// aura::WindowObserver:
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) override;
void OnWindowDestroying(aura::Window* window) override;
FrameCaptionButtonContainerView* caption_button_container() { FrameCaptionButtonContainerView* caption_button_container() {
return caption_button_container_; return caption_button_container_;
} }
...@@ -106,6 +100,10 @@ class ASH_EXPORT HeaderView : public views::View, ...@@ -106,6 +100,10 @@ class ASH_EXPORT HeaderView : public views::View,
bool in_immersive_mode() const { return in_immersive_mode_; } bool in_immersive_mode() const { return in_immersive_mode_; }
bool is_revealed() const { return fullscreen_visible_fraction_ > 0.0; } bool is_revealed() const { return fullscreen_visible_fraction_ > 0.0; }
void set_title(const base::string16& title) {
frame_header_->set_title(title);
}
void SetShouldPaintHeader(bool paint); void SetShouldPaintHeader(bool paint);
FrameCaptionButton* GetBackButton(); FrameCaptionButton* GetBackButton();
...@@ -122,14 +120,8 @@ class ASH_EXPORT HeaderView : public views::View, ...@@ -122,14 +120,8 @@ class ASH_EXPORT HeaderView : public views::View,
// The widget that the caption buttons act on. // The widget that the caption buttons act on.
views::Widget* target_widget_; views::Widget* target_widget_;
std::unique_ptr<CustomFrameHeader::AppearanceProvider> appearance_provider_; // Helper for painting the header.
std::unique_ptr<DefaultFrameHeader> frame_header_;
// Helper for painting the header. The exact type of FrameHeader will depend
// on the type of window: In Mash, Chrome Browser windows use
// CustomFrameHeader which is aware of theming. In classic Ash, Chrome Browser
// windows won't use HeaderView at all. In either configuration, non Browser
// windows will use DefaultFrameHeader.
std::unique_ptr<FrameHeader> frame_header_;
views::ImageView* avatar_icon_; views::ImageView* avatar_icon_;
...@@ -150,9 +142,6 @@ class ASH_EXPORT HeaderView : public views::View, ...@@ -150,9 +142,6 @@ class ASH_EXPORT HeaderView : public views::View,
bool in_immersive_mode_ = false; bool in_immersive_mode_ = false;
// Observes property changes to |target_widget_|'s window.
ScopedObserver<aura::Window, aura::WindowObserver> window_observer_{this};
DISALLOW_COPY_AND_ASSIGN(HeaderView); DISALLOW_COPY_AND_ASSIGN(HeaderView);
}; };
......
...@@ -105,8 +105,11 @@ WideFrameView::WideFrameView(views::Widget* target, views::Widget* widget) ...@@ -105,8 +105,11 @@ WideFrameView::WideFrameView(views::Widget* target, views::Widget* widget)
aura::Window* target_window = target->GetNativeWindow(); aura::Window* target_window = target->GetNativeWindow();
target_window->AddObserver(this); target_window->AddObserver(this);
SkColor active = target_window->GetProperty(kFrameActiveColorKey);
SkColor inactive = target_window->GetProperty(kFrameInactiveColorKey);
header_view_ = new HeaderView(target); header_view_ = new HeaderView(target);
AddChildView(header_view_); AddChildView(header_view_);
header_view_->SetFrameColors(active, inactive);
GetTargetHeaderView()->SetShouldPaintHeader(false); GetTargetHeaderView()->SetShouldPaintHeader(false);
} }
......
...@@ -63,11 +63,6 @@ void MusPropertyMirrorAsh::MirrorPropertyFromWidgetWindowToRootWindow( ...@@ -63,11 +63,6 @@ void MusPropertyMirrorAsh::MirrorPropertyFromWidgetWindowToRootWindow(
MirrorOwnedProperty(window, root_window, aura::client::kTitleKey); MirrorOwnedProperty(window, root_window, aura::client::kTitleKey);
} else if (key == aura::client::kWindowIconKey) { } else if (key == aura::client::kWindowIconKey) {
MirrorOwnedProperty(window, root_window, aura::client::kWindowIconKey); MirrorOwnedProperty(window, root_window, aura::client::kWindowIconKey);
} else if (key == kFrameImageActiveKey) {
MirrorOwnedProperty(window, root_window, kFrameImageActiveKey);
} else if (key == kWindowTitleShownKey) {
root_window->SetProperty(kWindowTitleShownKey,
window->GetProperty(kWindowTitleShownKey));
} }
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/public/interfaces/window_pin_type.mojom.h" #include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/public/interfaces/window_state_type.mojom.h" #include "ash/public/interfaces/window_state_type.mojom.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image_skia.h"
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(ASH_PUBLIC_EXPORT, DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(ASH_PUBLIC_EXPORT,
ash::mojom::WindowPinType) ash::mojom::WindowPinType)
...@@ -23,9 +22,6 @@ DEFINE_UI_CLASS_PROPERTY_KEY(BackdropWindowMode, ...@@ -23,9 +22,6 @@ DEFINE_UI_CLASS_PROPERTY_KEY(BackdropWindowMode,
kBackdropWindowMode, kBackdropWindowMode,
BackdropWindowMode::kAuto); BackdropWindowMode::kAuto);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCanConsumeSystemKeysKey, false); DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCanConsumeSystemKeysKey, false);
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::ImageSkia,
kFrameImageActiveKey,
nullptr);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kHideShelfWhenFullscreenKey, true); DEFINE_UI_CLASS_PROPERTY_KEY(bool, kHideShelfWhenFullscreenKey, true);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kPanelAttachedKey, true); DEFINE_UI_CLASS_PROPERTY_KEY(bool, kPanelAttachedKey, true);
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect, DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect,
...@@ -50,6 +46,5 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowPositionManagedTypeKey, false); ...@@ -50,6 +46,5 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowPositionManagedTypeKey, false);
DEFINE_UI_CLASS_PROPERTY_KEY(mojom::WindowStateType, DEFINE_UI_CLASS_PROPERTY_KEY(mojom::WindowStateType,
kWindowStateTypeKey, kWindowStateTypeKey,
mojom::WindowStateType::DEFAULT); mojom::WindowStateType::DEFAULT);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowTitleShownKey, true);
} // namespace ash } // namespace ash
...@@ -18,7 +18,6 @@ using WindowProperty = ui::ClassProperty<T>; ...@@ -18,7 +18,6 @@ using WindowProperty = ui::ClassProperty<T>;
} }
namespace gfx { namespace gfx {
class ImageSkia;
class Rect; class Rect;
} }
...@@ -48,10 +47,6 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<BackdropWindowMode>* const ...@@ -48,10 +47,6 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<BackdropWindowMode>* const
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
kCanConsumeSystemKeysKey; kCanConsumeSystemKeysKey;
// The frame's active image. Only set on themed windows.
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<gfx::ImageSkia*>* const
kFrameImageActiveKey;
// Whether the shelf should be hidden when this window is put into fullscreen. // Whether the shelf should be hidden when this window is put into fullscreen.
// Exposed because some windows want to explicitly opt-out of this. // Exposed because some windows want to explicitly opt-out of this.
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
...@@ -112,11 +107,6 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const ...@@ -112,11 +107,6 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
ASH_PUBLIC_EXPORT extern const aura::WindowProperty< ASH_PUBLIC_EXPORT extern const aura::WindowProperty<
mojom::WindowStateType>* const kWindowStateTypeKey; mojom::WindowStateType>* const kWindowStateTypeKey;
// Determines whether the window title should be drawn. For example, app and
// non-tabbed, trusted source windows (such as Settings) will not show a title.
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
kWindowTitleShownKey;
// Alphabetical sort. // Alphabetical sort.
} // namespace ash } // namespace ash
......
...@@ -9,10 +9,6 @@ module ash.mojom; ...@@ -9,10 +9,6 @@ module ash.mojom;
const string kCanConsumeSystemKeys_Property = const string kCanConsumeSystemKeys_Property =
"ash:can-consume-system-keys"; "ash:can-consume-system-keys";
// A gfx::ImageSkia used to tell Mash the frame image to use for a custom
// Browser theme.
const string kFrameImageActive_Property = "ash:frame-image-active";
// True if the shelf should be hidden when this window is put into fullscreen. // True if the shelf should be hidden when this window is put into fullscreen.
// Exposed because some windows want to explicitly opt-out of this. // Exposed because some windows want to explicitly opt-out of this.
const string kHideShelfWhenFullscreen_Property = const string kHideShelfWhenFullscreen_Property =
......
...@@ -95,8 +95,6 @@ WindowManager::WindowManager(service_manager::Connector* connector, ...@@ -95,8 +95,6 @@ WindowManager::WindowManager(service_manager::Connector* connector,
aura::client::kDrawAttentionKey, aura::client::kDrawAttentionKey,
ui::mojom::WindowManager::kDrawAttention_Property, ui::mojom::WindowManager::kDrawAttention_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback()); aura::PropertyConverter::CreateAcceptAnyValueCallback());
property_converter_->RegisterImageSkiaProperty(
kFrameImageActiveKey, ash::mojom::kFrameImageActive_Property);
property_converter_->RegisterPrimitiveProperty( property_converter_->RegisterPrimitiveProperty(
kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback()); aura::PropertyConverter::CreateAcceptAnyValueCallback());
...@@ -130,10 +128,6 @@ WindowManager::WindowManager(service_manager::Connector* connector, ...@@ -130,10 +128,6 @@ WindowManager::WindowManager(service_manager::Connector* connector,
kRestoreWindowStateTypeOverrideKey, kRestoreWindowStateTypeOverrideKey,
ash::mojom::kRestoreWindowStateTypeOverride_Property, ash::mojom::kRestoreWindowStateTypeOverride_Property,
base::BindRepeating(&ash::IsValidWindowStateType)); base::BindRepeating(&ash::IsValidWindowStateType));
property_converter_->RegisterPrimitiveProperty(
kWindowTitleShownKey,
ui::mojom::WindowManager::kWindowTitleShown_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback());
} }
WindowManager::~WindowManager() { WindowManager::~WindowManager() {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ash/frame/detached_title_area_renderer.h" #include "ash/frame/detached_title_area_renderer.h"
#include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/window_manager.h" #include "ash/window_manager.h"
#include "ash/wm/move_event_handler.h" #include "ash/wm/move_event_handler.h"
#include "ash/wm/panels/panel_frame_view.h" #include "ash/wm/panels/panel_frame_view.h"
...@@ -402,7 +401,9 @@ bool NonClientFrameController::CanMinimize() const { ...@@ -402,7 +401,9 @@ bool NonClientFrameController::CanMinimize() const {
} }
bool NonClientFrameController::ShouldShowWindowTitle() const { bool NonClientFrameController::ShouldShowWindowTitle() const {
return window_ && window_->GetProperty(kWindowTitleShownKey); // Only draw the title if the client hasn't declared any additional client
// areas which might conflict with it.
return window_ && additional_client_areas_.empty();
} }
views::ClientView* NonClientFrameController::CreateClientView( views::ClientView* NonClientFrameController::CreateClientView(
......
...@@ -40,7 +40,7 @@ void PanelFrameView::SetFrameColors(SkColor active_frame_color, ...@@ -40,7 +40,7 @@ void PanelFrameView::SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) { SkColor inactive_frame_color) {
frame_header_->SetFrameColors(active_frame_color, inactive_frame_color); frame_header_->SetFrameColors(active_frame_color, inactive_frame_color);
GetWidgetWindow()->SetProperty(aura::client::kTopViewColor, GetWidgetWindow()->SetProperty(aura::client::kTopViewColor,
inactive_frame_color); frame_header_->GetInactiveFrameColor());
} }
const char* PanelFrameView::GetClassName() const { const char* PanelFrameView::GetClassName() const {
...@@ -54,12 +54,12 @@ void PanelFrameView::InitFrameHeader() { ...@@ -54,12 +54,12 @@ void PanelFrameView::InitFrameHeader() {
frame_header_ = std::make_unique<DefaultFrameHeader>( frame_header_ = std::make_unique<DefaultFrameHeader>(
frame_, this, caption_button_container_); frame_, this, caption_button_container_);
GetWidgetWindow()->SetProperty(aura::client::kTopViewColor, GetWidgetWindow()->SetProperty(aura::client::kTopViewColor,
DefaultFrameHeader::GetDefaultFrameColor()); frame_header_->GetInactiveFrameColor());
if (frame_->widget_delegate()->ShouldShowWindowIcon()) { if (frame_->widget_delegate()->ShouldShowWindowIcon()) {
window_icon_ = new views::ImageView(); window_icon_ = new views::ImageView();
AddChildView(window_icon_); AddChildView(window_icon_);
frame_header_->SetLeftHeaderView(window_icon_); frame_header_->set_left_header_view(window_icon_);
} }
} }
......
...@@ -1876,6 +1876,8 @@ split_static_library("ui") { ...@@ -1876,6 +1876,8 @@ split_static_library("ui") {
"views/extensions/request_file_system_dialog_view.h", "views/extensions/request_file_system_dialog_view.h",
"views/frame/browser_frame_ash.cc", "views/frame/browser_frame_ash.cc",
"views/frame/browser_frame_ash.h", "views/frame/browser_frame_ash.h",
"views/frame/browser_frame_header_ash.cc",
"views/frame/browser_frame_header_ash.h",
"views/frame/browser_non_client_frame_view_ash.cc", "views/frame/browser_non_client_frame_view_ash.cc",
"views/frame/browser_non_client_frame_view_ash.h", "views/frame/browser_non_client_frame_view_ash.h",
"views/frame/immersive_context_mus.cc", "views/frame/immersive_context_mus.cc",
......
...@@ -148,8 +148,6 @@ void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( ...@@ -148,8 +148,6 @@ void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted(
ash::kCanConsumeSystemKeysKey, ash::kCanConsumeSystemKeysKey,
ash::mojom::kCanConsumeSystemKeys_Property, ash::mojom::kCanConsumeSystemKeys_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback()); aura::PropertyConverter::CreateAcceptAnyValueCallback());
converter->RegisterImageSkiaProperty(
ash::kFrameImageActiveKey, ash::mojom::kFrameImageActive_Property);
converter->RegisterPrimitiveProperty( converter->RegisterPrimitiveProperty(
ash::kHideShelfWhenFullscreenKey, ash::kHideShelfWhenFullscreenKey,
ash::mojom::kHideShelfWhenFullscreen_Property, ash::mojom::kHideShelfWhenFullscreen_Property,
...@@ -182,10 +180,6 @@ void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( ...@@ -182,10 +180,6 @@ void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted(
ash::kRestoreWindowStateTypeOverrideKey, ash::kRestoreWindowStateTypeOverrideKey,
ash::mojom::kRestoreWindowStateTypeOverride_Property, ash::mojom::kRestoreWindowStateTypeOverride_Property,
base::BindRepeating(&ash::IsValidWindowStateType)); base::BindRepeating(&ash::IsValidWindowStateType));
converter->RegisterPrimitiveProperty(
ash::kWindowTitleShownKey,
ui::mojom::WindowManager::kWindowTitleShown_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback());
mus_client->SetMusPropertyMirror( mus_client->SetMusPropertyMirror(
std::make_unique<ash::MusPropertyMirrorAsh>()); std::make_unique<ash::MusPropertyMirrorAsh>());
......
...@@ -188,9 +188,6 @@ void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( ...@@ -188,9 +188,6 @@ void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit(
->mus_properties[ui::mojom::WindowManager::kShelfItemType_Property] = ->mus_properties[ui::mojom::WindowManager::kShelfItemType_Property] =
mojo::ConvertTo<std::vector<uint8_t>>( mojo::ConvertTo<std::vector<uint8_t>>(
static_cast<int64_t>(ash::TYPE_APP)); static_cast<int64_t>(ash::TYPE_APP));
init_params
->mus_properties[ui::mojom::WindowManager::kWindowTitleShown_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int64_t>(false));
} }
void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit(
......
specific_include_rules = {
# This class is only used in classic Ash.
"browser_non_client_frame_view_ash\.*": [
"+ash",
],
}
...@@ -2,47 +2,43 @@ ...@@ -2,47 +2,43 @@
// 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.
#ifndef ASH_FRAME_CUSTOM_FRAME_HEADER_H_ #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_HEADER_ASH_H_
#define ASH_FRAME_CUSTOM_FRAME_HEADER_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_HEADER_ASH_H_
#include "ash/ash_export.h"
#include "ash/frame/frame_header.h" #include "ash/frame/frame_header.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/slide_animation.h" #include "ui/gfx/animation/slide_animation.h"
namespace ash {
class FrameCaptionButton;
class FrameCaptionButtonContainerView;
} // namespace ash
namespace gfx { namespace gfx {
class ImageSkia; class ImageSkia;
class Rect; class Rect;
} // namespace gfx } // namespace gfx
namespace views { namespace views {
class View; class View;
class Widget; class Widget;
} // namespace views } // namespace views
namespace ash { // Helper class for managing the browser window header.
class BrowserFrameHeaderAsh : public ash::FrameHeader,
class FrameCaptionButton; public gfx::AnimationDelegate {
class FrameCaptionButtonContainerView;
// Helper class for drawing a custom frame (such as for a themed Chrome Browser
// frame).
class ASH_EXPORT CustomFrameHeader : public FrameHeader,
public gfx::AnimationDelegate {
public: public:
class AppearanceProvider { class AppearanceProvider {
public: public:
virtual ~AppearanceProvider() = default;
virtual SkColor GetFrameHeaderColor(bool active) = 0; virtual SkColor GetFrameHeaderColor(bool active) = 0;
virtual gfx::ImageSkia GetFrameHeaderImage(bool active) = 0; virtual gfx::ImageSkia GetFrameHeaderImage(bool active) = 0;
virtual gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) = 0; virtual gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) = 0;
virtual bool IsTabletMode() = 0; virtual bool IsTabletMode() = 0;
}; };
CustomFrameHeader(); BrowserFrameHeaderAsh();
~CustomFrameHeader() override; ~BrowserFrameHeaderAsh() override;
// BrowserFrameHeaderAsh does not take ownership of any of the parameters. // BrowserFrameHeaderAsh does not take ownership of any of the parameters.
// |view| is the view into which |this| will paint. |back_button| can be // |view| is the view into which |this| will paint. |back_button| can be
...@@ -50,9 +46,11 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader, ...@@ -50,9 +46,11 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader,
void Init(views::View* view, void Init(views::View* view,
AppearanceProvider* appearance_provider, AppearanceProvider* appearance_provider,
bool incognito, bool incognito,
FrameCaptionButtonContainerView* caption_button_container); views::View* window_icon,
ash::FrameCaptionButtonContainerView* caption_button_container,
ash::FrameCaptionButton* back_button);
// FrameHeader overrides: // ash::FrameHeader overrides:
int GetMinimumHeaderWidth() const override; int GetMinimumHeaderWidth() const override;
void PaintHeader(gfx::Canvas* canvas, Mode mode) override; void PaintHeader(gfx::Canvas* canvas, Mode mode) override;
void LayoutHeader() override; void LayoutHeader() override;
...@@ -62,11 +60,6 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader, ...@@ -62,11 +60,6 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader,
void SchedulePaintForTitle() override; void SchedulePaintForTitle() override;
void SetPaintAsActive(bool paint_as_active) override; void SetPaintAsActive(bool paint_as_active) override;
void OnShowStateChanged(ui::WindowShowState show_state) override; void OnShowStateChanged(ui::WindowShowState show_state) override;
void SetLeftHeaderView(views::View* left_header_view) override;
void SetBackButton(FrameCaptionButton* back_button) override;
FrameCaptionButton* GetBackButton() const override;
void SetFrameColors(SkColor active_frame_color,
SkColor inactive_frame_color) override;
private: private:
// gfx::AnimationDelegate override: // gfx::AnimationDelegate override:
...@@ -105,8 +98,8 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader, ...@@ -105,8 +98,8 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader,
bool is_incognito_ = false; bool is_incognito_ = false;
views::View* window_icon_ = nullptr; views::View* window_icon_ = nullptr;
FrameCaptionButton* back_button_ = nullptr; ash::FrameCaptionButton* back_button_ = nullptr;
FrameCaptionButtonContainerView* caption_button_container_ = nullptr; ash::FrameCaptionButtonContainerView* caption_button_container_ = nullptr;
int painted_height_ = 0; int painted_height_ = 0;
// Whether the header is painted for the first time. // Whether the header is painted for the first time.
...@@ -117,9 +110,7 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader, ...@@ -117,9 +110,7 @@ class ASH_EXPORT CustomFrameHeader : public FrameHeader,
gfx::SlideAnimation activation_animation_{this}; gfx::SlideAnimation activation_animation_{this};
DISALLOW_COPY_AND_ASSIGN(CustomFrameHeader); DISALLOW_COPY_AND_ASSIGN(BrowserFrameHeaderAsh);
}; };
} // namespace ash #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_HEADER_ASH_H_
#endif // ASH_FRAME_CUSTOM_FRAME_HEADER_H_
...@@ -52,6 +52,7 @@ views::Widget::InitParams BrowserFrameMus::GetWidgetParams() { ...@@ -52,6 +52,7 @@ views::Widget::InitParams BrowserFrameMus::GetWidgetParams() {
params.delegate = browser_view_; params.delegate = browser_view_;
std::map<std::string, std::vector<uint8_t>> properties = std::map<std::string, std::vector<uint8_t>> properties =
views::MusClient::ConfigurePropertiesFromParams(params); views::MusClient::ConfigurePropertiesFromParams(params);
const std::string chrome_app_id(extension_misc::kChromeAppId);
// Indicates mash shouldn't handle immersive, rather we will. // Indicates mash shouldn't handle immersive, rather we will.
properties[ui::mojom::WindowManager::kDisableImmersive_InitProperty] = properties[ui::mojom::WindowManager::kDisableImmersive_InitProperty] =
mojo::ConvertTo<std::vector<uint8_t>>(true); mojo::ConvertTo<std::vector<uint8_t>>(true);
...@@ -65,9 +66,6 @@ views::Widget::InitParams BrowserFrameMus::GetWidgetParams() { ...@@ -65,9 +66,6 @@ views::Widget::InitParams BrowserFrameMus::GetWidgetParams() {
properties[ui::mojom::WindowManager::kShelfItemType_Property] = properties[ui::mojom::WindowManager::kShelfItemType_Property] =
mojo::ConvertTo<std::vector<uint8_t>>( mojo::ConvertTo<std::vector<uint8_t>>(
static_cast<int64_t>(ash::TYPE_BROWSER_SHORTCUT)); static_cast<int64_t>(ash::TYPE_BROWSER_SHORTCUT));
properties[ui::mojom::WindowManager::kWindowTitleShown_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(
static_cast<int64_t>(browser_view_->ShouldShowWindowTitle()));
// TODO(estade): to match classic Ash, this property should be toggled to true // TODO(estade): to match classic Ash, this property should be toggled to true
// for non-popups after the window is initially shown. // for non-popups after the window is initially shown.
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_frame_ash.h" #include "chrome/browser/ui/views/frame/browser_frame_ash.h"
#include "chrome/browser/ui/views/frame/browser_frame_header_ash.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/hosted_app_button_container.h" #include "chrome/browser/ui/views/frame/hosted_app_button_container.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
...@@ -435,7 +436,7 @@ void BrowserNonClientFrameViewAsh::ChildPreferredSizeChanged( ...@@ -435,7 +436,7 @@ void BrowserNonClientFrameViewAsh::ChildPreferredSizeChanged(
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ash::CustomFrameHeader::AppearanceProvider: // BrowserFrameHeaderAsh::AppearanceProvider:
SkColor BrowserNonClientFrameViewAsh::GetFrameHeaderColor(bool active) { SkColor BrowserNonClientFrameViewAsh::GetFrameHeaderColor(bool active) {
return GetFrameColor(active); return GetFrameColor(active);
...@@ -636,72 +637,71 @@ void BrowserNonClientFrameViewAsh::OnOverviewOrSplitviewModeChanged() { ...@@ -636,72 +637,71 @@ void BrowserNonClientFrameViewAsh::OnOverviewOrSplitviewModeChanged() {
std::unique_ptr<ash::FrameHeader> std::unique_ptr<ash::FrameHeader>
BrowserNonClientFrameViewAsh::CreateFrameHeader() { BrowserNonClientFrameViewAsh::CreateFrameHeader() {
std::unique_ptr<ash::FrameHeader> header;
Browser* browser = browser_view()->browser(); Browser* browser = browser_view()->browser();
if (!UsePackagedAppHeaderStyle()) { if (!UsePackagedAppHeaderStyle()) {
auto browser_frame_header = std::make_unique<ash::CustomFrameHeader>(); auto browser_frame_header = std::make_unique<BrowserFrameHeaderAsh>();
browser_frame_header->Init(this, this, browser_frame_header->Init(
!browser_view()->IsRegularOrGuestSession(), this, this, !browser_view()->IsRegularOrGuestSession(), window_icon_,
caption_button_container_); caption_button_container_, back_button_);
header = std::move(browser_frame_header); return browser_frame_header;
} else { }
std::unique_ptr<ash::DefaultFrameHeader> default_frame_header = std::unique_ptr<ash::DefaultFrameHeader> default_frame_header =
std::make_unique<ash::DefaultFrameHeader>(frame(), this, std::make_unique<ash::DefaultFrameHeader>(frame(), this,
caption_button_container_); caption_button_container_);
// TODO(alancutter): Move this branch into a new HostedAppFrameHeader class.
if (extensions::HostedAppBrowserController:: // TODO(alancutter): Move this branch into a new HostedAppFrameHeader class.
IsForExperimentalHostedAppBrowser(browser)) { if (extensions::HostedAppBrowserController::IsForExperimentalHostedAppBrowser(
SkColor active_color = ash::FrameCaptionButton::GetButtonColor( browser)) {
ash::FrameCaptionButton::ColorMode::kDefault, // Hosted apps apply a theme color if specified by the extension.
ash::DefaultFrameHeader::GetDefaultFrameColor()); base::Optional<SkColor> theme_color =
browser->hosted_app_controller()->GetThemeColor();
// Hosted apps apply a theme color if specified by the extension. if (theme_color) {
base::Optional<SkColor> theme_color = SkColor opaque_theme_color =
browser->hosted_app_controller()->GetThemeColor(); SkColorSetA(theme_color.value(), SK_AlphaOPAQUE);
if (theme_color) { default_frame_header->SetThemeColor(opaque_theme_color);
theme_color = SkColorSetA(theme_color.value(), SK_AlphaOPAQUE);
default_frame_header->SetThemeColor(*theme_color);
active_color = ash::FrameCaptionButton::GetButtonColor(
ash::FrameCaptionButton::ColorMode::kThemed, *theme_color);
}
// Add the container for extra hosted app buttons (e.g app menu button).
const float inactive_alpha_ratio =
ash::FrameCaptionButton::GetInactiveButtonColorAlphaRatio();
SkColor inactive_color =
SkColorSetA(active_color, 255 * inactive_alpha_ratio);
hosted_app_button_container_ = new HostedAppButtonContainer(
browser_view(), active_color, inactive_color);
caption_button_container_->AddChildViewAt(hosted_app_button_container_,
0);
// Add the origin text.
frame_header_origin_text_ =
std::make_unique<ash::FrameHeaderOriginText>(
browser->hosted_app_controller()->GetFormattedUrlOrigin(),
active_color, inactive_color)
.release();
AddChildView(frame_header_origin_text_);
// Schedule the title bar animation.
constexpr base::TimeDelta kTitlebarAnimationDelay =
base::TimeDelta::FromMilliseconds(750);
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&BrowserNonClientFrameViewAsh::StartHostedAppAnimation,
weak_factory_.GetWeakPtr()),
kTitlebarAnimationDelay);
} else if (!browser->is_app()) {
default_frame_header->SetFrameColors(BrowserFrameAsh::kMdWebUiFrameColor,
BrowserFrameAsh::kMdWebUiFrameColor);
} }
header = std::move(default_frame_header);
// Add the container for extra hosted app buttons (e.g app menu button).
SkColor active_color = ash::FrameCaptionButton::GetButtonColor(
theme_color ? ash::FrameCaptionButton::ColorMode::kThemed
: ash::FrameCaptionButton::ColorMode::kDefault,
default_frame_header->GetActiveFrameColor());
const float inactive_alpha_ratio =
ash::FrameCaptionButton::GetInactiveButtonColorAlphaRatio();
SkColor inactive_color =
SkColorSetA(active_color, 255 * inactive_alpha_ratio);
hosted_app_button_container_ = new HostedAppButtonContainer(
browser_view(), active_color, inactive_color);
caption_button_container_->AddChildViewAt(hosted_app_button_container_, 0);
// Add the origin text.
frame_header_origin_text_ =
std::make_unique<ash::FrameHeaderOriginText>(
browser->hosted_app_controller()->GetFormattedUrlOrigin(),
active_color, inactive_color)
.release();
AddChildView(frame_header_origin_text_);
// Schedule the title bar animation.
constexpr base::TimeDelta kTitlebarAnimationDelay =
base::TimeDelta::FromMilliseconds(750);
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&BrowserNonClientFrameViewAsh::StartHostedAppAnimation,
weak_factory_.GetWeakPtr()),
kTitlebarAnimationDelay);
} else if (!browser->is_app()) {
default_frame_header->SetFrameColors(BrowserFrameAsh::kMdWebUiFrameColor,
BrowserFrameAsh::kMdWebUiFrameColor);
} }
header->SetBackButton(back_button_); if (back_button_)
header->SetLeftHeaderView(window_icon_); default_frame_header->set_back_button(back_button_);
return header;
if (window_icon_)
default_frame_header->set_left_header_view(window_icon_);
return default_frame_header;
} }
void BrowserNonClientFrameViewAsh::StartHostedAppAnimation() { void BrowserNonClientFrameViewAsh::StartHostedAppAnimation() {
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <memory> #include <memory>
#include "ash/frame/custom_frame_header.h"
#include "ash/public/interfaces/split_view.mojom.h" #include "ash/public/interfaces/split_view.mojom.h"
#include "ash/shell_observer.h" #include "ash/shell_observer.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/command_observer.h" #include "chrome/browser/command_observer.h"
#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/ash/tablet_mode_client_observer.h"
#include "chrome/browser/ui/views/frame/browser_frame_header_ash.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/tab_icon_view_model.h" #include "chrome/browser/ui/views/tab_icon_view_model.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
...@@ -35,7 +35,7 @@ class FrameHeaderOriginText; ...@@ -35,7 +35,7 @@ class FrameHeaderOriginText;
// Provides the BrowserNonClientFrameView for Chrome OS. // Provides the BrowserNonClientFrameView for Chrome OS.
class BrowserNonClientFrameViewAsh class BrowserNonClientFrameViewAsh
: public BrowserNonClientFrameView, : public BrowserNonClientFrameView,
public ash::CustomFrameHeader::AppearanceProvider, public BrowserFrameHeaderAsh::AppearanceProvider,
public ash::ShellObserver, public ash::ShellObserver,
public TabletModeClientObserver, public TabletModeClientObserver,
public TabIconViewModel, public TabIconViewModel,
...@@ -76,7 +76,7 @@ class BrowserNonClientFrameViewAsh ...@@ -76,7 +76,7 @@ class BrowserNonClientFrameViewAsh
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
// ash::CustomFrameHeader::AppearanceProvider: // BrowserFrameHeaderAsh::AppearanceProvider:
SkColor GetFrameHeaderColor(bool active) override; SkColor GetFrameHeaderColor(bool active) override;
gfx::ImageSkia GetFrameHeaderImage(bool active) override; gfx::ImageSkia GetFrameHeaderImage(bool active) override;
gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) override; gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) override;
...@@ -135,6 +135,7 @@ class BrowserNonClientFrameViewAsh ...@@ -135,6 +135,7 @@ class BrowserNonClientFrameViewAsh
FrameLayout); FrameLayout);
friend class HostedAppNonClientFrameViewAshTest; friend class HostedAppNonClientFrameViewAshTest;
friend class BrowserFrameHeaderAsh;
// Distance between the right edge of the NonClientFrameView and the tab // Distance between the right edge of the NonClientFrameView and the tab
// strip. // strip.
......
...@@ -694,8 +694,8 @@ class HostedAppNonClientFrameViewAshTest ...@@ -694,8 +694,8 @@ class HostedAppNonClientFrameViewAshTest
// Tests that a web app's theme color is set. // Tests that a web app's theme color is set.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) {
EXPECT_EQ(GetThemeColor(), frame_header_->active_frame_color_for_testing()); EXPECT_EQ(GetThemeColor(), frame_header_->GetActiveFrameColor());
EXPECT_EQ(GetThemeColor(), frame_header_->inactive_frame_color_for_testing()); EXPECT_EQ(GetThemeColor(), frame_header_->GetInactiveFrameColor());
EXPECT_EQ(SK_ColorWHITE, GetActiveIconColor(hosted_app_button_container_)); EXPECT_EQ(SK_ColorWHITE, GetActiveIconColor(hosted_app_button_container_));
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_frame_header_ash.h"
#include "chrome/browser/ui/views/frame/browser_frame_mus.h" #include "chrome/browser/ui/views/frame/browser_frame_mus.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
...@@ -38,7 +39,6 @@ ...@@ -38,7 +39,6 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ash/ash_layout_constants.h" #include "ash/ash_layout_constants.h"
#include "ash/public/cpp/window_properties.h"
#endif #endif
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -102,8 +102,6 @@ void BrowserNonClientFrameViewMus::Init() { ...@@ -102,8 +102,6 @@ void BrowserNonClientFrameViewMus::Init() {
AddChildView(window_icon_); AddChildView(window_icon_);
window_icon_->Update(); window_icon_->Update();
} }
OnThemeChanged();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -352,18 +350,6 @@ gfx::Size BrowserNonClientFrameViewMus::GetMinimumSize() const { ...@@ -352,18 +350,6 @@ gfx::Size BrowserNonClientFrameViewMus::GetMinimumSize() const {
return gfx::Size(min_width, min_client_view_size.height()); return gfx::Size(min_width, min_client_view_size.height());
} }
void BrowserNonClientFrameViewMus::OnThemeChanged() {
#if defined(OS_CHROMEOS)
gfx::ImageSkia active_frame_image = GetFrameImage(true);
if (active_frame_image.isNull()) {
frame()->GetNativeWindow()->ClearProperty(ash::kFrameImageActiveKey);
} else {
frame()->GetNativeWindow()->SetProperty(
ash::kFrameImageActiveKey, new gfx::ImageSkia(active_frame_image));
}
#endif
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// TabIconViewModel: // TabIconViewModel:
......
...@@ -57,7 +57,6 @@ class BrowserNonClientFrameViewMus : public BrowserNonClientFrameView, ...@@ -57,7 +57,6 @@ class BrowserNonClientFrameViewMus : public BrowserNonClientFrameView,
const char* GetClassName() const override; const char* GetClassName() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
void OnThemeChanged() override;
// TabIconViewModel: // TabIconViewModel:
bool ShouldTabIconViewAnimate() const override; bool ShouldTabIconViewAnimate() const override;
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#include "ui/views/linux_ui/linux_ui.h" #include "ui/views/linux_ui/linux_ui.h"
#endif #endif
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/ash_config.h"
#endif
namespace { namespace {
enum PopupType { WIDE, NARROW, ROUNDED }; enum PopupType { WIDE, NARROW, ROUNDED };
...@@ -320,6 +324,20 @@ IN_PROC_BROWSER_TEST_P(OmniboxPopupContentsViewTest, MAYBE_ThemeIntegration) { ...@@ -320,6 +324,20 @@ IN_PROC_BROWSER_TEST_P(OmniboxPopupContentsViewTest, MAYBE_ThemeIntegration) {
loader.LoadExtension(path); loader.LoadExtension(path);
} }
#if defined(OS_CHROMEOS)
if (chromeos::GetAshConfig() == ash::Config::MASH) {
// http://crbug.com/704942: Incognito frames do not update correctly in
// Mash, so the old values remain. Check here so this is revisited when
// fixed, and bail out of the rest of the test.
if (GetParam() == ROUNDED)
EXPECT_EQ(rounded_selection_color_dark, get_selection_color());
else
EXPECT_EQ(legacy_dark_color, get_selection_color());
return;
}
#endif
// Check the incognito browser first. Everything should now be light and never // Check the incognito browser first. Everything should now be light and never
// GTK. // GTK.
if (GetParam() == ROUNDED) { if (GetParam() == ROUNDED) {
......
...@@ -169,9 +169,6 @@ interface WindowManager { ...@@ -169,9 +169,6 @@ interface WindowManager {
// The window's title. Maps to aura::client::kTitleKey. Type: mojom::String // The window's title. Maps to aura::client::kTitleKey. Type: mojom::String
const string kWindowTitle_Property = "prop:window-title"; const string kWindowTitle_Property = "prop:window-title";
// A boolean determining whether to show the window's title.
const string kWindowTitleShown_Property = "prop:window-title-shown";
// End long lived properties. ------------------------------------------------ // End long lived properties. ------------------------------------------------
// Called immediately when the WindowManager is obtained. // Called immediately when the WindowManager is obtained.
......
...@@ -698,9 +698,7 @@ bool DesktopWindowTreeHostMus::ShouldWindowContentsBeTransparent() const { ...@@ -698,9 +698,7 @@ bool DesktopWindowTreeHostMus::ShouldWindowContentsBeTransparent() const {
return false; return false;
} }
void DesktopWindowTreeHostMus::FrameTypeChanged() { void DesktopWindowTreeHostMus::FrameTypeChanged() {}
native_widget_delegate_->AsWidget()->ThemeChanged();
}
void DesktopWindowTreeHostMus::SetFullscreen(bool fullscreen) { void DesktopWindowTreeHostMus::SetFullscreen(bool fullscreen) {
if (IsFullscreen() == fullscreen) if (IsFullscreen() == fullscreen)
......
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