Skip to content

Commit

Permalink
Add CanMinimize to classes that implement WidgetDelegate::CanMaximize.
Browse files Browse the repository at this point in the history
There were some cases where we use CanMaximize to determine if
minimization should be disabled. They now use CanMinimize:
- custom_frame_view_ash
- hwnd_message_handler

All classes that implement CanMaximize now implement
CanMinimize in the same way, so there should no change in
behavior.

BUG=328241,341010

Review URL: https://codereview.chromium.org/583603004

Cr-Commit-Position: refs/heads/master@{#296381}
  • Loading branch information
jackhou-chromium authored and Commit bot committed Sep 24, 2014
1 parent 4912899 commit 3fdb732
Show file tree
Hide file tree
Showing 29 changed files with 72 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class TestWidgetDelegate : public views::WidgetDelegateView {
return can_maximize_;
}

virtual bool CanMinimize() const OVERRIDE {
return can_maximize_;
}

private:
bool can_maximize_;

Expand Down
3 changes: 3 additions & 0 deletions ash/frame/caption_buttons/frame_size_button_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class TestWidgetDelegate : public views::WidgetDelegateView {
virtual bool CanMaximize() const OVERRIDE {
return true;
}
virtual bool CanMinimize() const OVERRIDE {
return true;
}

ash::FrameCaptionButtonContainerView* caption_button_container() {
return caption_button_container_;
Expand Down
4 changes: 1 addition & 3 deletions ash/frame/custom_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,8 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
avatar_icon_(NULL),
caption_button_container_(NULL),
fullscreen_visible_fraction_(0) {
// Unfortunately, there is no views::WidgetDelegate::CanMinimize(). Assume
// that the window frame can be minimized if it can be maximized.
FrameCaptionButtonContainerView::MinimizeAllowed minimize_allowed =
frame_->widget_delegate()->CanMaximize() ?
frame_->widget_delegate()->CanMinimize() ?
FrameCaptionButtonContainerView::MINIMIZE_ALLOWED :
FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED;
caption_button_container_ = new FrameCaptionButtonContainerView(frame_,
Expand Down
4 changes: 4 additions & 0 deletions ash/frame/custom_frame_view_ash_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TestWidgetConstraintsDelegate : public TestWidgetDelegate {
return true;
}

virtual bool CanMinimize() const OVERRIDE {
return true;
}

void set_minimum_size(const gfx::Size& min_size) {
minimum_size_ = min_size;
}
Expand Down
4 changes: 4 additions & 0 deletions ash/shell/panel_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ bool PanelWindow::CanMaximize() const {
return false;
}

bool PanelWindow::CanMinimize() const {
return false;
}

views::NonClientFrameView* PanelWindow::CreateNonClientFrameView(
views::Widget* widget) {
return new PanelFrameView(widget, PanelFrameView::FRAME_NONE);
Expand Down
1 change: 1 addition & 0 deletions ash/shell/panel_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PanelWindow : public views::WidgetDelegateView {
virtual View* GetContentsView() OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual views::NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) OVERRIDE;

Expand Down
4 changes: 4 additions & 0 deletions ash/shell/toplevel_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,9 @@ bool ToplevelWindow::CanMaximize() const {
return params_.can_maximize;
}

bool ToplevelWindow::CanMinimize() const {
return params_.can_maximize;
}

} // namespace shell
} // namespace ash
1 change: 1 addition & 0 deletions ash/shell/toplevel_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ToplevelWindow : public views::WidgetDelegateView {
virtual View* GetContentsView() OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;

const CreateParams params_;

Expand Down
4 changes: 4 additions & 0 deletions ash/shell/window_type_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ bool WindowTypeLauncher::CanMaximize() const {
return true;
}

bool WindowTypeLauncher::CanMinimize() const {
return true;
}

void WindowTypeLauncher::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == create_button_) {
Expand Down
1 change: 1 addition & 0 deletions ash/shell/window_type_launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class WindowTypeLauncher : public views::WidgetDelegateView,
virtual bool CanResize() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;

// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
Expand Down
3 changes: 3 additions & 0 deletions ash/wm/resize_shadow_and_cursor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class TestWidgetDelegate : public views::WidgetDelegateView {
virtual bool CanMaximize() const OVERRIDE {
return true;
}
virtual bool CanMinimize() const OVERRIDE {
return true;
}
virtual views::NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) OVERRIDE {
return new ash::CustomFrameViewAsh(widget);
Expand Down
1 change: 1 addition & 0 deletions ash/wm/system_gesture_event_filter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ResizableWidgetDelegate : public views::WidgetDelegateView {
private:
virtual bool CanResize() const OVERRIDE { return true; }
virtual bool CanMaximize() const OVERRIDE { return true; }
virtual bool CanMinimize() const OVERRIDE { return true; }
virtual void DeleteDelegate() OVERRIDE { delete this; }

DISALLOW_COPY_AND_ASSIGN(ResizableWidgetDelegate);
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,10 @@ bool BrowserView::CanMaximize() const {
return true;
}

bool BrowserView::CanMinimize() const {
return true;
}

bool BrowserView::CanActivate() const {
if (!AppModalDialogQueue::GetInstance()->active_dialog() ||
!AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog())
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/frame/browser_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ class BrowserView : public BrowserWindow,
// Overridden from views::WidgetDelegate:
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual bool CanActivate() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual base::string16 GetAccessibleWindowTitle() const OVERRIDE;
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/views/panels/panel_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ bool PanelView::CanMaximize() const {
return false;
}

bool PanelView::CanMinimize() const {
return false;
}

base::string16 PanelView::GetWindowTitle() const {
return panel_->GetWindowTitle();
}
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/panels/panel_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class PanelView : public NativePanel,
views::Widget* widget) OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual views::Widget* GetWidget() OVERRIDE;
virtual const views::Widget* GetWidget() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/views/profiles/user_manager_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ bool UserManagerView::CanMaximize() const {
return true;
}

bool UserManagerView::CanMinimize() const {
return true;
}

base::string16 UserManagerView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
}
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/profiles/user_manager_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class UserManagerView : public views::DialogDelegateView {
// views::DialogDelegateView:
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual int GetDialogButtons() const OVERRIDE;
virtual void WindowClosing() OVERRIDE;
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/ui/views/task_manager_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class TaskManagerView : public views::ButtonListener,
// views::DialogDelegateView:
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual std::string GetWindowName() const OVERRIDE;
Expand Down Expand Up @@ -530,6 +531,10 @@ bool TaskManagerView::CanMaximize() const {
return true;
}

bool TaskManagerView::CanMinimize() const {
return true;
}

bool TaskManagerView::ExecuteWindowsCommand(int command_id) {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions components/native_app_window/native_app_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ bool NativeAppWindowViews::CanMaximize() const {
!app_window_->window_type_is_panel() && !WidgetHasHitTestMask();
}

bool NativeAppWindowViews::CanMinimize() const {
// TODO(jackhou): Change this to always be true.
return CanMaximize();
}

base::string16 NativeAppWindowViews::GetWindowTitle() const {
return app_window_->GetTitle();
}
Expand Down
1 change: 1 addition & 0 deletions components/native_app_window/native_app_window_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class NativeAppWindowViews : public extensions::NativeAppWindow,
virtual views::View* GetInitiallyFocusedView() OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual base::string16 GetWindowTitle() const OVERRIDE;
virtual bool ShouldShowWindowTitle() const OVERRIDE;
virtual bool ShouldShowWindowIcon() const OVERRIDE;
Expand Down
1 change: 1 addition & 0 deletions content/shell/browser/shell_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class ShellWindowDelegateView : public views::WidgetDelegateView,
// Overridden from WidgetDelegateView
virtual bool CanResize() const OVERRIDE { return true; }
virtual bool CanMaximize() const OVERRIDE { return true; }
virtual bool CanMinimize() const OVERRIDE { return true; }
virtual base::string16 GetWindowTitle() const OVERRIDE {
return title_;
}
Expand Down
1 change: 1 addition & 0 deletions ui/views/examples/examples_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class ExamplesWindowContents : public WidgetDelegateView,
// WidgetDelegateView:
virtual bool CanResize() const OVERRIDE { return true; }
virtual bool CanMaximize() const OVERRIDE { return true; }
virtual bool CanMinimize() const OVERRIDE { return true; }
virtual base::string16 GetWindowTitle() const OVERRIDE {
return base::ASCIIToUTF16("Views Examples");
}
Expand Down
4 changes: 4 additions & 0 deletions ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ bool DesktopWindowTreeHostWin::CanMaximize() const {
return GetWidget()->widget_delegate()->CanMaximize();
}

bool DesktopWindowTreeHostWin::CanMinimize() const {
return GetWidget()->widget_delegate()->CanMinimize();
}

bool DesktopWindowTreeHostWin::CanActivate() const {
if (IsModalWindowActive())
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
virtual bool IsInactiveRenderingDisabled() OVERRIDE;
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual bool CanMinimize() const OVERRIDE;
virtual bool CanActivate() const OVERRIDE;
virtual bool WidgetSizeIsClientSize() const OVERRIDE;
virtual bool IsModal() const OVERRIDE;
Expand Down
3 changes: 3 additions & 0 deletions ui/views/widget/native_widget_aura_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ class PropertyTestWidgetDelegate : public views::WidgetDelegate {
virtual bool CanMaximize() const OVERRIDE {
return true;
}
virtual bool CanMinimize() const OVERRIDE {
return true;
}
virtual bool CanResize() const OVERRIDE {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions ui/views/widget/widget_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class VIEWS_EXPORT WidgetDelegate {
virtual BubbleDelegateView* AsBubbleDelegate();
virtual DialogDelegate* AsDialogDelegate();

// Returns true if the window can ever be resized.
// Returns true if the window can be resized.
virtual bool CanResize() const;

// Returns true if the window can ever be maximized.
// Returns true if the window can be maximized.
virtual bool CanMaximize() const;

// Returns true if the window can ever be minimized.
// Returns true if the window can be minimized.
virtual bool CanMinimize() const;

// Returns true if the window can be activated.
Expand Down
4 changes: 1 addition & 3 deletions ui/views/win/hwnd_message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,7 @@ void HWNDMessageHandler::OnInitMenu(HMENU menu) {
EnableMenuItemByCommand(menu, SC_SIZE, delegate_->CanResize() && is_restored);
EnableMenuItemByCommand(menu, SC_MAXIMIZE, delegate_->CanMaximize() &&
!is_fullscreen && !is_maximized);
// TODO: unfortunately, WidgetDelegate does not declare CanMinimize() and some
// code depends on this check, see http://crbug.com/341010.
EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMaximize() &&
EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMinimize() &&
!is_minimized);

if (is_maximized && delegate_->CanResize())
Expand Down
1 change: 1 addition & 0 deletions ui/views/win/hwnd_message_handler_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {

virtual bool CanResize() const = 0;
virtual bool CanMaximize() const = 0;
virtual bool CanMinimize() const = 0;
virtual bool CanActivate() const = 0;

virtual bool WidgetSizeIsClientSize() const = 0;
Expand Down

0 comments on commit 3fdb732

Please sign in to comment.