Commit 5052c19b authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Chrome OS - Don't show window title in container windows.

This restores the behavior that the window title won't be shown
in the window frame for container windows (ARC++/Crostini). The
exception is when a debug title ("extra title") has been set, in
which case the debug string is shown.

Overview mode will use the normal title, unless a debug/"extra" title
is set, in which case it uses that.

Bug: 842476
Change-Id: Id0df3466b66e769363f313772bf63ff9f26e7b80
Reviewed-on: https://chromium-review.googlesource.com/1058560
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560373}
parent 10c6fad6
......@@ -343,10 +343,6 @@ gfx::Rect CustomFrameViewAsh::GetClientBoundsForWindowBounds(
return client_bounds;
}
base::string16 CustomFrameViewAsh::GetFrameTitle() const {
return frame_->widget_delegate()->GetWindowTitle();
}
////////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh, views::NonClientFrameView overrides:
......
......@@ -88,9 +88,6 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView,
gfx::Rect GetClientBoundsForWindowBounds(
const gfx::Rect& window_bounds) const;
// Returns the title string which should be shown in the frame.
virtual base::string16 GetFrameTitle() const;
// views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
gfx::Rect GetWindowBoundsForClientBounds(
......
......@@ -472,7 +472,7 @@ void ClientControlledShellSurface::SetExtraTitle(
TRACE_EVENT1("exo", "ClientControlledShellSurface::SetExtraTitle",
"extra_title", base::UTF16ToUTF8(extra_title));
// The extra title is used in the window frame.
frame_title_ = extra_title;
extra_title_ = extra_title;
if (widget_)
widget_->UpdateWindowTitle();
}
......
......@@ -1062,27 +1062,24 @@ TEST_F(ClientControlledShellSurfaceTest, SetExtraTitle) {
surface->Attach(buffer.get());
surface->Commit();
// NativeWindow's title is used within the overview mode. It should be the
// specified title, as ShellSurface does. On the other hand, the frame's
// GetWindowTitle() should return the extra -- showing the debugging info
// in the title bar but otherwise it should have empty string.
// See https://crbug.com/831383.
// The window title should include the debugging info, if any, and should only
// be shown (in the frame) when there is debugging info. See
// https://crbug.com/831383.
const aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
const ash::CustomFrameViewAsh* frame =
static_cast<const ash::CustomFrameViewAsh*>(
shell_surface->GetWidget()->non_client_view()->frame_view());
const views::WidgetDelegate* widget_delegate =
shell_surface->GetWidget()->widget_delegate();
shell_surface->SetExtraTitle(base::ASCIIToUTF16("extra"));
EXPECT_EQ(base::string16(), window->GetTitle());
EXPECT_EQ(base::ASCIIToUTF16("extra"), frame->GetFrameTitle());
EXPECT_EQ(base::ASCIIToUTF16(" (extra)"), window->GetTitle());
EXPECT_TRUE(widget_delegate->ShouldShowWindowTitle());
shell_surface->SetTitle(base::ASCIIToUTF16("title"));
EXPECT_EQ(base::ASCIIToUTF16("title"), window->GetTitle());
EXPECT_EQ(base::ASCIIToUTF16("extra"), frame->GetFrameTitle());
EXPECT_EQ(base::ASCIIToUTF16("title (extra)"), window->GetTitle());
EXPECT_TRUE(widget_delegate->ShouldShowWindowTitle());
shell_surface->SetExtraTitle(base::string16());
EXPECT_EQ(base::ASCIIToUTF16("title"), window->GetTitle());
EXPECT_EQ(base::string16(), frame->GetFrameTitle());
EXPECT_FALSE(widget_delegate->ShouldShowWindowTitle());
}
TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
......
......@@ -111,10 +111,6 @@ class CustomFrameView : public ash::CustomFrameViewAsh {
~CustomFrameView() override {}
// Overridden from ash::CustomFrameViewAsh:
base::string16 GetFrameTitle() const override {
return static_cast<ShellSurfaceBase*>(GetWidget()->widget_delegate())
->frame_title();
}
void SetShouldPaintHeader(bool paint) override {
if (visible()) {
CustomFrameViewAsh::SetShouldPaintHeader(paint);
......@@ -912,7 +908,17 @@ bool ShellSurfaceBase::CanMinimize() const {
}
base::string16 ShellSurfaceBase::GetWindowTitle() const {
return title_;
if (extra_title_.empty())
return title_;
// TODO(estade): revisit how the extra title is shown in the window frame and
// other surfaces like overview mode.
return title_ + base::ASCIIToUTF16(" (") + extra_title_ +
base::ASCIIToUTF16(")");
}
bool ShellSurfaceBase::ShouldShowWindowTitle() const {
return !extra_title_.empty();
}
gfx::ImageSkia ShellSurfaceBase::GetWindowIcon() {
......
......@@ -103,8 +103,6 @@ class ShellSurfaceBase : public SurfaceTreeHost,
// Set title for the surface.
void SetTitle(const base::string16& title);
const base::string16& frame_title() const { return frame_title_; }
// Set icon for the surface.
void SetIcon(const gfx::ImageSkia& icon);
......@@ -188,6 +186,7 @@ class ShellSurfaceBase : public SurfaceTreeHost,
bool CanMaximize() const override;
bool CanMinimize() const override;
base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
gfx::ImageSkia GetWindowIcon() override;
void WindowClosing() override;
views::Widget* GetWidget() override;
......@@ -311,8 +310,8 @@ class ShellSurfaceBase : public SurfaceTreeHost,
bool shadow_bounds_changed_ = false;
std::unique_ptr<ash::WindowResizer> resizer_;
base::string16 title_;
// The title string shown in the window frame (title bar).
base::string16 frame_title_;
// The debug title string shown in the window frame (title bar).
base::string16 extra_title_;
std::unique_ptr<ui::CompositorLock> configure_compositor_lock_;
ConfigureCallback configure_callback_;
// TODO(oshima): Remove this once the transition to new drag/resize
......
......@@ -249,12 +249,9 @@ TEST_F(ShellSurfaceTest, SetTitle) {
// have the specified title.
EXPECT_EQ(base::ASCIIToUTF16("test"),
shell_surface->GetWidget()->GetNativeWindow()->GetTitle());
const ash::CustomFrameViewAsh* frame =
static_cast<const ash::CustomFrameViewAsh*>(
shell_surface->GetWidget()->non_client_view()->frame_view());
// Frame's title is the string to be shown in the title bar. This should be
// empty.
EXPECT_EQ(base::string16(), frame->GetFrameTitle());
// The titlebar shouldn't show the title.
EXPECT_FALSE(
shell_surface->GetWidget()->widget_delegate()->ShouldShowWindowTitle());
}
TEST_F(ShellSurfaceTest, SetApplicationId) {
......
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