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