Commit da08ce6d authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Mash browser frame: fix rendering in single tab mode

Single tab mode makes the frame the same color as a tab.

Bug: 854704
Change-Id: I0d7e790d977858e4ae2942f5f93009c7774bf423
Reviewed-on: https://chromium-review.googlesource.com/1118977
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571690}
parent 530ea0fe
......@@ -70,6 +70,7 @@ int BrowserNonClientFrameView::GetAvatarIconPadding() {
void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {
MaybeObserveTabstrip();
OnSingleTabModeChanged();
UpdateMinimumSize();
}
......
......@@ -249,6 +249,15 @@ BrowserNonClientFrameViewAsh::CreateInterfacePtrForTesting() {
///////////////////////////////////////////////////////////////////////////////
// BrowserNonClientFrameView:
void BrowserNonClientFrameViewAsh::OnSingleTabModeChanged() {
if (!IsMash()) {
BrowserNonClientFrameView::OnSingleTabModeChanged();
return;
}
UpdateFrameColors();
}
gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip(
views::View* tabstrip) const {
if (!tabstrip)
......@@ -659,27 +668,7 @@ void BrowserNonClientFrameViewAsh::OnThemeChanged() {
inactive_frame_overlay_image_registration_ = update_window_image(
ash::kFrameImageOverlayInactiveKey, GetFrameOverlayImage(false));
base::Optional<SkColor> active_color, inactive_color;
if (!UsePackagedAppHeaderStyle(browser_view()->browser())) {
active_color = GetFrameColor(true);
inactive_color = GetFrameColor(false);
} else if (extensions::HostedAppBrowserController::
IsForExperimentalHostedAppBrowser(browser_view()->browser())) {
base::Optional<SkColor> theme_color =
browser_view()->browser()->hosted_app_controller()->GetThemeColor();
window->SetProperty(ash::kFrameIsThemedByHostedAppKey, !!theme_color);
if (theme_color)
active_color = SkColorSetA(*theme_color, SK_AlphaOPAQUE);
} else {
active_color = BrowserFrameAsh::kMdWebUiFrameColor;
}
if (active_color) {
window->SetProperty(ash::kFrameActiveColorKey, *active_color);
window->SetProperty(ash::kFrameInactiveColorKey,
inactive_color.value_or(*active_color));
}
UpdateFrameColors();
BrowserNonClientFrameView::OnThemeChanged();
}
......@@ -1072,3 +1061,33 @@ void BrowserNonClientFrameViewAsh::StartHostedAppAnimation() {
hosted_app_button_container_->StartTitlebarAnimation(
frame_header_origin_text_->AnimationDuration());
}
void BrowserNonClientFrameViewAsh::UpdateFrameColors() {
DCHECK(IsMash());
aura::Window* window = frame()->GetNativeWindow();
base::Optional<SkColor> active_color, inactive_color;
if (!UsePackagedAppHeaderStyle(browser_view()->browser())) {
active_color = GetFrameColor(true);
inactive_color = GetFrameColor(false);
} else if (extensions::HostedAppBrowserController::
IsForExperimentalHostedAppBrowser(browser_view()->browser())) {
base::Optional<SkColor> theme_color =
browser_view()->browser()->hosted_app_controller()->GetThemeColor();
window->SetProperty(ash::kFrameIsThemedByHostedAppKey, !!theme_color);
if (theme_color)
active_color = SkColorSetA(*theme_color, SK_AlphaOPAQUE);
} else {
active_color = BrowserFrameAsh::kMdWebUiFrameColor;
}
if (active_color) {
window->SetProperty(ash::kFrameActiveColorKey, *active_color);
window->SetProperty(ash::kFrameInactiveColorKey,
inactive_color.value_or(*active_color));
} else {
window->ClearProperty(ash::kFrameActiveColorKey);
window->ClearProperty(ash::kFrameInactiveColorKey);
}
}
......@@ -60,6 +60,7 @@ class BrowserNonClientFrameViewAsh
ash::mojom::SplitViewObserverPtr CreateInterfacePtrForTesting();
// BrowserNonClientFrameView:
void OnSingleTabModeChanged() override;
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
......@@ -196,6 +197,9 @@ class BrowserNonClientFrameViewAsh
// app UI elements exist.
void StartHostedAppAnimation();
// To be called after the frame's colors may have changed.
void UpdateFrameColors();
// View which contains the window controls.
ash::FrameCaptionButtonContainerView* caption_button_container_ = nullptr;
......
......@@ -494,7 +494,7 @@ void TabStrip::AddTabAt(int model_index, TabRendererData data, bool is_active) {
SwapLayoutIfNecessary();
if (was_single_tab_mode)
if (was_single_tab_mode != SingleTabMode())
SingleTabModeChanged();
for (TabStripObserver& observer : observers_)
......
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