Skip to content

Commit

Permalink
Makes top border height customizable
Browse files Browse the repository at this point in the history
BUG=b/33693796
TEST=covered by unittest

Change-Id: Ief4d7ff8426ce8c54ad0fbcf34f54bbbd72490cf
Reviewed-on: https://chromium-review.googlesource.com/989849
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547474}
  • Loading branch information
mitoshima authored and Commit Bot committed Apr 2, 2018
1 parent 7356813 commit 0304ae9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ash/frame/custom_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() {
}

int CustomFrameViewAsh::NonClientTopBorderHeight() const {
// TODO(oshima): CustomFrameViewAsh should be able to tell if it's
// in immersive mode and return 0, instead of using custom logic.
if (zero_top_border_height_)
return 0;

// The frame should not occupy the window area when it's in fullscreen,
// not visible or disabled.
if (frame_->IsFullscreen() || !visible() || !enabled())
Expand Down
7 changes: 7 additions & 0 deletions ash/frame/custom_frame_view_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView,
// preferred height is used.
void SetHeaderHeight(base::Optional<int> height);

// Overrides the default top border height with zero value.
void set_zero_top_border_height(bool zero_top_border_height) {
zero_top_border_height_ = zero_top_border_height;
}

// Get the view of the header.
views::View* GetHeaderView();

Expand Down Expand Up @@ -166,6 +171,8 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView,

OverlayView* overlay_view_;

bool zero_top_border_height_ = false;

ImmersiveFullscreenControllerDelegate* immersive_delegate_;

// Observes avatar icon change and updates |header_view_|.
Expand Down
10 changes: 10 additions & 0 deletions ash/frame/custom_frame_view_ash_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,16 @@ TEST_F(CustomFrameViewAshTest, CustomButtonModel) {
#endif
}

TEST_F(CustomFrameViewAshTest, ZeroTopBorderHeightOverride) {
CustomFrameTestWidgetDelegate* delegate = new CustomFrameTestWidgetDelegate;
std::unique_ptr<views::Widget> widget(CreateWidget(delegate));
CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view();
custom_frame_view->set_zero_top_border_height(true);
EXPECT_EQ(0, delegate->GetCustomFrameViewTopBorderHeight());
custom_frame_view->set_zero_top_border_height(false);
EXPECT_EQ(33, delegate->GetCustomFrameViewTopBorderHeight());
}

namespace {

class CustomFrameViewAshFrameColorTest
Expand Down

0 comments on commit 0304ae9

Please sign in to comment.