Index: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
index ed796ab96efa4e48c6a67cb79ad05508aaf94a56..d69dbc520db2545ac1884854b2d329ad2a91b127 100644 |
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc |
@@ -13,6 +13,7 @@ |
#include "components/signin/core/common/profile_management_switches.h" |
#include "ui/base/material_design/material_design_controller.h" |
#include "ui/gfx/font.h" |
+#include "ui/views/controls/button/custom_button.h" |
#include "ui/views/controls/button/image_button.h" |
#include "ui/views/controls/label.h" |
@@ -419,11 +420,11 @@ void OpaqueBrowserFrameViewLayout::ConfigureButton( |
// When the window is restored, we show a maximized button; otherwise, we |
// show a restore button. |
bool is_restored = !delegate_->IsMaximized() && !delegate_->IsMinimized(); |
- views::ImageButton* invisible_button = is_restored ? |
+ views::CustomButton* invisible_button = is_restored ? |
restore_button_ : maximize_button_; |
invisible_button->SetVisible(false); |
- views::ImageButton* visible_button = is_restored ? |
+ views::CustomButton* visible_button = is_restored ? |
maximize_button_ : restore_button_; |
visible_button->SetVisible(true); |
SetBoundsForButton(host, visible_button, alignment, caption_y); |
@@ -454,15 +455,23 @@ void OpaqueBrowserFrameViewLayout::HideButton(views::FrameButton button_id) { |
void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
views::View* host, |
- views::ImageButton* button, |
+ views::CustomButton* button, |
ButtonAlignment alignment, |
int caption_y) { |
gfx::Size button_size = button->GetPreferredSize(); |
- button->SetImageAlignment( |
- (alignment == ALIGN_LEADING) ? |
- views::ImageButton::ALIGN_RIGHT : views::ImageButton::ALIGN_LEFT, |
- views::ImageButton::ALIGN_BOTTOM); |
+ // If the custom button is actually an ImageButton, get a pointer so that |
+ // the image can be further configured. |
+ views::ImageButton* image_button = |
+ views::ImageButton::kViewClassName == button->GetClassName() ? |
+ static_cast<views::ImageButton*>(button) : nullptr; |
+ |
+ if (image_button) { |
+ image_button->SetImageAlignment( |
+ (alignment == ALIGN_LEADING) ? |
+ views::ImageButton::ALIGN_RIGHT : views::ImageButton::ALIGN_LEFT, |
+ views::ImageButton::ALIGN_BOTTOM); |
+ } |
// There should always be the same number of non-shadow pixels visible to the |
// side of the caption buttons. In maximized mode we extend buttons to the |
@@ -470,12 +479,15 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton( |
// to the screen left, for left-aligned buttons) to obey Fitts' Law. |
bool title_bar_condensed = IsTitleBarCondensed(); |
- // When we are the first button on the leading side and are the close |
- // button, we must flip ourselves, because the close button assets have |
- // a little notch to fit in the rounded frame. |
- button->SetDrawImageMirrored(alignment == ALIGN_LEADING && |
- !has_leading_buttons_ && |
- button == close_button_); |
+ if (image_button) { |
+ // When we are the first button on the leading side and are the close |
+ // button, we must flip ourselves, because the close button assets have |
+ // a little notch to fit in the rounded frame. |
+ image_button->SetDrawImageMirrored( |
+ alignment == ALIGN_LEADING && !has_leading_buttons_ && |
+ button == close_button_); |
+ } |
+ |
// If the window is maximized, align the buttons to its upper edge. |
int extra_height = title_bar_condensed ? extra_caption_y_ : 0; |
@@ -534,31 +546,35 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) { |
switch (id) { |
case VIEW_ID_MINIMIZE_BUTTON: |
if (view) { |
- DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
- view->GetClassName()); |
+ minimize_button_ = views::CustomButton::AsCustomButton(view); |
+ DCHECK(nullptr != minimize_button_); |
+ } else { |
+ minimize_button_ = nullptr; |
} |
- minimize_button_ = static_cast<views::ImageButton*>(view); |
break; |
case VIEW_ID_MAXIMIZE_BUTTON: |
if (view) { |
- DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
- view->GetClassName()); |
+ maximize_button_ = views::CustomButton::AsCustomButton(view); |
+ DCHECK(nullptr != maximize_button_); |
+ } else { |
+ maximize_button_ = nullptr; |
} |
- maximize_button_ = static_cast<views::ImageButton*>(view); |
break; |
case VIEW_ID_RESTORE_BUTTON: |
if (view) { |
- DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
- view->GetClassName()); |
+ restore_button_ = views::CustomButton::AsCustomButton(view); |
+ DCHECK(nullptr != restore_button_); |
+ } else { |
+ restore_button_ = nullptr; |
} |
- restore_button_ = static_cast<views::ImageButton*>(view); |
break; |
case VIEW_ID_CLOSE_BUTTON: |
if (view) { |
- DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
- view->GetClassName()); |
+ close_button_ = views::CustomButton::AsCustomButton(view); |
+ DCHECK(nullptr != close_button_); |
+ } else { |
+ close_button_ = nullptr; |
} |
- close_button_ = static_cast<views::ImageButton*>(view); |
break; |
case VIEW_ID_WINDOW_ICON: |
window_icon_ = view; |