summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp12
-rw-r--r--ash/ash_strings.grd15
-rw-r--r--ash/ash_switches.cc17
-rw-r--r--ash/ash_switches.h6
-rw-r--r--ash/frame/caption_buttons/alternate_frame_size_button.h7
-rw-r--r--ash/frame/caption_buttons/alternate_frame_size_button_unittest.cc6
-rw-r--r--ash/frame/caption_buttons/bubble_contents_button_row.cc216
-rw-r--r--ash/frame/caption_buttons/bubble_contents_button_row.h59
-rw-r--r--ash/frame/caption_buttons/caption_button_types.h8
-rw-r--r--ash/frame/caption_buttons/frame_caption_button_container_view.cc20
-rw-r--r--ash/frame/caption_buttons/frame_caption_button_container_view.h5
-rw-r--r--ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc71
-rw-r--r--ash/frame/caption_buttons/frame_maximize_button.cc547
-rw-r--r--ash/frame/caption_buttons/frame_maximize_button.h174
-rw-r--r--ash/frame/caption_buttons/frame_maximize_button_observer.h26
-rw-r--r--ash/frame/caption_buttons/frame_maximize_button_unittest.cc814
-rw-r--r--ash/frame/caption_buttons/maximize_bubble_controller.cc99
-rw-r--r--ash/frame/caption_buttons/maximize_bubble_controller.h104
-rw-r--r--ash/frame/caption_buttons/maximize_bubble_controller_bubble.cc510
-rw-r--r--ash/frame/caption_buttons/maximize_bubble_controller_bubble.h102
-rw-r--r--ash/frame/custom_frame_view_ash.cc37
-rw-r--r--ash/metrics/user_metrics_recorder.cc12
-rw-r--r--ash/metrics/user_metrics_recorder.h4
-rw-r--r--ash/resources/ash_resources.grd15
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_hover.pngbin271 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_hover_restore.pngbin344 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_normal.pngbin112 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_normal_restore.pngbin190 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_pressed.pngbin363 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_left_pressed_restore.pngbin476 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_middle_hover.pngbin276 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_middle_normal.pngbin113 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_middle_pressed.pngbin365 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_hover.pngbin273 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_hover_restore.pngbin355 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_normal.pngbin112 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_normal_restore.pngbin189 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_pressed.pngbin372 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/common/window_position_right_pressed_restore.pngbin511 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_hover.pngbin370 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_hover_restore.pngbin724 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_normal.pngbin140 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_normal_restore.pngbin410 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_pressed.pngbin686 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_left_pressed_restore.pngbin1059 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_middle_hover.pngbin321 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_middle_normal.pngbin148 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_middle_pressed.pngbin658 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_hover.pngbin364 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_hover_restore.pngbin743 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_normal.pngbin146 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_normal_restore.pngbin406 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_pressed.pngbin690 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/common/window_position_right_pressed_restore.pngbin1085 -> 0 bytes
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc18
-rw-r--r--ash/wm/dock/docked_window_layout_manager.h3
-rw-r--r--ash/wm/workspace/phantom_window_controller.cc190
-rw-r--r--ash/wm/workspace/phantom_window_controller.h33
-rw-r--r--ash/wm/workspace/phantom_window_controller_unittest.cc173
-rw-r--r--ash/wm/workspace/snap_types.h23
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc8
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h15
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/about_flags.cc8
64 files changed, 71 insertions, 3292 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index eedf7a7..ad4398e 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -164,20 +164,11 @@
'frame/caption_buttons/alternate_frame_size_button.cc',
'frame/caption_buttons/alternate_frame_size_button.h',
'frame/caption_buttons/alternate_frame_size_button_delegate.h',
- 'frame/caption_buttons/bubble_contents_button_row.cc',
- 'frame/caption_buttons/bubble_contents_button_row.h',
'frame/caption_buttons/caption_button_types.h',
'frame/caption_buttons/frame_caption_button.cc',
'frame/caption_buttons/frame_caption_button.h',
'frame/caption_buttons/frame_caption_button_container_view.cc',
'frame/caption_buttons/frame_caption_button_container_view.h',
- 'frame/caption_buttons/frame_maximize_button.cc',
- 'frame/caption_buttons/frame_maximize_button.h',
- 'frame/caption_buttons/frame_maximize_button_observer.h',
- 'frame/caption_buttons/maximize_bubble_controller.cc',
- 'frame/caption_buttons/maximize_bubble_controller.h',
- 'frame/caption_buttons/maximize_bubble_controller_bubble.cc',
- 'frame/caption_buttons/maximize_bubble_controller_bubble.h',
'frame/custom_frame_view_ash.cc',
'frame/custom_frame_view_ash.h',
'frame/frame_border_hit_test_controller.cc',
@@ -680,7 +671,6 @@
'wm/workspace/multi_window_resize_controller.h',
'wm/workspace/phantom_window_controller.cc',
'wm/workspace/phantom_window_controller.h',
- 'wm/workspace/snap_types.h',
'wm/workspace/two_step_edge_cycler.cc',
'wm/workspace/two_step_edge_cycler.h',
'wm/workspace/workspace_event_handler.cc',
@@ -932,7 +922,6 @@
'focus_cycler_unittest.cc',
'frame/caption_buttons/alternate_frame_size_button_unittest.cc',
'frame/caption_buttons/frame_caption_button_container_view_unittest.cc',
- 'frame/caption_buttons/frame_maximize_button_unittest.cc',
'frame/custom_frame_view_ash_unittest.cc',
'frame/default_header_painter_unittest.cc',
'host/ash_window_tree_host_x11_unittest.cc',
@@ -1014,7 +1003,6 @@
'wm/maximize_mode/workspace_backdrop_delegate.h',
'wm/workspace/magnetism_matcher_unittest.cc',
'wm/workspace/multi_window_resize_controller_unittest.cc',
- 'wm/workspace/phantom_window_controller_unittest.cc',
'wm/workspace/workspace_event_handler_test_helper.cc',
'wm/workspace/workspace_event_handler_test_helper.h',
'wm/workspace/workspace_event_handler_unittest.cc',
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd
index 3b93ca0..07a6f3f 100644
--- a/ash/ash_strings.grd
+++ b/ash/ash_strings.grd
@@ -542,21 +542,6 @@ Press Shift + Alt to switch.
<message name="IDS_ASH_NOTIFICATION_UNREAD_COUNT_NINE_PLUS" desc="The text shown in the notification icon for the unread count when the count is more than 9.">
9+
</message>
- <message name="IDS_ASH_MAXIMIZE_WINDOW" desc="A help text to show that when the button gets clicked the window get maximized.">
- Maximize
- </message>
- <message name="IDS_ASH_SNAP_WINDOW_RIGHT" desc="A help text to show that when the button gets clicked the window get snapped to the right side.">
- Right
- </message>
- <message name="IDS_ASH_SNAP_WINDOW_LEFT" desc="A help text to show that when the button gets clicked the window get snapped to the left side.">
- Left
- </message>
- <message name="IDS_ASH_RESTORE_WINDOW" desc="A help text to show that when the button gets clicked the window gets restored to its normal - non maximized - state.">
- Restore
- </message>
- <message name="IDS_ASH_MINIMIZE_WINDOW" desc="A help text to show that when the button gets clicked the window gets minimized.">
- Minimize
- </message>
<message name="IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING" desc="An error message to show that the system failed to enter the mirroring mode.">
Could not mirror displays since no supported resolutions found. Entered extended desktop instead.
</message>
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index faeb168..acc29b1 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -38,11 +38,6 @@ const char kAshDefaultWallpaperIsOem[] = "ash-default-wallpaper-is-oem";
const char kAshDefaultWallpaperLarge[] = "ash-default-wallpaper-large";
const char kAshDefaultWallpaperSmall[] = "ash-default-wallpaper-small";
-// Use the normal visual style for the caption buttons (minimize, maximize,
-// restore, close).
-const char kAshDisableAlternateFrameCaptionButtonStyle[] =
- "ash-disable-alternate-caption-button";
-
// Disable ability to dock windows at the desktop edge.
const char kAshDisableDockedWindows[] = "ash-disable-docked-windows";
@@ -51,13 +46,6 @@ const char kAshDisableDockedWindows[] = "ash-disable-docked-windows";
const char kAshEnableTouchExplorationMode[] =
"ash-enable-touch-exploration-mode";
-// Use alternate visual style for the caption buttons (minimize, maximize,
-// restore, close). The alternate style:
-// - Adds a dedicated button for minimize.
-// - Removes the maximize button's help bubble.
-const char kAshEnableAlternateFrameCaptionButtonStyle[] =
- "ash-enable-alternate-caption-button";
-
#if defined(OS_CHROMEOS)
// Enables key bindings to scroll magnified screen.
const char kAshEnableMagnifierKeyScroller[] =
@@ -122,11 +110,6 @@ const char kForceAshToDesktop[] = "ash-force-desktop";
#endif
-bool UseAlternateFrameCaptionButtonStyle() {
- return !CommandLine::ForCurrentProcess()->
- HasSwitch(kAshDisableAlternateFrameCaptionButtonStyle);
-}
-
bool UseDockedWindows() {
return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableDockedWindows);
}
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index 8ad2ec6..e1be504 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -24,10 +24,8 @@ ASH_EXPORT extern const char kAshDebugShortcuts[];
ASH_EXPORT extern const char kAshDefaultWallpaperIsOem[];
ASH_EXPORT extern const char kAshDefaultWallpaperLarge[];
ASH_EXPORT extern const char kAshDefaultWallpaperSmall[];
-ASH_EXPORT extern const char kAshDisableAlternateFrameCaptionButtonStyle[];
ASH_EXPORT extern const char kAshDisableDockedWindows[];
ASH_EXPORT extern const char kAshEnableTouchExplorationMode[];
-ASH_EXPORT extern const char kAshEnableAlternateFrameCaptionButtonStyle[];
#if defined(OS_CHROMEOS)
ASH_EXPORT extern const char kAshEnableMagnifierKeyScroller[];
#endif
@@ -47,10 +45,6 @@ ASH_EXPORT extern const char kAuraLegacyPowerButton[];
ASH_EXPORT extern const char kForceAshToDesktop[];
#endif
-// Returns true if the alternate visual style for the caption buttons (minimize,
-// maximize, restore, close) should be used.
-ASH_EXPORT bool UseAlternateFrameCaptionButtonStyle();
-
// Returns true if items can be dragged off the shelf to unpin.
ASH_EXPORT bool UseDragOffShelf();
diff --git a/ash/frame/caption_buttons/alternate_frame_size_button.h b/ash/frame/caption_buttons/alternate_frame_size_button.h
index e99d32f..f7ffe3b 100644
--- a/ash/frame/caption_buttons/alternate_frame_size_button.h
+++ b/ash/frame/caption_buttons/alternate_frame_size_button.h
@@ -8,7 +8,6 @@
#include "ash/ash_export.h"
#include "ash/frame/caption_buttons/alternate_frame_size_button_delegate.h"
#include "ash/frame/caption_buttons/frame_caption_button.h"
-#include "ash/wm/workspace/snap_types.h"
#include "base/timer/timer.h"
namespace views {
@@ -49,6 +48,12 @@ class ASH_EXPORT AlternateFrameSizeButton : public FrameCaptionButton {
}
private:
+ enum SnapType {
+ SNAP_LEFT,
+ SNAP_RIGHT,
+ SNAP_NONE
+ };
+
// Starts |set_buttons_to_snap_mode_timer_|.
void StartSetButtonsToSnapModeTimer(const ui::LocatedEvent& event);
diff --git a/ash/frame/caption_buttons/alternate_frame_size_button_unittest.cc b/ash/frame/caption_buttons/alternate_frame_size_button_unittest.cc
index 92c7bbc..9fd4b0f 100644
--- a/ash/frame/caption_buttons/alternate_frame_size_button_unittest.cc
+++ b/ash/frame/caption_buttons/alternate_frame_size_button_unittest.cc
@@ -4,13 +4,11 @@
#include "ash/frame/caption_buttons/alternate_frame_size_button.h"
-#include "ash/ash_switches.h"
#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h"
-#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "grit/ash_resources.h"
#include "ui/aura/test/event_generator.h"
@@ -127,10 +125,6 @@ class AlternateFrameSizeButtonTest : public AshTestBase {
virtual void SetUp() OVERRIDE {
AshTestBase::SetUp();
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- command_line->AppendSwitch(
- switches::kAshEnableAlternateFrameCaptionButtonStyle);
-
TestWidgetDelegate* delegate = new TestWidgetDelegate();
window_state_ = ash::wm::GetWindowState(
CreateWidget(delegate)->GetNativeWindow());
diff --git a/ash/frame/caption_buttons/bubble_contents_button_row.cc b/ash/frame/caption_buttons/bubble_contents_button_row.cc
deleted file mode 100644
index 761beec..0000000
--- a/ash/frame/caption_buttons/bubble_contents_button_row.cc
+++ /dev/null
@@ -1,216 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/frame/caption_buttons/bubble_contents_button_row.h"
-
-#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
-#include "ash/frame/caption_buttons/maximize_bubble_controller_bubble.h"
-#include "grit/ash_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/views/controls/button/image_button.h"
-#include "ui/views/layout/box_layout.h"
-
-
-namespace ash {
-
-// BubbleDialogButton ---------------------------------------------------------
-
-// The image button gets overridden to be able to capture mouse hover events.
-// The constructor also assigns all button states and adds |this| as a child of
-// |button_row|.
-class BubbleDialogButton : public views::ImageButton {
- public:
- explicit BubbleDialogButton(BubbleContentsButtonRow* button_row,
- int normal_image,
- int hovered_image,
- int pressed_image);
- virtual ~BubbleDialogButton();
-
- // views::ImageButton:
- virtual void OnMouseCaptureLost() OVERRIDE;
- virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
- virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
- virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
-
- private:
- // The creating class which needs to get notified in case of a hover event.
- BubbleContentsButtonRow* button_row_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton);
-};
-
-BubbleDialogButton::BubbleDialogButton(
- BubbleContentsButtonRow* button_row,
- int normal_image,
- int hovered_image,
- int pressed_image)
- : views::ImageButton(button_row),
- button_row_(button_row) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- SetImage(views::CustomButton::STATE_NORMAL,
- rb.GetImageSkiaNamed(normal_image));
- SetImage(views::CustomButton::STATE_HOVERED,
- rb.GetImageSkiaNamed(hovered_image));
- SetImage(views::CustomButton::STATE_PRESSED,
- rb.GetImageSkiaNamed(pressed_image));
- button_row->AddChildView(this);
-}
-
-BubbleDialogButton::~BubbleDialogButton() {
-}
-
-void BubbleDialogButton::OnMouseCaptureLost() {
- button_row_->ButtonHovered(NULL);
- views::ImageButton::OnMouseCaptureLost();
-}
-
-void BubbleDialogButton::OnMouseEntered(const ui::MouseEvent& event) {
- button_row_->ButtonHovered(this);
- views::ImageButton::OnMouseEntered(event);
-}
-
-void BubbleDialogButton::OnMouseExited(const ui::MouseEvent& event) {
- button_row_->ButtonHovered(NULL);
- views::ImageButton::OnMouseExited(event);
-}
-
-bool BubbleDialogButton::OnMouseDragged(const ui::MouseEvent& event) {
- if (!button_row_->bubble()->controller())
- return false;
-
- // Remove the phantom window when we leave the button.
- gfx::Point screen_location(event.location());
- View::ConvertPointToScreen(this, &screen_location);
- if (!GetBoundsInScreen().Contains(screen_location))
- button_row_->ButtonHovered(NULL);
- else
- button_row_->ButtonHovered(this);
-
- // Pass the event on to the normal handler.
- return views::ImageButton::OnMouseDragged(event);
-}
-
-
-// BubbleContentsButtonRow ----------------------------------------------------
-
-BubbleContentsButtonRow::BubbleContentsButtonRow(
- MaximizeBubbleControllerBubble* bubble)
- : bubble_(bubble),
- left_button_(NULL),
- minimize_button_(NULL),
- right_button_(NULL) {
- SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kHorizontal, 0, 0,
- MaximizeBubbleControllerBubble::kLayoutSpacing));
- set_background(views::Background::CreateSolidBackground(
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor));
-
- if (base::i18n::IsRTL()) {
- AddMaximizeRightButton();
- AddMinimizeButton();
- AddMaximizeLeftButton();
- } else {
- AddMaximizeLeftButton();
- AddMinimizeButton();
- AddMaximizeRightButton();
- }
-}
-
-BubbleContentsButtonRow::~BubbleContentsButtonRow() {
-}
-
-void BubbleContentsButtonRow::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- // While shutting down, the connection to the owner might already be broken.
- if (!bubble_->controller())
- return;
- if (sender == left_button_) {
- bubble_->controller()->OnButtonClicked(
- (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_LEFT) ?
- SNAP_RESTORE : SNAP_LEFT);
- } else if (sender == minimize_button_) {
- bubble_->controller()->OnButtonClicked(SNAP_MINIMIZE);
- } else {
- DCHECK(sender == right_button_);
- bubble_->controller()->OnButtonClicked(
- (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_RIGHT) ?
- SNAP_RESTORE : SNAP_RIGHT);
- }
-}
-
-void BubbleContentsButtonRow::ButtonHovered(BubbleDialogButton* sender) {
- // While shutting down, the connection to the owner might already be broken.
- if (!bubble_->controller())
- return;
- if (sender == left_button_) {
- bubble_->controller()->OnButtonHover(
- (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_LEFT) ?
- SNAP_RESTORE : SNAP_LEFT);
- } else if (sender == minimize_button_) {
- bubble_->controller()->OnButtonHover(SNAP_MINIMIZE);
- } else if (sender == right_button_) {
- bubble_->controller()->OnButtonHover(
- (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_RIGHT) ?
- SNAP_RESTORE : SNAP_RIGHT);
- } else {
- bubble_->controller()->OnButtonHover(SNAP_NONE);
- }
-}
-
-views::CustomButton* BubbleContentsButtonRow::GetButtonForUnitTest(
- SnapType state) {
- switch (state) {
- case SNAP_LEFT:
- return left_button_;
- case SNAP_MINIMIZE:
- return minimize_button_;
- case SNAP_RIGHT:
- return right_button_;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-void BubbleContentsButtonRow::AddMaximizeLeftButton() {
- if (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_LEFT) {
- left_button_ = new BubbleDialogButton(
- this,
- IDR_AURA_WINDOW_POSITION_LEFT_RESTORE,
- IDR_AURA_WINDOW_POSITION_LEFT_RESTORE_H,
- IDR_AURA_WINDOW_POSITION_LEFT_RESTORE_P);
- } else {
- left_button_ = new BubbleDialogButton(
- this,
- IDR_AURA_WINDOW_POSITION_LEFT,
- IDR_AURA_WINDOW_POSITION_LEFT_H,
- IDR_AURA_WINDOW_POSITION_LEFT_P);
- }
-}
-
-void BubbleContentsButtonRow::AddMaximizeRightButton() {
- if (bubble_->controller()->maximize_type() == FRAME_STATE_SNAP_RIGHT) {
- right_button_ = new BubbleDialogButton(
- this,
- IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE,
- IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE_H,
- IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE_P);
- } else {
- right_button_ = new BubbleDialogButton(
- this,
- IDR_AURA_WINDOW_POSITION_RIGHT,
- IDR_AURA_WINDOW_POSITION_RIGHT_H,
- IDR_AURA_WINDOW_POSITION_RIGHT_P);
- }
-}
-
-void BubbleContentsButtonRow::AddMinimizeButton() {
- minimize_button_ = new BubbleDialogButton(
- this,
- IDR_AURA_WINDOW_POSITION_MIDDLE,
- IDR_AURA_WINDOW_POSITION_MIDDLE_H,
- IDR_AURA_WINDOW_POSITION_MIDDLE_P);
-}
-
-} // namespace ash
diff --git a/ash/frame/caption_buttons/bubble_contents_button_row.h b/ash/frame/caption_buttons/bubble_contents_button_row.h
deleted file mode 100644
index e3bfc61..0000000
--- a/ash/frame/caption_buttons/bubble_contents_button_row.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_FRAME_CAPTION_BUTTONS_BUBBLE_CONTENTS_BUTTON_ROW_H_
-#define ASH_FRAME_CAPTION_BUTTONS_BUBBLE_CONTENTS_BUTTON_ROW_H_
-
-#include "ash/wm/workspace/snap_types.h"
-#include "ui/views/controls/button/button.h"
-
-namespace views {
-class CustomButton;
-}
-
-namespace ash {
-
-class BubbleDialogButton;
-class MaximizeBubbleControllerBubble;
-
-// A class that creates all buttons and puts them into a view.
-class BubbleContentsButtonRow : public views::View,
- public views::ButtonListener {
- public:
- explicit BubbleContentsButtonRow(MaximizeBubbleControllerBubble* bubble);
- virtual ~BubbleContentsButtonRow();
-
- // views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const ui::Event& event) OVERRIDE;
-
- // Called from BubbleDialogButton.
- void ButtonHovered(BubbleDialogButton* sender);
-
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
- MaximizeBubbleControllerBubble* bubble() { return bubble_; }
-
- private:
- // Functions to add the left and right maximize / restore buttons.
- void AddMaximizeLeftButton();
- void AddMaximizeRightButton();
- void AddMinimizeButton();
-
- // The owning object which gets notifications.
- MaximizeBubbleControllerBubble* bubble_;
-
- // The created buttons for our menu.
- BubbleDialogButton* left_button_;
- BubbleDialogButton* minimize_button_;
- BubbleDialogButton* right_button_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleContentsButtonRow);
-};
-
-} // namespace ash
-
-#endif // ASH_FRAME_CAPTION_BUTTONS_BUBBLE_CONTENTS_BUTTON_ROW_H_
diff --git a/ash/frame/caption_buttons/caption_button_types.h b/ash/frame/caption_buttons/caption_button_types.h
index b481a02..7cf625a 100644
--- a/ash/frame/caption_buttons/caption_button_types.h
+++ b/ash/frame/caption_buttons/caption_button_types.h
@@ -7,14 +7,6 @@
namespace ash {
-// These are the types of maximization we know.
-enum MaximizeBubbleFrameState {
- FRAME_STATE_NONE = 0,
- FRAME_STATE_FULL = 1, // This is the full maximized state.
- FRAME_STATE_SNAP_LEFT = 2,
- FRAME_STATE_SNAP_RIGHT = 3
-};
-
// These are the icon types that a caption button can have. The size button's
// action (SnapType) can be different from its icon.
enum CaptionButtonIcon {
diff --git a/ash/frame/caption_buttons/frame_caption_button_container_view.cc b/ash/frame/caption_buttons/frame_caption_button_container_view.cc
index f533f14..2138534 100644
--- a/ash/frame/caption_buttons/frame_caption_button_container_view.cc
+++ b/ash/frame/caption_buttons/frame_caption_button_container_view.cc
@@ -9,7 +9,6 @@
#include "ash/ash_switches.h"
#include "ash/frame/caption_buttons/alternate_frame_size_button.h"
#include "ash/frame/caption_buttons/frame_caption_button.h"
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "grit/ui_strings.h" // Accessibility names
@@ -48,23 +47,14 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView(
minimize_button_(NULL),
size_button_(NULL),
close_button_(NULL) {
- bool alternate_style = switches::UseAlternateFrameCaptionButtonStyle();
-
// Insert the buttons left to right.
minimize_button_ = new FrameCaptionButton(this, CAPTION_BUTTON_ICON_MINIMIZE);
minimize_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE));
- // Hide |minimize_button_| when using the non-alternate button style because
- // |size_button_| is capable of minimizing in this case.
- minimize_button_->SetVisible(
- minimize_allowed == MINIMIZE_ALLOWED &&
- (alternate_style || !frame_->widget_delegate()->CanMaximize()));
+ minimize_button_->SetVisible(minimize_allowed == MINIMIZE_ALLOWED);
AddChildView(minimize_button_);
- if (alternate_style)
- size_button_ = new AlternateFrameSizeButton(this, frame, this);
- else
- size_button_ = new FrameMaximizeButton(this, frame);
+ size_button_ = new AlternateFrameSizeButton(this, frame, this);
size_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE));
UpdateSizeButtonVisibility(false);
@@ -79,12 +69,6 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView(
FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() {
}
-FrameMaximizeButton*
-FrameCaptionButtonContainerView::GetOldStyleSizeButton() {
- return switches::UseAlternateFrameCaptionButtonStyle() ?
- NULL : static_cast<FrameMaximizeButton*>(size_button_);
-}
-
void FrameCaptionButtonContainerView::SetButtonImages(
CaptionButtonIcon icon,
int icon_image_id,
diff --git a/ash/frame/caption_buttons/frame_caption_button_container_view.h b/ash/frame/caption_buttons/frame_caption_button_container_view.h
index d50350e..31a85426 100644
--- a/ash/frame/caption_buttons/frame_caption_button_container_view.h
+++ b/ash/frame/caption_buttons/frame_caption_button_container_view.h
@@ -16,7 +16,6 @@ class Widget;
namespace ash {
class FrameCaptionButton;
-class FrameMaximizeButton;
// Container view for the frame caption buttons. It performs the appropriate
// action when a caption button is clicked.
@@ -66,10 +65,6 @@ class ASH_EXPORT FrameCaptionButtonContainerView
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
- // Returns the size button if using the old caption button style, returns NULL
- // otherwise.
- FrameMaximizeButton* GetOldStyleSizeButton();
-
// Sets the resource ids of the images to paint the button for |icon|. The
// FrameCaptionButtonContainerView will keep track of the images to use for
// |icon| even if none of the buttons currently use |icon|.
diff --git a/ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc b/ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc
index c0317bf..acd72c8 100644
--- a/ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc
+++ b/ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc
@@ -4,12 +4,9 @@
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/ash_switches.h"
#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/test/ash_test_base.h"
-#include "base/command_line.h"
#include "grit/ash_resources.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -102,29 +99,10 @@ class FrameCaptionButtonContainerViewTest : public ash::test::AshTestBase {
DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTest);
};
-class FrameCaptionButtonContainerViewTestOldStyle
- : public FrameCaptionButtonContainerViewTest {
- public:
- FrameCaptionButtonContainerViewTestOldStyle() {
- }
-
- virtual ~FrameCaptionButtonContainerViewTestOldStyle() {
- }
-
- virtual void SetUp() OVERRIDE {
- FrameCaptionButtonContainerViewTest::SetUp();
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAshDisableAlternateFrameCaptionButtonStyle);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTestOldStyle);
-};
-
// Test how the allowed actions affect which caption buttons are visible.
-TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) {
- // The minimize button should be hidden when both minimizing and maximizing
- // are allowed because the size button can do both.
+TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) {
+ // All the buttons should be visible when minimizing and maximizing are
+ // allowed.
scoped_ptr<views::Widget> widget_can_maximize(
CreateTestWidget(MAXIMIZE_ALLOWED));
FrameCaptionButtonContainerView container1(widget_can_maximize.get(),
@@ -132,11 +110,11 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) {
SetMockImages(&container1);
container1.Layout();
FrameCaptionButtonContainerView::TestApi t1(&container1);
- EXPECT_FALSE(t1.minimize_button()->visible());
+ EXPECT_TRUE(t1.minimize_button()->visible());
EXPECT_TRUE(t1.size_button()->visible());
EXPECT_TRUE(t1.close_button()->visible());
EXPECT_TRUE(CheckButtonsAtEdges(
- &container1, *t1.size_button(), *t1.close_button()));
+ &container1, *t1.minimize_button(), *t1.close_button()));
// The minimize button should be visible when minimizing is allowed but
// maximizing is disallowed.
@@ -167,43 +145,4 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) {
&container3, *t3.close_button(), *t3.close_button()));
}
-class FrameCaptionButtonContainerViewTestAlternateStyle
- : public FrameCaptionButtonContainerViewTest {
- public:
- FrameCaptionButtonContainerViewTestAlternateStyle() {
- }
-
- virtual ~FrameCaptionButtonContainerViewTestAlternateStyle() {
- }
-
- virtual void SetUp() OVERRIDE {
- FrameCaptionButtonContainerViewTest::SetUp();
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAshEnableAlternateFrameCaptionButtonStyle);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTestAlternateStyle);
-};
-
-// Test how the alternate button style affects which buttons are visible in the
-// default case.
-TEST_F(FrameCaptionButtonContainerViewTestAlternateStyle, ButtonVisibility) {
- // Both the minimize button and the maximize button should be visible when
- // both minimizing and maximizing are allowed when using the alternate
- // button style.
- scoped_ptr<views::Widget> widget_can_maximize(
- CreateTestWidget(MAXIMIZE_ALLOWED));
- FrameCaptionButtonContainerView container(widget_can_maximize.get(),
- FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
- SetMockImages(&container);
- container.Layout();
- FrameCaptionButtonContainerView::TestApi t(&container);
- EXPECT_TRUE(t.minimize_button()->visible());
- EXPECT_TRUE(t.size_button()->visible());
- EXPECT_TRUE(t.close_button()->visible());
- EXPECT_TRUE(CheckButtonsAtEdges(
- &container, *t.minimize_button(), *t.close_button()));
-}
-
} // namespace ash
diff --git a/ash/frame/caption_buttons/frame_maximize_button.cc b/ash/frame/caption_buttons/frame_maximize_button.cc
deleted file mode 100644
index dc28c7a..0000000
--- a/ash/frame/caption_buttons/frame_maximize_button.cc
+++ /dev/null
@@ -1,547 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
-
-#include "ash/frame/caption_buttons/frame_maximize_button_observer.h"
-#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
-#include "ash/metrics/user_metrics_recorder.h"
-#include "ash/screen_util.h"
-#include "ash/shelf/shelf_widget.h"
-#include "ash/shell.h"
-#include "ash/touch/touch_uma.h"
-#include "ash/wm/window_animations.h"
-#include "ash/wm/window_state.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/wm_event.h"
-#include "ash/wm/workspace/phantom_window_controller.h"
-#include "grit/ash_strings.h"
-#include "ui/aura/window.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/events/event.h"
-#include "ui/events/event_handler.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/screen.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/window/non_client_view.h"
-
-namespace ash {
-
-namespace {
-
-// Delay before forcing an update of the snap location.
-const int kUpdateDelayMS = 400;
-
-// The delay of the bubble appearance.
-const int kBubbleAppearanceDelayMS = 500;
-
-// The minimum sanp size in percent of the screen width.
-const int kMinSnapSizePercent = 50;
-}
-
-// EscapeEventFilter is installed on the RootWindow to track when the escape key
-// is pressed. We use an EventFilter for this as the FrameMaximizeButton
-// normally does not get focus.
-class FrameMaximizeButton::EscapeEventFilter : public ui::EventHandler {
- public:
- explicit EscapeEventFilter(FrameMaximizeButton* button);
- virtual ~EscapeEventFilter();
-
- // EventFilter overrides:
- virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
-
- private:
- FrameMaximizeButton* button_;
-
- DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter);
-};
-
-FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter(
- FrameMaximizeButton* button)
- : button_(button) {
- Shell::GetInstance()->AddPreTargetHandler(this);
-}
-
-FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() {
- Shell::GetInstance()->RemovePreTargetHandler(this);
-}
-
-void FrameMaximizeButton::EscapeEventFilter::OnKeyEvent(
- ui::KeyEvent* event) {
- if (event->type() == ui::ET_KEY_PRESSED &&
- event->key_code() == ui::VKEY_ESCAPE) {
- button_->Cancel(false);
- }
-}
-
-// FrameMaximizeButton ---------------------------------------------------------
-
-FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
- views::Widget* frame)
- : FrameCaptionButton(listener, CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE),
- frame_(frame),
- observing_frame_(false),
- is_snap_enabled_(false),
- exceeded_drag_threshold_(false),
- snap_type_(SNAP_NONE),
- bubble_appearance_delay_ms_(kBubbleAppearanceDelayMS) {
-}
-
-FrameMaximizeButton::~FrameMaximizeButton() {
- // Before the window gets destroyed, the maximizer dialog needs to be shut
- // down since it would otherwise call into a deleted object.
- maximizer_.reset();
- if (observing_frame_)
- OnWindowDestroying(frame_->GetNativeWindow());
-}
-
-void FrameMaximizeButton::AddObserver(FrameMaximizeButtonObserver* observer) {
- observer_list_.AddObserver(observer);
-}
-
-void FrameMaximizeButton::RemoveObserver(
- FrameMaximizeButtonObserver* observer) {
- observer_list_.RemoveObserver(observer);
-}
-
-void FrameMaximizeButton::SnapButtonHovered(SnapType type) {
- // Make sure to only show hover operations when no button is pressed and
- // a similar snap operation in progress does not get re-applied.
- if (is_snap_enabled_ || type == snap_type_)
- return;
- // Prime the mouse location with the center of the (local) button.
- press_location_ = gfx::Point(width() / 2, height() / 2);
- // Then get an adjusted mouse position to initiate the effect.
- gfx::Point location = press_location_;
- switch (type) {
- case SNAP_LEFT:
- location.set_x(location.x() - width());
- break;
- case SNAP_RIGHT:
- location.set_x(location.x() + width());
- break;
- case SNAP_MINIMIZE:
- location.set_y(location.y() + height());
- break;
- case SNAP_RESTORE:
- // Simulate a mouse button move over the according button.
- if (GetMaximizeBubbleFrameState() == FRAME_STATE_SNAP_LEFT)
- location.set_x(location.x() - width());
- else if (GetMaximizeBubbleFrameState() == FRAME_STATE_SNAP_RIGHT)
- location.set_x(location.x() + width());
- break;
- case SNAP_MAXIMIZE:
- break;
- case SNAP_NONE:
- Cancel(true);
- return;
- default:
- // We should not come here.
- NOTREACHED();
- }
- UpdateSnap(location);
-}
-
-void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) {
- Cancel(true);
- // Tell our menu to close.
- maximizer_.reset();
- snap_type_ = snap_type;
- Snap();
-}
-
-void FrameMaximizeButton::OnMaximizeBubbleShown(views::Widget* bubble) {
- FOR_EACH_OBSERVER(FrameMaximizeButtonObserver,
- observer_list_,
- OnMaximizeBubbleShown(bubble));
-}
-
-void FrameMaximizeButton::DestroyMaximizeMenu() {
- Cancel(false);
-}
-
-void FrameMaximizeButton::OnWindowBoundsChanged(
- aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
- Cancel(false);
-}
-
-void FrameMaximizeButton::OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) {
- Cancel(false);
-}
-
-void FrameMaximizeButton::OnWindowDestroying(aura::Window* window) {
- maximizer_.reset();
- if (observing_frame_) {
- CHECK_EQ(frame_->GetNativeWindow(), window);
- frame_->GetNativeWindow()->RemoveObserver(this);
- frame_->RemoveObserver(this);
- observing_frame_ = false;
- }
-}
-
-void FrameMaximizeButton::OnWidgetActivationChanged(views::Widget* widget,
- bool active) {
- // Upon losing focus, the bubble menu and the phantom window should hide.
- if (!active)
- Cancel(false);
-}
-
-bool FrameMaximizeButton::OnMousePressed(const ui::MouseEvent& event) {
- // If we are already in a mouse click / drag operation, a second button down
- // call will cancel (this addresses crbug.com/143755).
- if (is_snap_enabled_) {
- Cancel(false);
- } else {
- is_snap_enabled_ = event.IsOnlyLeftMouseButton();
- if (is_snap_enabled_)
- ProcessStartEvent(event);
- }
- FrameCaptionButton::OnMousePressed(event);
- return true;
-}
-
-void FrameMaximizeButton::OnMouseEntered(const ui::MouseEvent& event) {
- FrameCaptionButton::OnMouseEntered(event);
- if (!maximizer_) {
- DCHECK(GetWidget());
- if (!observing_frame_) {
- observing_frame_ = true;
- frame_->GetNativeWindow()->AddObserver(this);
- frame_->AddObserver(this);
- }
- maximizer_.reset(new MaximizeBubbleController(
- this,
- GetMaximizeBubbleFrameState(),
- bubble_appearance_delay_ms_));
- }
-}
-
-void FrameMaximizeButton::OnMouseExited(const ui::MouseEvent& event) {
- FrameCaptionButton::OnMouseExited(event);
- // Remove the bubble menu when the button is not pressed and the mouse is not
- // within the bubble.
- if (!is_snap_enabled_ && maximizer_) {
- if (maximizer_->GetBubbleWindow()) {
- gfx::Point screen_location = Shell::GetScreen()->GetCursorScreenPoint();
- if (!maximizer_->GetBubbleWindow()->GetBoundsInScreen().Contains(
- screen_location)) {
- maximizer_.reset();
- // Make sure that all remaining snap hover states get removed.
- SnapButtonHovered(SNAP_NONE);
- }
- } else {
- // The maximize dialog does not show up immediately after creating the
- // |maximizer_|. Destroy the dialog therefore before it shows up.
- maximizer_.reset();
- }
- }
-}
-
-bool FrameMaximizeButton::OnMouseDragged(const ui::MouseEvent& event) {
- if (is_snap_enabled_)
- ProcessUpdateEvent(event);
- return FrameCaptionButton::OnMouseDragged(event);
-}
-
-void FrameMaximizeButton::OnMouseReleased(const ui::MouseEvent& event) {
- maximizer_.reset();
- bool snap_was_enabled = is_snap_enabled_;
- if (!ProcessEndEvent(event) && snap_was_enabled)
- FrameCaptionButton::OnMouseReleased(event);
- // At this point |this| might be already destroyed.
-}
-
-void FrameMaximizeButton::OnMouseCaptureLost() {
- Cancel(false);
- FrameCaptionButton::OnMouseCaptureLost();
-}
-
-void FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) {
- if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
- is_snap_enabled_ = true;
- ProcessStartEvent(*event);
- event->SetHandled();
- return;
- }
-
- if (event->type() == ui::ET_GESTURE_TAP ||
- (event->type() == ui::ET_GESTURE_SCROLL_END && is_snap_enabled_) ||
- event->type() == ui::ET_SCROLL_FLING_START) {
- // The position of the event may have changed from the previous event (both
- // for TAP and SCROLL_END). So it is necessary to update the snap-state for
- // the current event.
- ProcessUpdateEvent(*event);
- if (event->type() == ui::ET_GESTURE_TAP) {
- snap_type_ = SnapTypeForLocation(event->location());
- TouchUMA::GetInstance()->RecordGestureAction(
- TouchUMA::GESTURE_FRAMEMAXIMIZE_TAP);
- }
- ProcessEndEvent(*event);
- event->SetHandled();
- return;
- }
-
- if (is_snap_enabled_) {
- if (event->type() == ui::ET_GESTURE_END &&
- event->details().touch_points() == 1) {
- // The position of the event may have changed from the previous event. So
- // it is necessary to update the snap-state for the current event.
- ProcessUpdateEvent(*event);
- snap_type_ = SnapTypeForLocation(event->location());
- ProcessEndEvent(*event);
- event->SetHandled();
- return;
- }
-
- if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
- event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
- ProcessUpdateEvent(*event);
- event->SetHandled();
- return;
- }
- }
-
- FrameCaptionButton::OnGestureEvent(event);
-}
-
-void FrameMaximizeButton::SetVisible(bool visible) {
- views::View::SetVisible(visible);
-}
-
-void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) {
- DCHECK(is_snap_enabled_);
- // Prepare the help menu.
- if (!maximizer_) {
- maximizer_.reset(new MaximizeBubbleController(
- this,
- GetMaximizeBubbleFrameState(),
- bubble_appearance_delay_ms_));
- } else {
- // If the menu did not show up yet, we delay it even a bit more.
- maximizer_->DelayCreation();
- }
- InstallEventFilter();
- snap_type_ = SNAP_NONE;
- press_location_ = event.location();
- exceeded_drag_threshold_ = false;
- update_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kUpdateDelayMS),
- this,
- &FrameMaximizeButton::UpdateSnapFromEventLocation);
-}
-
-void FrameMaximizeButton::ProcessUpdateEvent(const ui::LocatedEvent& event) {
- DCHECK(is_snap_enabled_);
- if (!exceeded_drag_threshold_) {
- exceeded_drag_threshold_ = views::View::ExceededDragThreshold(
- event.location() - press_location_);
- }
- if (exceeded_drag_threshold_)
- UpdateSnap(event.location());
-}
-
-bool FrameMaximizeButton::ProcessEndEvent(const ui::LocatedEvent& event) {
- update_timer_.Stop();
- UninstallEventFilter();
- bool should_snap = is_snap_enabled_;
- is_snap_enabled_ = false;
-
- // Remove our help bubble.
- maximizer_.reset();
-
- if (!should_snap || snap_type_ == SNAP_NONE)
- return false;
-
- SetState(views::CustomButton::STATE_NORMAL);
- // SetState will not call SchedulePaint() if state was already set to
- // STATE_NORMAL during a drag.
- SchedulePaint();
- phantom_window_.reset();
- Snap();
- return true;
-}
-
-void FrameMaximizeButton::Cancel(bool keep_menu_open) {
- if (!keep_menu_open) {
- maximizer_.reset();
- UninstallEventFilter();
- is_snap_enabled_ = false;
- }
- phantom_window_.reset();
- snap_type_ = SNAP_NONE;
- update_timer_.Stop();
- SchedulePaint();
-}
-
-void FrameMaximizeButton::InstallEventFilter() {
- if (escape_event_filter_)
- return;
-
- escape_event_filter_.reset(new EscapeEventFilter(this));
-}
-
-void FrameMaximizeButton::UninstallEventFilter() {
- escape_event_filter_.reset(NULL);
-}
-
-void FrameMaximizeButton::UpdateSnapFromEventLocation() {
- // If the drag threshold has been exceeded the snap location is up to date.
- if (exceeded_drag_threshold_)
- return;
- exceeded_drag_threshold_ = true;
- UpdateSnap(press_location_);
-}
-
-void FrameMaximizeButton::UpdateSnap(const gfx::Point& location) {
- SnapType type = SnapTypeForLocation(location);
- if (type == snap_type_)
- return;
-
- snap_type_ = type;
- SchedulePaint();
-
- if (snap_type_ == SNAP_NONE) {
- phantom_window_.reset();
- return;
- }
-
- if (!phantom_window_) {
- phantom_window_.reset(
- new PhantomWindowController(frame_->GetNativeWindow()));
- }
- if (maximizer_) {
- phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow());
- maximizer_->SetSnapType(snap_type_);
- }
- phantom_window_->Show(ScreenBoundsForType(snap_type_));
-}
-
-SnapType FrameMaximizeButton::SnapTypeForLocation(
- const gfx::Point& location) const {
- MaximizeBubbleFrameState maximize_type = GetMaximizeBubbleFrameState();
- gfx::Vector2d delta(location - press_location_);
- if (!views::View::ExceededDragThreshold(delta))
- return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE;
- if (delta.x() < 0 && delta.y() > delta.x() && delta.y() < -delta.x())
- return maximize_type == FRAME_STATE_SNAP_LEFT ? SNAP_RESTORE : SNAP_LEFT;
- if (delta.x() > 0 && delta.y() > -delta.x() && delta.y() < delta.x())
- return maximize_type == FRAME_STATE_SNAP_RIGHT ? SNAP_RESTORE : SNAP_RIGHT;
- if (delta.y() > 0)
- return SNAP_MINIMIZE;
- return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE;
-}
-
-gfx::Rect FrameMaximizeButton::ScreenBoundsForType(SnapType type) const {
- aura::Window* window = frame_->GetNativeWindow();
- switch (type) {
- case SNAP_LEFT:
- return ScreenUtil::ConvertRectToScreen(
- window->parent(),
- wm::GetDefaultLeftSnappedWindowBoundsInParent(window));
- case SNAP_RIGHT:
- return ScreenUtil::ConvertRectToScreen(
- window->parent(),
- wm::GetDefaultRightSnappedWindowBoundsInParent(window));
- case SNAP_MAXIMIZE:
- return ScreenUtil::ConvertRectToScreen(
- window->parent(),
- ScreenUtil::GetMaximizedWindowBoundsInParent(window));
- case SNAP_MINIMIZE: {
- gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(window);
- if (!rect.IsEmpty()) {
- // PhantomWindowController insets slightly, outset it so the phantom
- // doesn't appear inset.
- rect.Inset(-8, -8);
- }
- return rect;
- }
- case SNAP_RESTORE: {
- wm::WindowState* window_state = wm::GetWindowState(window);
- return window_state->HasRestoreBounds() ?
- window_state->GetRestoreBoundsInScreen() :
- frame_->GetWindowBoundsInScreen();
- }
- case SNAP_NONE:
- NOTREACHED();
- }
- return gfx::Rect();
-}
-
-void FrameMaximizeButton::Snap() {
- Shell* shell = Shell::GetInstance();
- wm::WindowState* window_state = wm::GetWindowState(frame_->GetNativeWindow());
- switch (snap_type_) {
- case SNAP_LEFT: {
- const wm::WMEvent event(wm::WM_EVENT_SNAP_LEFT);
- window_state->OnWMEvent(&event);
- shell->metrics()->RecordUserMetricsAction(
- UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT);
- break;
- }
- case SNAP_RIGHT: {
- const wm::WMEvent event(wm::WM_EVENT_SNAP_RIGHT);
- window_state->OnWMEvent(&event);
- shell->metrics()->RecordUserMetricsAction(
- UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT);
- break;
- }
- case SNAP_MAXIMIZE:
- frame_->Maximize();
- shell->metrics()->RecordUserMetricsAction(
- UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE);
- break;
- case SNAP_MINIMIZE:
- frame_->Minimize();
- shell->metrics()->RecordUserMetricsAction(
- UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE);
- break;
- case SNAP_RESTORE:
- frame_->Restore();
- shell->metrics()->RecordUserMetricsAction(
- UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE);
- break;
- case SNAP_NONE:
- NOTREACHED();
- }
-}
-
-MaximizeBubbleFrameState
-FrameMaximizeButton::GetMaximizeBubbleFrameState() const {
- wm::WindowState* window_state =
- wm::GetWindowState(frame_->GetNativeWindow());
- // When there are no restore bounds, we are in normal mode.
- if (!window_state->HasRestoreBounds())
- return FRAME_STATE_NONE;
- // The normal maximized test can be used.
- if (frame_->IsMaximized())
- return FRAME_STATE_FULL;
- // For Left/right maximize we need to check the dimensions.
- gfx::Rect bounds = frame_->GetWindowBoundsInScreen();
- gfx::Rect screen = Shell::GetScreen()->GetDisplayNearestWindow(
- frame_->GetNativeView()).work_area();
- if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100)
- return FRAME_STATE_NONE;
- // We might still have a horizontally filled window at this point which we
- // treat as no special state.
- if (bounds.y() != screen.y() || bounds.height() != screen.height())
- return FRAME_STATE_NONE;
-
- // We have to be in a maximize mode at this point.
- if (bounds.x() == screen.x())
- return FRAME_STATE_SNAP_LEFT;
- if (bounds.right() == screen.right())
- return FRAME_STATE_SNAP_RIGHT;
- // If we come here, it is likely caused by the fact that the
- // "VerticalResizeDoubleClick" stored a restore rectangle. In that case
- // we allow all maximize operations (and keep the restore rectangle).
- return FRAME_STATE_NONE;
-}
-
-} // namespace ash
diff --git a/ash/frame/caption_buttons/frame_maximize_button.h b/ash/frame/caption_buttons/frame_maximize_button.h
deleted file mode 100644
index 29d89e8..0000000
--- a/ash/frame/caption_buttons/frame_maximize_button.h
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
-#define ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
-
-#include "ash/ash_export.h"
-#include "ash/frame/caption_buttons/caption_button_types.h"
-#include "ash/frame/caption_buttons/frame_caption_button.h"
-#include "ash/wm/workspace/snap_types.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "base/timer/timer.h"
-#include "ui/aura/window_observer.h"
-#include "ui/views/widget/widget_observer.h"
-
-namespace views {
-class Widget;
-}
-
-namespace ash {
-class FrameMaximizeButtonObserver;
-class MaximizeBubbleController;
-class PhantomWindowController;
-
-// Button used for the maximize control on the frame. Handles snapping logic.
-class ASH_EXPORT FrameMaximizeButton : public FrameCaptionButton,
- public views::WidgetObserver,
- public aura::WindowObserver {
- public:
- FrameMaximizeButton(views::ButtonListener* listener,
- views::Widget* frame);
- virtual ~FrameMaximizeButton();
-
- void AddObserver(FrameMaximizeButtonObserver* observer);
- void RemoveObserver(FrameMaximizeButtonObserver* observer);
-
- // Updates |snap_type_| based on a a given snap type. This is used by
- // external hover events from the button menu.
- void SnapButtonHovered(SnapType type);
-
- // The user clicked the |type| button and the action needs to be performed,
- // which will at the same time close the window.
- void ExecuteSnapAndCloseMenu(SnapType type);
-
- // Called by the MaximizeBubbleController when the maximize bubble is shown.
- void OnMaximizeBubbleShown(views::Widget* bubble);
-
- // Remove the maximize menu from the screen (and destroy it).
- void DestroyMaximizeMenu();
-
- // Returns true when the user clicks and drags the button.
- bool is_snap_enabled() const { return is_snap_enabled_; }
-
- // WindowObserver overrides:
- virtual void OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE;
- virtual void OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) OVERRIDE;
- virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
-
- // WidgetObserver overrides:
- virtual void OnWidgetActivationChanged(views::Widget* widget,
- bool active) OVERRIDE;
-
- // ImageButton overrides:
- virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
- virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
- virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
- virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
- virtual void OnMouseCaptureLost() OVERRIDE;
-
- // ui::EventHandler overrides:
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
-
- // views::View overwrite:
- virtual void SetVisible(bool visible) OVERRIDE;
-
- // Unit test overwrite: Change the UI delay used for the bubble show up.
- void set_bubble_appearance_delay_ms(int bubble_appearance_delay_ms) {
- bubble_appearance_delay_ms_ = bubble_appearance_delay_ms;
- }
-
- // Unit test accessor for the maximize bubble.
- MaximizeBubbleController* maximizer() { return maximizer_.get(); }
-
- // Unit test to see if phantom window is open.
- bool phantom_window_open() { return phantom_window_.get() != NULL; }
-
- private:
- class EscapeEventFilter;
-
- // Initializes the snap-gesture based on the event. This should only be called
- // when the event is confirmed to have started a snap gesture.
- void ProcessStartEvent(const ui::LocatedEvent& event);
-
- // Updates the snap-state based on the current event. This should only be
- // called after the snap gesture has already started.
- void ProcessUpdateEvent(const ui::LocatedEvent& event);
-
- // Returns true if the window was snapped. Returns false otherwise.
- bool ProcessEndEvent(const ui::LocatedEvent& event);
-
- // Cancels snap behavior. If |keep_menu_open| is set, a possibly opened
- // bubble help will remain open.
- void Cancel(bool keep_menu_open);
-
- // Installs/uninstalls an EventFilter to track when escape is pressed.
- void InstallEventFilter();
- void UninstallEventFilter();
-
- // Updates the snap position from the event location. This is invoked by
- // |update_timer_|.
- void UpdateSnapFromEventLocation();
-
- // Updates |snap_type_| based on a mouse drag.
- void UpdateSnap(const gfx::Point& location);
-
- // Returns the type of snap based on the specified location.
- SnapType SnapTypeForLocation(const gfx::Point& location) const;
-
- // Returns the bounds of the resulting window for the specified type.
- gfx::Rect ScreenBoundsForType(SnapType type) const;
-
- // Snaps the window to the current snap position determined by |snap_type_|.
- void Snap();
-
- // Determine the maximize type of this window.
- MaximizeBubbleFrameState GetMaximizeBubbleFrameState() const;
-
- // Widget that the maximize button acts on. This is different than the widget
- // which contains the button in the case of AppNonClientFrameViewAsh.
- views::Widget* frame_;
-
- // True if we have put observers on |frame_|.
- bool observing_frame_;
-
- // Renders the snap position.
- scoped_ptr<PhantomWindowController> phantom_window_;
-
- // Is snapping enabled? Set on press so that in drag we know whether we
- // should show the snap locations.
- bool is_snap_enabled_;
-
- // Did the user drag far enough to trigger snapping?
- bool exceeded_drag_threshold_;
-
- // Location of the press.
- gfx::Point press_location_;
-
- // Current snap type.
- SnapType snap_type_;
-
- scoped_ptr<EscapeEventFilter> escape_event_filter_;
-
- base::OneShotTimer<FrameMaximizeButton> update_timer_;
-
- scoped_ptr<MaximizeBubbleController> maximizer_;
-
- // The delay of the bubble appearance.
- int bubble_appearance_delay_ms_;
-
- ObserverList<FrameMaximizeButtonObserver> observer_list_;
-
- DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
-};
-
-} // namespace ash
-
-#endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
diff --git a/ash/frame/caption_buttons/frame_maximize_button_observer.h b/ash/frame/caption_buttons/frame_maximize_button_observer.h
deleted file mode 100644
index 57bdd47..0000000
--- a/ash/frame/caption_buttons/frame_maximize_button_observer.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_
-#define ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_
-
-#include "ash/ash_export.h"
-
-namespace views {
-class Widget;
-}
-
-namespace ash {
-
-class ASH_EXPORT FrameMaximizeButtonObserver {
- public:
- virtual ~FrameMaximizeButtonObserver() {}
-
- // Called when the maximize button's help bubble is shown.
- virtual void OnMaximizeBubbleShown(views::Widget* bubble) = 0;
-};
-
-} // namespace ash
-
-#endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_
diff --git a/ash/frame/caption_buttons/frame_maximize_button_unittest.cc b/ash/frame/caption_buttons/frame_maximize_button_unittest.cc
deleted file mode 100644
index 06305d1..0000000
--- a/ash/frame/caption_buttons/frame_maximize_button_unittest.cc
+++ /dev/null
@@ -1,814 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
-
-#include "ash/ash_switches.h"
-#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
-#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/window_state.h"
-#include "ash/wm/window_util.h"
-#include "base/command_line.h"
-#include "grit/ash_resources.h"
-#include "ui/aura/client/focus_client.h"
-#include "ui/aura/test/event_generator.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/events/event_processor.h"
-#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_configuration.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_delegate.h"
-
-namespace ash {
-namespace test {
-
-namespace {
-
-class CancelCallbackHandler {
- public:
- CancelCallbackHandler(int update_events_before_cancel,
- FrameMaximizeButton* maximize_button) :
- update_events_before_cancel_(update_events_before_cancel),
- maximize_button_(maximize_button) {}
- virtual ~CancelCallbackHandler() {}
-
- void CountedCancelCallback(ui::EventType event_type,
- const gfx::Vector2dF& pos) {
- if (event_type == ui::ET_GESTURE_SCROLL_UPDATE &&
- !(--update_events_before_cancel_)) {
- // Make sure that we are in the middle of a resizing operation, cancel it
- // and then test that it is exited.
- EXPECT_TRUE(maximize_button_->is_snap_enabled());
- maximize_button_->DestroyMaximizeMenu();
- EXPECT_FALSE(maximize_button_->is_snap_enabled());
- }
- }
-
- private:
- // When this counter reaches 0, the gesture maximize action gets cancelled.
- int update_events_before_cancel_;
-
- // The maximize button which needs to get informed of the gesture termination.
- FrameMaximizeButton* maximize_button_;
-
- DISALLOW_COPY_AND_ASSIGN(CancelCallbackHandler);
-};
-
-class TestWidgetDelegate : public views::WidgetDelegateView {
- public:
- TestWidgetDelegate() {}
- virtual ~TestWidgetDelegate() {}
-
- // views::WidgetDelegate overrides:
- virtual views::View* GetContentsView() OVERRIDE {
- return this;
- }
- virtual bool CanResize() const OVERRIDE {
- return true;
- }
- virtual bool CanMaximize() const OVERRIDE {
- return true;
- }
-
- ash::FrameCaptionButtonContainerView* caption_button_container() {
- return caption_button_container_;
- }
-
- private:
- // Overridden from views::View:
- virtual void Layout() OVERRIDE {
- caption_button_container_->Layout();
-
- // Right align the caption button container.
- gfx::Size preferred_size = caption_button_container_->GetPreferredSize();
- caption_button_container_->SetBounds(width() - preferred_size.width(), 0,
- preferred_size.width(), preferred_size.height());
- }
-
- virtual void ViewHierarchyChanged(
- const ViewHierarchyChangedDetails& details) OVERRIDE {
- if (details.is_add && details.child == this) {
- caption_button_container_ = new FrameCaptionButtonContainerView(
- GetWidget(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
-
- // Set arbitrary images for the container's buttons so that the buttons
- // have non-empty sizes.
- for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) {
- caption_button_container_->SetButtonImages(
- static_cast<CaptionButtonIcon>(icon),
- IDR_AURA_WINDOW_CONTROL_ICON_CLOSE,
- IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_I,
- IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
- IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
- }
-
- AddChildView(caption_button_container_);
- }
- }
-
- // Not owned.
- ash::FrameCaptionButtonContainerView* caption_button_container_;
-
- DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate);
-};
-
-} // namespace
-
-class FrameMaximizeButtonTest : public ash::test::AshTestBase {
- public:
- FrameMaximizeButtonTest() {}
- virtual ~FrameMaximizeButtonTest() {}
-
- // The returned widget takes ownership of |delegate|.
- views::Widget* CreateWidget(views::WidgetDelegate* delegate) {
- views::Widget::InitParams params(
- views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- views::Widget* widget = new views::Widget;
- params.context = CurrentContext();
- params.delegate = delegate;
- params.bounds = gfx::Rect(10, 10, 100, 100);
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- widget->Init(params);
- widget->Show();
- return widget;
- }
-
- void CloseWidget() {
- if (widget_)
- widget_->CloseNow();
- widget_ = NULL;
- }
-
- virtual void SetUp() OVERRIDE {
- AshTestBase::SetUp();
-
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAshDisableAlternateFrameCaptionButtonStyle);
-
- TestWidgetDelegate* delegate = new TestWidgetDelegate();
- widget_ = CreateWidget(delegate);
- FrameCaptionButtonContainerView* caption_button_container =
- delegate->caption_button_container();
-
- FrameCaptionButtonContainerView::TestApi test(caption_button_container);
- maximize_button_ = static_cast<FrameMaximizeButton*>(
- test.size_button());
- }
-
- virtual void TearDown() OVERRIDE {
- CloseWidget();
- AshTestBase::TearDown();
- }
-
- views::Widget* widget() { return widget_; }
-
- FrameMaximizeButton* maximize_button() { return maximize_button_; }
-
- private:
- views::Widget* widget_;
- FrameMaximizeButton* maximize_button_;
-
- DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButtonTest);
-};
-
-// Tests that clicking on the resize-button toggles between maximize and normal
-// state.
-TEST_F(FrameMaximizeButtonTest, ResizeButtonToggleMaximize) {
- wm::WindowState* window_state =
- wm::GetWindowState(widget()->GetNativeWindow());
- views::View* view = maximize_button();
- gfx::Point center = view->GetBoundsInScreen().CenterPoint();
-
- aura::test::EventGenerator generator(
- window_state->window()->GetRootWindow(), center);
-
- EXPECT_FALSE(window_state->IsMaximized());
-
- generator.ClickLeftButton();
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(window_state->IsMaximized());
-
- center = view->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(center);
- generator.ClickLeftButton();
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(window_state->IsMaximized());
-
- generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(window_state->IsMaximized());
-
- generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(window_state->IsMaximized());
-
- generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(window_state->IsMaximized());
-
- generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
-#if defined(OS_WIN)
-// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
-#define MAYBE_ResizeButtonDrag DISABLED_ResizeButtonDrag
-#else
-#define MAYBE_ResizeButtonDrag ResizeButtonDrag
-#endif
-
-// Tests that click+dragging on the resize-button tiles or minimizes the window.
-TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
- aura::Window* window = widget()->GetNativeWindow();
- views::View* view = maximize_button();
- gfx::Point center = view->GetBoundsInScreen().CenterPoint();
-
- aura::test::EventGenerator generator(window->GetRootWindow(), center);
-
- wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_TRUE(window_state->IsNormalStateType());
-
- // Snap right.
- {
- generator.PressLeftButton();
- generator.MoveMouseBy(10, 0);
- generator.ReleaseLeftButton();
- RunAllPendingInMessageLoop();
-
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_FALSE(window_state->IsMinimized());
- EXPECT_EQ(wm::GetDefaultRightSnappedWindowBoundsInParent(window).ToString(),
- window->bounds().ToString());
- }
-
- // Snap left.
- {
- center = view->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(center);
- generator.PressLeftButton();
- generator.MoveMouseBy(-10, 0);
- generator.ReleaseLeftButton();
- RunAllPendingInMessageLoop();
-
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_FALSE(window_state->IsMinimized());
- EXPECT_EQ(wm::GetDefaultLeftSnappedWindowBoundsInParent(window).ToString(),
- window->bounds().ToString());
- }
-
- // Minimize.
- {
- center = view->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(center);
- generator.PressLeftButton();
- generator.MoveMouseBy(0, 10);
- generator.ReleaseLeftButton();
- RunAllPendingInMessageLoop();
-
- EXPECT_TRUE(window_state->IsMinimized());
- }
-
- window_state->Restore();
-
- // Now test the same behaviour for gesture events.
-
- // Snap right.
- {
- center = view->GetBoundsInScreen().CenterPoint();
- gfx::Point end = center;
- end.Offset(80, 0);
- generator.GestureScrollSequence(center, end,
- base::TimeDelta::FromMilliseconds(100),
- 3);
- RunAllPendingInMessageLoop();
-
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_FALSE(window_state->IsMinimized());
- // This is a short resizing distance and different touch behavior
- // applies which leads in half of the screen being used.
- EXPECT_EQ("400,0 400x553", window->bounds().ToString());
- }
-
- // Snap left.
- {
- center = view->GetBoundsInScreen().CenterPoint();
- gfx::Point end = center;
- end.Offset(-80, 0);
- generator.GestureScrollSequence(center, end,
- base::TimeDelta::FromMilliseconds(100),
- 3);
- RunAllPendingInMessageLoop();
-
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_FALSE(window_state->IsMinimized());
- EXPECT_EQ(wm::GetDefaultLeftSnappedWindowBoundsInParent(window).ToString(),
- window->bounds().ToString());
- }
-
- // Minimize.
- {
- center = view->GetBoundsInScreen().CenterPoint();
- gfx::Point end = center;
- end.Offset(0, 40);
- generator.GestureScrollSequence(center, end,
- base::TimeDelta::FromMilliseconds(100),
- 3);
- RunAllPendingInMessageLoop();
-
- EXPECT_TRUE(window_state->IsMinimized());
- }
-
- // Test with gesture events.
-}
-
-// Test that closing the (browser) window with an opened balloon does not
-// crash the system. In other words: Make sure that shutting down the frame
-// destroys the opened balloon in an orderly fashion.
-TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
-
- // Move the mouse cursor over the button to bring up the maximizer bubble.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Even though the widget is closing the bubble menu should not crash upon
- // its delayed destruction.
- CloseWidget();
-}
-
-// Test that maximizing the browser after hovering in does not crash the system
-// when the observer gets removed in the bubble destruction process.
-TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
-
- // Move the mouse cursor over the button to bring up the maximizer bubble.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
- generator.ClickLeftButton();
- EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized());
-}
-
-// Test that hovering over a button in the balloon dialog will show the phantom
-// window. Moving then away from the button will hide it again. Then check that
-// pressing and dragging the button itself off the button will also release the
-// phantom window.
-TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- // Move the mouse cursor over the button to bring up the maximizer bubble.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Move the mouse over the left maximize button.
- gfx::Point left_max_pos = maximize_button->maximizer()->
- GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
-
- generator.MoveMouseTo(left_max_pos);
- // Expect the phantom window to be open.
- EXPECT_TRUE(maximize_button->phantom_window_open());
-
- // Move away to see the window being destroyed.
- generator.MoveMouseTo(off_pos);
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- // Move back over the button.
- generator.MoveMouseTo(button_pos);
- generator.MoveMouseTo(left_max_pos);
- EXPECT_TRUE(maximize_button->phantom_window_open());
-
- // Press button and drag out of dialog.
- generator.PressLeftButton();
- generator.MoveMouseTo(off_pos);
- generator.ReleaseLeftButton();
-
- // Check that the phantom window is also gone.
- EXPECT_FALSE(maximize_button->phantom_window_open());
-}
-
-// Test that clicking a button in the maximizer bubble (in this case the
-// maximize left button) will do the requested action.
-TEST_F(FrameMaximizeButtonTest, MaximizeLeftByButton) {
- aura::Window* window = widget()->GetNativeWindow();
-
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- // Move the mouse cursor over the button to bring up the maximizer bubble.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Move the mouse over the left maximize button.
- gfx::Point left_max_pos = maximize_button->maximizer()->
- GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(left_max_pos);
- EXPECT_TRUE(maximize_button->phantom_window_open());
- generator.ClickLeftButton();
-
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_FALSE(window_state->IsMaximized());
- EXPECT_FALSE(window_state->IsMinimized());
- EXPECT_EQ(wm::GetDefaultLeftSnappedWindowBoundsInParent(window).ToString(),
- window->bounds().ToString());
-}
-
-// Test that the activation focus does not change when the bubble gets shown.
-TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
-
- aura::Window* active =
- aura::client::GetFocusClient(window)->GetFocusedWindow();
-
- // Move the mouse cursor over the button to bring up the maximizer bubble.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Check that the focused window is still the same.
- EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow());
-}
-
-TEST_F(FrameMaximizeButtonTest, MaximizeTap) {
- aura::Window* window = widget()->GetNativeWindow();
- aura::Window* root_window = window->GetRootWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
-
- const int touch_default_radius =
- ui::GestureConfiguration::default_radius();
- ui::GestureConfiguration::set_default_radius(0);
-
- ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
- const int kTouchId = 2;
- ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
- button_pos,
- kTouchId,
- ui::EventTimeForNow());
- ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press);
- ASSERT_FALSE(details.dispatcher_destroyed);
-
- button_pos.Offset(9, 8);
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED,
- button_pos,
- kTouchId,
- press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
- details = dispatcher->OnEventFromSource(&release);
- ASSERT_FALSE(details.dispatcher_destroyed);
-
- ui::GestureConfiguration::set_default_radius(touch_default_radius);
-}
-
-// Test that only the left button will activate the maximize button.
-TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_TRUE(window_state->IsNormalStateType());
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Move the mouse cursor over the button.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- // After pressing the left button the button should get triggered.
- generator.PressLeftButton();
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(maximize_button->is_snap_enabled());
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Pressing the right button then should cancel the operation.
- generator.PressRightButton();
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(maximize_button->maximizer());
-
- // After releasing the second button the window shouldn't be maximized.
- generator.ReleaseRightButton();
- generator.ReleaseLeftButton();
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Second experiment: Starting with right should also not trigger.
- generator.MoveMouseTo(off_pos);
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Pressing first the right button should not activate.
- generator.PressRightButton();
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(maximize_button->is_snap_enabled());
-
- // Pressing then additionally the left button shouldn't activate either.
- generator.PressLeftButton();
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(maximize_button->is_snap_enabled());
- generator.ReleaseRightButton();
- generator.ReleaseLeftButton();
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
-// Click a button of window maximize functionality.
-// If |snap_type| is SNAP_NONE the FrameMaximizeButton gets clicked, otherwise
-// the associated snap button.
-// |Window| is the window which owns the maximize button.
-// |maximize_button| is the FrameMaximizeButton which controls the window.
-void ClickMaxButton(
- ash::FrameMaximizeButton* maximize_button,
- aura::Window* window,
- SnapType snap_type) {
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- generator.MoveMouseTo(off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- // Move the mouse cursor over the button.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
- EXPECT_FALSE(maximize_button->phantom_window_open());
-
- if (snap_type != SNAP_NONE) {
- gfx::Point left_max_pos = maximize_button->maximizer()->
- GetButtonForUnitTest(snap_type)->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(left_max_pos);
- EXPECT_TRUE(maximize_button->phantom_window_open());
- }
- // After pressing the left button the button should get triggered.
- generator.ClickLeftButton();
- EXPECT_FALSE(maximize_button->maximizer());
-}
-
-// Test that the restore from left/right maximize is properly done.
-TEST_F(FrameMaximizeButtonTest, MaximizeLeftRestore) {
- aura::Window* window = widget()->GetNativeWindow();
- gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
-
- ClickMaxButton(maximize_button, window, SNAP_LEFT);
- wm::WindowState* window_state = wm::GetWindowState(window);
- // The window should not be maximized.
- EXPECT_FALSE(window_state->IsMaximized());
- // But the bounds should be different.
- gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
- EXPECT_EQ(0, new_bounds.x());
- EXPECT_EQ(0, new_bounds.y());
-
- // Now click the same button again to see that it restores.
- ClickMaxButton(maximize_button, window, SNAP_LEFT);
- // But the bounds should be restored.
- new_bounds = widget()->GetWindowBoundsInScreen();
- EXPECT_EQ(new_bounds.x(), initial_bounds.x());
- EXPECT_EQ(new_bounds.y(), initial_bounds.x());
- EXPECT_EQ(new_bounds.width(), initial_bounds.width());
- EXPECT_EQ(new_bounds.height(), initial_bounds.height());
- // Make sure that there is no restore rectangle left.
- EXPECT_FALSE(window_state->HasRestoreBounds());
-}
-
-// Maximize, left/right maximize and then restore should works.
-TEST_F(FrameMaximizeButtonTest, MaximizeMaximizeLeftRestore) {
- aura::Window* window = widget()->GetNativeWindow();
- gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
-
- ClickMaxButton(maximize_button, window, SNAP_NONE);
-
- wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_TRUE(window_state->IsMaximized());
-
- ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(window_state->IsMaximized());
- gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
- EXPECT_EQ(0, new_bounds.x());
- EXPECT_EQ(0, new_bounds.y());
-
- // Now click the same button again to see that it restores.
- ClickMaxButton(maximize_button, window, SNAP_LEFT);
- RunAllPendingInMessageLoop();
- // But the bounds should be restored.
- new_bounds = widget()->GetWindowBoundsInScreen();
- EXPECT_EQ(new_bounds.x(), initial_bounds.x());
- EXPECT_EQ(new_bounds.y(), initial_bounds.x());
- EXPECT_EQ(new_bounds.width(), initial_bounds.width());
- EXPECT_EQ(new_bounds.height(), initial_bounds.height());
- // Make sure that there is no restore rectangle left.
- EXPECT_FALSE(window_state->HasRestoreBounds());
-}
-
-// Left/right maximize, maximize and then restore should work.
-TEST_F(FrameMaximizeButtonTest, MaximizeSnapLeftRestore) {
- aura::Window* window = widget()->GetNativeWindow();
- gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
-
- ClickMaxButton(maximize_button, window, SNAP_LEFT);
-
- wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_FALSE(window_state->IsMaximized());
-
- ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(window_state->IsMaximized());
-
- ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_FALSE(window_state->IsMaximized());
- gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
- EXPECT_EQ(new_bounds.x(), initial_bounds.x());
- EXPECT_EQ(new_bounds.y(), initial_bounds.x());
- EXPECT_EQ(new_bounds.width(), initial_bounds.width());
- EXPECT_EQ(new_bounds.height(), initial_bounds.height());
- // Make sure that there is no restore rectangle left.
- EXPECT_FALSE(window_state->HasRestoreBounds());
-}
-
-// Test that minimizing the window per keyboard closes the maximize bubble.
-TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
-
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- generator.MoveMouseTo(off_pos);
- EXPECT_FALSE(maximize_button->maximizer());
-
- // Move the mouse cursor over the maximize button.
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // We simulate the keystroke by calling minimizeWindow directly.
- wm::WindowState* window_state = wm::GetWindowState(window);
- window_state->Minimize();
-
- EXPECT_TRUE(window_state->IsMinimized());
- EXPECT_FALSE(maximize_button->maximizer());
-}
-
-// Tests that dragging down on the maximize button minimizes the window.
-TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragDownMinimizes) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
-
- wm::WindowState* window_state = wm::GetWindowState(window);
- // Drag down on a maximized window.
- window_state->Maximize();
- EXPECT_TRUE(window_state->IsMaximized());
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x(), button_pos.y() + 100);
-
- aura::test::EventGenerator generator(window->GetRootWindow());
- generator.GestureScrollSequence(button_pos, off_pos,
- base::TimeDelta::FromMilliseconds(0), 1);
-
- EXPECT_TRUE(window_state->IsMinimized());
- EXPECT_FALSE(maximize_button->maximizer());
-
- // Drag down on a restored window.
- window_state->Restore();
-
- button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200);
- generator.GestureScrollSequence(button_pos, off_pos,
- base::TimeDelta::FromMilliseconds(10), 1);
- EXPECT_TRUE(window_state->IsMinimized());
- EXPECT_FALSE(maximize_button->maximizer());
-}
-
-// Tests that dragging Left and pressing ESC does properly abort.
-TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragLeftEscapeExits) {
- aura::Window* window = widget()->GetNativeWindow();
- gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
-
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() - button_pos.x() / 2, button_pos.y());
-
- const int kGestureSteps = 10;
- CancelCallbackHandler cancel_handler(kGestureSteps / 2, maximize_button);
- aura::test::EventGenerator generator(window->GetRootWindow());
- generator.GestureScrollSequenceWithCallback(
- button_pos,
- off_pos,
- base::TimeDelta::FromMilliseconds(0),
- kGestureSteps,
- base::Bind(&CancelCallbackHandler::CountedCancelCallback,
- base::Unretained(&cancel_handler)));
-
- // Check that there was no size change.
- EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(),
- initial_bounds.size().ToString());
- // Check that there is no phantom window left open.
- EXPECT_FALSE(maximize_button->phantom_window_open());
-}
-
-// Test that hovering over a button in the maximizer bubble and switching
-// activation without moving the mouse properly aborts.
-TEST_F(FrameMaximizeButtonTest, LossOfActivationWhileMaximizeBubbleOpenAborts) {
- aura::Window* window = widget()->GetNativeWindow();
- ash::FrameMaximizeButton* maximize_button =
- FrameMaximizeButtonTest::maximize_button();
- maximize_button->set_bubble_appearance_delay_ms(0);
-
- gfx::Rect initial_bounds = window->GetBoundsInScreen();
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
- EXPECT_TRUE(widget()->IsActive());
-
- // Move the mouse over the maximize button in order to bring up the maximizer
- // bubble.
- gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
- gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
- aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
- generator.MoveMouseTo(button_pos);
- EXPECT_TRUE(maximize_button->maximizer());
-
- // Hover the mouse over the left maximize button in the maximizer bubble to
- // show the phantom window.
- gfx::Point left_max_pos = maximize_button->maximizer()->
- GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
- generator.MoveMouseTo(left_max_pos);
- EXPECT_TRUE(maximize_button->phantom_window_open());
-
- // Change activation by creating a new window. This could be done via an
- // accelerator. The root window takes ownership of |just_created|.
- views::Widget* just_created = views::Widget::CreateWindowWithContextAndBounds(
- NULL, widget()->GetNativeWindow(), gfx::Rect(100, 100));
- just_created->Show();
- just_created->Activate();
- EXPECT_FALSE(widget()->IsActive());
-
- // Test that we have properly reset the state of the now inactive window.
- EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_FALSE(maximize_button->phantom_window_open());
- EXPECT_TRUE(wm::GetWindowState(window)->IsNormalStateType());
- EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString());
-}
-
-} // namespace test
-} // namespace ash
diff --git a/ash/frame/caption_buttons/maximize_bubble_controller.cc b/ash/frame/caption_buttons/maximize_bubble_controller.cc
deleted file mode 100644
index 9b353dd..0000000
--- a/ash/frame/caption_buttons/maximize_bubble_controller.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
-
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
-#include "ash/frame/caption_buttons/maximize_bubble_controller_bubble.h"
-#include "base/timer/timer.h"
-
-
-namespace ash {
-
-MaximizeBubbleController::MaximizeBubbleController(
- FrameMaximizeButton* frame_maximize_button,
- MaximizeBubbleFrameState maximize_type,
- int appearance_delay_ms)
- : frame_maximize_button_(frame_maximize_button),
- bubble_(NULL),
- maximize_type_(maximize_type),
- snap_type_for_creation_(SNAP_NONE),
- appearance_delay_ms_(appearance_delay_ms) {
- // Create the task which will create the bubble delayed.
- base::OneShotTimer<MaximizeBubbleController>* new_timer =
- new base::OneShotTimer<MaximizeBubbleController>();
- // Note: Even if there was no delay time given, we need to have a timer.
- new_timer->Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(
- appearance_delay_ms_ ? appearance_delay_ms_ : 10),
- this,
- &MaximizeBubbleController::CreateBubble);
- timer_.reset(new_timer);
- if (!appearance_delay_ms_)
- CreateBubble();
-}
-
-MaximizeBubbleController::~MaximizeBubbleController() {
- // Note: The destructor only gets initiated through the owner.
- timer_.reset();
- if (bubble_) {
- bubble_->ControllerRequestsCloseAndDelete();
- bubble_ = NULL;
- }
-}
-
-void MaximizeBubbleController::SetSnapType(SnapType snap_type) {
- if (bubble_) {
- bubble_->SetSnapType(snap_type);
- } else {
- // The bubble has not been created yet. This can occur if bubble creation is
- // delayed.
- snap_type_for_creation_ = snap_type;
- }
-}
-
-aura::Window* MaximizeBubbleController::GetBubbleWindow() {
- return bubble_ ? bubble_->GetBubbleWindow() : NULL;
-}
-
-void MaximizeBubbleController::DelayCreation() {
- if (timer_.get() && timer_->IsRunning())
- timer_->Reset();
-}
-
-void MaximizeBubbleController::OnButtonClicked(SnapType snap_type) {
- frame_maximize_button_->ExecuteSnapAndCloseMenu(snap_type);
-}
-
-void MaximizeBubbleController::OnButtonHover(SnapType snap_type) {
- frame_maximize_button_->SnapButtonHovered(snap_type);
-}
-
-views::CustomButton* MaximizeBubbleController::GetButtonForUnitTest(
- SnapType state) {
- return bubble_ ? bubble_->GetButtonForUnitTest(state) : NULL;
-}
-
-void MaximizeBubbleController::RequestDestructionThroughOwner() {
- // Tell the parent to destroy us (if this didn't happen yet).
- if (timer_) {
- timer_.reset(NULL);
- // Informs the owner that the menu is gone and requests |this| destruction.
- frame_maximize_button_->DestroyMaximizeMenu();
- // Note: After this call |this| is destroyed.
- }
-}
-
-void MaximizeBubbleController::CreateBubble() {
- if (!bubble_) {
- bubble_ = new MaximizeBubbleControllerBubble(this, appearance_delay_ms_,
- snap_type_for_creation_);
- frame_maximize_button_->OnMaximizeBubbleShown(bubble_->GetWidget());
- }
-
- timer_->Stop();
-}
-
-} // namespace ash
diff --git a/ash/frame/caption_buttons/maximize_bubble_controller.h b/ash/frame/caption_buttons/maximize_bubble_controller.h
deleted file mode 100644
index 4ed03b8..0000000
--- a/ash/frame/caption_buttons/maximize_bubble_controller.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_
-#define ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_
-
-#include "ash/ash_export.h"
-#include "ash/frame/caption_buttons/caption_button_types.h"
-#include "ash/wm/workspace/snap_types.h"
-#include "base/memory/scoped_ptr.h"
-
-namespace aura {
-class Window;
-}
-
-namespace base {
-class Timer;
-}
-
-namespace views {
-class CustomButton;
-}
-
-namespace ash {
-
-class FrameMaximizeButton;
-class MaximizeBubbleControllerBubble;
-
-// A class which shows a helper UI for the maximize button after a delay.
-class ASH_EXPORT MaximizeBubbleController {
- public:
- MaximizeBubbleController(FrameMaximizeButton* frame_maximize_button,
- MaximizeBubbleFrameState maximize_type,
- int appearance_delay_ms);
- // Called from the outside to destroy the interface to the UI visuals.
- // The visuals will then delete when possible (maybe asynchronously).
- virtual ~MaximizeBubbleController();
-
- // Update the UI visuals to reflect the previewed |snap_type| snapping state.
- void SetSnapType(SnapType snap_type);
-
- // To achieve proper Z-sorting with the snap animation, this window will be
- // presented above the phantom window.
- aura::Window* GetBubbleWindow();
-
- // Reset the delay of the menu creation (if it was not created yet).
- void DelayCreation();
-
- // Called to tell the owning FrameMaximizeButton that a button was clicked.
- void OnButtonClicked(SnapType snap_type);
-
- // Called to tell the the owning FrameMaximizeButton that the hover status
- // for a button has changed. |snap_type| can be either SNAP_LEFT, SNAP_RIGHT,
- // SNAP_MINIMIZE or SNAP_NONE.
- void OnButtonHover(SnapType snap_type);
-
- // Get the owning FrameMaximizeButton.
- FrameMaximizeButton* frame_maximize_button() {
- return frame_maximize_button_;
- }
-
- // The status of the associated window: Maximized or normal.
- MaximizeBubbleFrameState maximize_type() const { return maximize_type_; }
-
- // A unit test function to return buttons of the sub menu. |state| can be
- // either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
- // Called from the the Bubble class to destroy itself: It tells the owning
- // object that it will destroy itself asynchronously. The owner will then
- // destroy |this|.
- void RequestDestructionThroughOwner();
-
- private:
- // The function which creates the bubble once the delay is elapsed.
- void CreateBubble();
-
- // The owning button which is also the anchor for the menu.
- FrameMaximizeButton* frame_maximize_button_;
-
- // The bubble menu.
- MaximizeBubbleControllerBubble* bubble_;
-
- // The current maximize state of the owning window.
- const MaximizeBubbleFrameState maximize_type_;
-
- // The snap type with which the bubble is created. This is needed because the
- // creation of the bubble can be delayed and SetSnapType() may be called
- // before the bubble is created.
- SnapType snap_type_for_creation_;
-
- // The timer for the delayed creation of the menu.
- scoped_ptr<base::Timer> timer_;
-
- // The appearance delay in ms (delay and fade in & fade out delay).
- const int appearance_delay_ms_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleController);
-};
-
-} // namespace ash
-
-#endif // ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_
diff --git a/ash/frame/caption_buttons/maximize_bubble_controller_bubble.cc b/ash/frame/caption_buttons/maximize_bubble_controller_bubble.cc
deleted file mode 100644
index e8188cd..0000000
--- a/ash/frame/caption_buttons/maximize_bubble_controller_bubble.cc
+++ /dev/null
@@ -1,510 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/frame/caption_buttons/maximize_bubble_controller_bubble.h"
-
-#include "ash/frame/caption_buttons/bubble_contents_button_row.h"
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
-#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
-#include "ash/metrics/user_metrics_recorder.h"
-#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
-#include "grit/ash_strings.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/path.h"
-#include "ui/views/bubble/bubble_frame_view.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/layout/box_layout.h"
-#include "ui/views/mouse_watcher.h"
-#include "ui/wm/core/masked_window_targeter.h"
-
-namespace ash {
-
-// BubbleContentsView ---------------------------------------------------------
-
-// A class which creates the content of the bubble: The buttons, and the label.
-class BubbleContentsView : public views::View {
- public:
- BubbleContentsView(MaximizeBubbleControllerBubble* bubble,
- SnapType initial_snap_type);
- virtual ~BubbleContentsView();
-
- // Set the label content to reflect the currently selected |snap_type|.
- // This function can be executed through the frame maximize button as well as
- // through hover operations.
- void SetSnapType(SnapType snap_type);
-
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
- private:
- // The owning class.
- MaximizeBubbleControllerBubble* bubble_;
-
- // The object which owns all the buttons.
- BubbleContentsButtonRow* buttons_view_;
-
- // The label object which shows the user the selected action.
- views::Label* label_view_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleContentsView);
-};
-
-BubbleContentsView::BubbleContentsView(
- MaximizeBubbleControllerBubble* bubble,
- SnapType initial_snap_type)
- : bubble_(bubble),
- buttons_view_(NULL),
- label_view_(NULL) {
- SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kVertical, 0, 0,
- MaximizeBubbleControllerBubble::kLayoutSpacing));
- set_background(views::Background::CreateSolidBackground(
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor));
-
- buttons_view_ = new BubbleContentsButtonRow(bubble);
- AddChildView(buttons_view_);
-
- label_view_ = new views::Label();
- SetSnapType(initial_snap_type);
- label_view_->SetBackgroundColor(
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
- const SkColor kBubbleTextColor = SK_ColorWHITE;
- label_view_->SetEnabledColor(kBubbleTextColor);
- const int kLabelSpacing = 4;
- label_view_->SetBorder(
- views::Border::CreateEmptyBorder(kLabelSpacing, 0, kLabelSpacing, 0));
- AddChildView(label_view_);
-}
-
-BubbleContentsView::~BubbleContentsView() {
-}
-
-// Set the label content to reflect the currently selected |snap_type|.
-// This function can be executed through the frame maximize button as well as
-// through hover operations.
-void BubbleContentsView::SetSnapType(SnapType snap_type) {
- if (!bubble_->controller())
- return;
-
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- int id = 0;
- switch (snap_type) {
- case SNAP_LEFT:
- id = IDS_ASH_SNAP_WINDOW_LEFT;
- break;
- case SNAP_RIGHT:
- id = IDS_ASH_SNAP_WINDOW_RIGHT;
- break;
- case SNAP_MAXIMIZE:
- DCHECK_NE(FRAME_STATE_FULL, bubble_->controller()->maximize_type());
- id = IDS_ASH_MAXIMIZE_WINDOW;
- break;
- case SNAP_MINIMIZE:
- id = IDS_ASH_MINIMIZE_WINDOW;
- break;
- case SNAP_RESTORE:
- DCHECK_NE(FRAME_STATE_NONE, bubble_->controller()->maximize_type());
- id = IDS_ASH_RESTORE_WINDOW;
- break;
- default:
- // If nothing is selected, we automatically select the click operation.
- id = bubble_->controller()->maximize_type() == FRAME_STATE_FULL ?
- IDS_ASH_RESTORE_WINDOW : IDS_ASH_MAXIMIZE_WINDOW;
- break;
- }
- label_view_->SetText(rb.GetLocalizedString(id));
-}
-
-views::CustomButton* BubbleContentsView::GetButtonForUnitTest(SnapType state) {
- return buttons_view_->GetButtonForUnitTest(state);
-}
-
-
-// MaximizeBubbleBorder -------------------------------------------------------
-
-namespace {
-
-const int kLineWidth = 1;
-const int kArrowHeight = 10;
-const int kArrowWidth = 20;
-
-} // namespace
-
-class MaximizeBubbleBorder : public views::BubbleBorder {
- public:
- MaximizeBubbleBorder(views::View* content_view, views::View* anchor);
-
- virtual ~MaximizeBubbleBorder() {}
-
- // Get the mouse active area of the window.
- void GetMask(gfx::Path* mask);
-
- // views::BubbleBorder:
- virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
- const gfx::Size& contents_size) const OVERRIDE;
- virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE;
- virtual gfx::Size GetMinimumSize() const OVERRIDE;
-
- private:
- // Note: Animations can continue after then main window frame was destroyed.
- // To avoid this problem, the owning screen metrics get extracted upon
- // creation.
- gfx::Size anchor_size_;
- gfx::Point anchor_screen_origin_;
- views::View* content_view_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleBorder);
-};
-
-MaximizeBubbleBorder::MaximizeBubbleBorder(views::View* content_view,
- views::View* anchor)
- : views::BubbleBorder(
- views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::NO_SHADOW,
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor),
- anchor_size_(anchor->size()),
- anchor_screen_origin_(0, 0),
- content_view_(content_view) {
- views::View::ConvertPointToScreen(anchor, &anchor_screen_origin_);
- set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
-}
-
-void MaximizeBubbleBorder::GetMask(gfx::Path* mask) {
- gfx::Insets inset = GetInsets();
- // Note: Even though the tip could be added as activatable, it is left out
- // since it would not change the action behavior in any way plus it makes
- // more sense to keep the focus on the underlying button for clicks.
- int left = inset.left() - kLineWidth;
- int right = inset.left() + content_view_->width() + kLineWidth;
- int top = inset.top() - kLineWidth;
- int bottom = inset.top() + content_view_->height() + kLineWidth;
- mask->moveTo(left, top);
- mask->lineTo(right, top);
- mask->lineTo(right, bottom);
- mask->lineTo(left, bottom);
- mask->lineTo(left, top);
- mask->close();
-}
-
-gfx::Rect MaximizeBubbleBorder::GetBounds(
- const gfx::Rect& position_relative_to,
- const gfx::Size& contents_size) const {
- gfx::Size border_size(contents_size);
- gfx::Insets insets = GetInsets();
- border_size.Enlarge(insets.width(), insets.height());
-
- // Position the bubble to center the box on the anchor.
- int x = (anchor_size_.width() - border_size.width()) / 2;
- // Position the bubble under the anchor, overlapping the arrow with it.
- int y = anchor_size_.height() - insets.top();
-
- gfx::Point view_origin(x + anchor_screen_origin_.x(),
- y + anchor_screen_origin_.y());
-
- return gfx::Rect(view_origin, border_size);
-}
-
-void MaximizeBubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
- gfx::Insets inset = GetInsets();
-
- // Draw the border line around everything.
- int y = inset.top();
- // Top
- canvas->FillRect(gfx::Rect(inset.left(),
- y - kLineWidth,
- content_view_->width(),
- kLineWidth),
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
- // Bottom
- canvas->FillRect(gfx::Rect(inset.left(),
- y + content_view_->height(),
- content_view_->width(),
- kLineWidth),
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
- // Left
- canvas->FillRect(gfx::Rect(inset.left() - kLineWidth,
- y - kLineWidth,
- kLineWidth,
- content_view_->height() + 2 * kLineWidth),
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
- // Right
- canvas->FillRect(gfx::Rect(inset.left() + content_view_->width(),
- y - kLineWidth,
- kLineWidth,
- content_view_->height() + 2 * kLineWidth),
- MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
-
- // Draw the arrow afterwards covering the border.
- SkPath path;
- path.incReserve(4);
- // The center of the tip should be in the middle of the button.
- int tip_x = inset.left() + content_view_->width() / 2;
- int left_base_x = tip_x - kArrowWidth / 2;
- int left_base_y = y;
- int tip_y = left_base_y - kArrowHeight;
- path.moveTo(SkIntToScalar(left_base_x), SkIntToScalar(left_base_y));
- path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
- path.lineTo(SkIntToScalar(left_base_x + kArrowWidth),
- SkIntToScalar(left_base_y));
-
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(MaximizeBubbleControllerBubble::kBubbleBackgroundColor);
- canvas->DrawPath(path, paint);
-}
-
-gfx::Size MaximizeBubbleBorder::GetMinimumSize() const {
- return gfx::Size(kLineWidth * 2 + kArrowWidth,
- std::max(kLineWidth, kArrowHeight) + kLineWidth);
-}
-
-namespace {
-
-// MaximizebubbleTargeter -----------------------------------------------------
-
-// Window targeter used for the bubble.
-class MaximizeBubbleTargeter : public ::wm::MaskedWindowTargeter {
- public:
- MaximizeBubbleTargeter(aura::Window* window,
- MaximizeBubbleBorder* border)
- : ::wm::MaskedWindowTargeter(window),
- border_(border) {
- }
-
- virtual ~MaximizeBubbleTargeter() {}
-
- private:
- // ::wm::MaskedWindowTargeter:
- virtual bool GetHitTestMask(aura::Window* window,
- gfx::Path* mask) const OVERRIDE {
- border_->GetMask(mask);
- return true;
- }
-
- MaximizeBubbleBorder* border_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleTargeter);
-};
-
-} // namespace
-
-
-// BubbleMouseWatcherHost -----------------------------------------------------
-
-// The mouse watcher host which makes sure that the bubble does not get closed
-// while the mouse cursor is over the maximize button or the balloon content.
-// Note: This object gets destroyed when the MouseWatcher gets destroyed.
-class BubbleMouseWatcherHost: public views::MouseWatcherHost {
- public:
- explicit BubbleMouseWatcherHost(MaximizeBubbleControllerBubble* bubble);
- virtual ~BubbleMouseWatcherHost();
-
- // views::MouseWatcherHost:
- virtual bool Contains(const gfx::Point& screen_point,
- views::MouseWatcherHost::MouseEventType type) OVERRIDE;
- private:
- MaximizeBubbleControllerBubble* bubble_;
-
- DISALLOW_COPY_AND_ASSIGN(BubbleMouseWatcherHost);
-};
-
-BubbleMouseWatcherHost::BubbleMouseWatcherHost(
- MaximizeBubbleControllerBubble* bubble)
- : bubble_(bubble) {
-}
-
-BubbleMouseWatcherHost::~BubbleMouseWatcherHost() {
-}
-
-bool BubbleMouseWatcherHost::Contains(
- const gfx::Point& screen_point,
- views::MouseWatcherHost::MouseEventType type) {
- return bubble_->Contains(screen_point, type);
-}
-
-
-// MaximizeBubbleControllerBubble ---------------------------------------------
-
-// static
-const SkColor MaximizeBubbleControllerBubble::kBubbleBackgroundColor =
- 0xFF141414;
-const int MaximizeBubbleControllerBubble::kLayoutSpacing = -1;
-
-MaximizeBubbleControllerBubble::MaximizeBubbleControllerBubble(
- MaximizeBubbleController* owner,
- int appearance_delay_ms,
- SnapType initial_snap_type)
- : views::BubbleDelegateView(owner->frame_maximize_button(),
- views::BubbleBorder::TOP_RIGHT),
- shutting_down_(false),
- owner_(owner),
- contents_view_(NULL),
- bubble_border_(NULL),
- appearance_delay_ms_(appearance_delay_ms) {
- set_margins(gfx::Insets());
-
- // The window needs to be owned by the root so that the phantom window does
- // not cover it upon animation.
- aura::Window* parent = Shell::GetContainer(Shell::GetTargetRootWindow(),
- kShellWindowId_ShelfContainer);
- set_parent_window(parent);
-
- set_notify_enter_exit_on_child(true);
- set_adjust_if_offscreen(false);
- SetPaintToLayer(true);
- set_color(kBubbleBackgroundColor);
- set_close_on_deactivate(false);
- set_background(
- views::Background::CreateSolidBackground(kBubbleBackgroundColor));
-
- SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kVertical, 0, 0, kLayoutSpacing));
-
- contents_view_ = new BubbleContentsView(this, initial_snap_type);
- AddChildView(contents_view_);
-
- // Note that the returned widget has an observer which points to our
- // functions.
- views::Widget* bubble_widget = views::BubbleDelegateView::CreateBubble(this);
- bubble_widget->set_focus_on_creation(false);
-
- SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
- bubble_widget->non_client_view()->frame_view()->set_background(NULL);
-
- bubble_border_ = new MaximizeBubbleBorder(this, GetAnchorView());
- GetBubbleFrameView()->SetBubbleBorder(
- scoped_ptr<views::BubbleBorder>(bubble_border_));
- GetBubbleFrameView()->set_background(NULL);
-
- // Recalculate size with new border.
- SizeToContents();
-
- GetWidget()->Show();
-
- aura::Window* window = bubble_widget->GetNativeWindow();
- window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
- new MaximizeBubbleTargeter(window, bubble_border_)));
-
- ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_SHOW_BUBBLE);
-
- mouse_watcher_.reset(new views::MouseWatcher(
- new BubbleMouseWatcherHost(this),
- this));
- mouse_watcher_->Start();
-}
-
-MaximizeBubbleControllerBubble::~MaximizeBubbleControllerBubble() {
-}
-
-aura::Window* MaximizeBubbleControllerBubble::GetBubbleWindow() {
- return GetWidget()->GetNativeWindow();
-}
-
-gfx::Rect MaximizeBubbleControllerBubble::GetAnchorRect() {
- if (!owner_)
- return gfx::Rect();
-
- gfx::Rect anchor_rect =
- owner_->frame_maximize_button()->GetBoundsInScreen();
- return anchor_rect;
-}
-
-bool MaximizeBubbleControllerBubble::CanActivate() const {
- return false;
-}
-
-bool MaximizeBubbleControllerBubble::WidgetHasHitTestMask() const {
- return bubble_border_ != NULL;
-}
-
-void MaximizeBubbleControllerBubble::GetWidgetHitTestMask(
- gfx::Path* mask) const {
- DCHECK(mask);
- DCHECK(bubble_border_);
- bubble_border_->GetMask(mask);
-}
-
-void MaximizeBubbleControllerBubble::MouseMovedOutOfHost() {
- if (!owner_ || shutting_down_)
- return;
- // When we leave the bubble, we might be still be in gesture mode or over
- // the maximize button. So only close if none of the other cases apply.
- if (!owner_->frame_maximize_button()->is_snap_enabled()) {
- gfx::Point screen_location = Shell::GetScreen()->GetCursorScreenPoint();
- if (!owner_->frame_maximize_button()->GetBoundsInScreen().Contains(
- screen_location)) {
- owner_->RequestDestructionThroughOwner();
- }
- }
-}
-
-bool MaximizeBubbleControllerBubble::Contains(
- const gfx::Point& screen_point,
- views::MouseWatcherHost::MouseEventType type) {
- if (!owner_ || shutting_down_)
- return false;
- bool inside_button =
- owner_->frame_maximize_button()->GetBoundsInScreen().Contains(
- screen_point);
- if (!owner_->frame_maximize_button()->is_snap_enabled() && inside_button) {
- SetSnapType(controller()->maximize_type() == FRAME_STATE_FULL ?
- SNAP_RESTORE : SNAP_MAXIMIZE);
- return true;
- }
- // Check if either a gesture is taking place (=> bubble stays no matter what
- // the mouse does) or the mouse is over the maximize button or the bubble
- // content.
- return (owner_->frame_maximize_button()->is_snap_enabled() ||
- inside_button ||
- contents_view_->GetBoundsInScreen().Contains(screen_point));
-}
-
-gfx::Size MaximizeBubbleControllerBubble::GetPreferredSize() {
- return contents_view_->GetPreferredSize();
-}
-
-void MaximizeBubbleControllerBubble::OnWidgetDestroying(views::Widget* widget) {
- if (GetWidget() == widget) {
- mouse_watcher_->Stop();
-
- if (owner_) {
- // If the bubble destruction was triggered by some other external
- // influence then ourselves, the owner needs to be informed that the menu
- // is gone.
- shutting_down_ = true;
- owner_->RequestDestructionThroughOwner();
- owner_ = NULL;
- }
- }
- BubbleDelegateView::OnWidgetDestroying(widget);
-}
-
-void MaximizeBubbleControllerBubble::ControllerRequestsCloseAndDelete() {
- // This only gets called from the owning base class once it is deleted.
- if (shutting_down_)
- return;
- shutting_down_ = true;
- owner_ = NULL;
-
- // Close the widget asynchronously after the hide animation is finished.
- if (!appearance_delay_ms_)
- GetWidget()->CloseNow();
- else
- GetWidget()->Close();
-}
-
-void MaximizeBubbleControllerBubble::SetSnapType(SnapType snap_type) {
- if (contents_view_)
- contents_view_->SetSnapType(snap_type);
-}
-
-views::CustomButton* MaximizeBubbleControllerBubble::GetButtonForUnitTest(
- SnapType state) {
- return contents_view_->GetButtonForUnitTest(state);
-}
-
-} // namespace ash
diff --git a/ash/frame/caption_buttons/maximize_bubble_controller_bubble.h b/ash/frame/caption_buttons/maximize_bubble_controller_bubble.h
deleted file mode 100644
index f2e25d6..0000000
--- a/ash/frame/caption_buttons/maximize_bubble_controller_bubble.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_
-#define ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_
-
-#include "ash/wm/workspace/snap_types.h"
-#include "ui/views/bubble/bubble_delegate.h"
-#include "ui/views/mouse_watcher.h"
-
-namespace views {
-class CustomButton;
-}
-
-namespace ash {
-
-class BubbleContentsView;
-class MaximizeBubbleBorder;
-class MaximizeBubbleController;
-
-// The class which creates and manages the bubble menu element.
-// It creates a 'bubble border' and the content accordingly.
-// Note: Since the phantom window will show animations on top of the maximize
-// button this menu gets created as a separate window and the phantom window
-// will be created underneath this window.
-class MaximizeBubbleControllerBubble : public views::BubbleDelegateView,
- public views::MouseWatcherListener {
- public:
- static const SkColor kBubbleBackgroundColor;
- static const int kLayoutSpacing; // The spacing between two buttons.
-
- MaximizeBubbleControllerBubble(MaximizeBubbleController* owner,
- int appearance_delay_ms,
- SnapType initial_snap_type);
- virtual ~MaximizeBubbleControllerBubble();
-
- // The window of the menu under which the phantom window will get created.
- aura::Window* GetBubbleWindow();
-
- // Overridden from views::BubbleDelegateView.
- virtual gfx::Rect GetAnchorRect() OVERRIDE;
- virtual bool CanActivate() const OVERRIDE;
-
- // Overridden from views::WidgetDelegateView.
- virtual bool WidgetHasHitTestMask() const OVERRIDE;
- virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
-
- // Implementation of MouseWatcherListener.
- virtual void MouseMovedOutOfHost() OVERRIDE;
-
- // Implementation of MouseWatcherHost.
- virtual bool Contains(const gfx::Point& screen_point,
- views::MouseWatcherHost::MouseEventType type);
-
- // Overridden from views::View.
- virtual gfx::Size GetPreferredSize() OVERRIDE;
-
- // Overridden from views::Widget::Observer.
- virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
-
- // Called from the controller class to indicate that the menu should get
- // destroyed.
- virtual void ControllerRequestsCloseAndDelete();
-
- // Called from the owning class to change the menu content to the given
- // |snap_type| so that the user knows what is selected.
- void SetSnapType(SnapType snap_type);
-
- // Get the owning MaximizeBubbleController. This might return NULL in case
- // of an asynchronous shutdown.
- MaximizeBubbleController* controller() const { return owner_; }
-
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
- private:
- // True if the shut down has been initiated.
- bool shutting_down_;
-
- // Our owning class.
- MaximizeBubbleController* owner_;
-
- // The content accessor of the menu.
- BubbleContentsView* contents_view_;
-
- // The bubble border (weak reference).
- MaximizeBubbleBorder* bubble_border_;
-
- // The mouse watcher which takes care of out of window hover events.
- scoped_ptr<views::MouseWatcher> mouse_watcher_;
-
- // The fade delay - if 0 it will show / hide immediately.
- const int appearance_delay_ms_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleControllerBubble);
-};
-
-} // namespace ash
-
-#endif // ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_
diff --git a/ash/frame/custom_frame_view_ash.cc b/ash/frame/custom_frame_view_ash.cc
index 8ab7e23..68bc36a 100644
--- a/ash/frame/custom_frame_view_ash.cc
+++ b/ash/frame/custom_frame_view_ash.cc
@@ -6,8 +6,6 @@
#include "ash/ash_switches.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/frame/caption_buttons/frame_maximize_button.h"
-#include "ash/frame/caption_buttons/frame_maximize_button_observer.h"
#include "ash/frame/default_header_painter.h"
#include "ash/frame/frame_border_hit_test_controller.h"
#include "ash/frame/frame_util.h"
@@ -32,7 +30,6 @@
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
-#include "ui/views/widget/widget_deletion_observer.h"
namespace {
@@ -127,7 +124,6 @@ namespace ash {
class CustomFrameViewAsh::HeaderView
: public views::View,
public ImmersiveFullscreenController::Delegate,
- public FrameMaximizeButtonObserver,
public ShellObserver {
public:
// |frame| is the widget that the caption buttons act on.
@@ -175,9 +171,6 @@ class CustomFrameViewAsh::HeaderView
virtual void SetVisibleFraction(double visible_fraction) OVERRIDE;
virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE;
- // FrameMaximizeButtonObserver:
- virtual void OnMaximizeBubbleShown(views::Widget* bubble) OVERRIDE;
-
// The widget that the caption buttons act on.
views::Widget* frame_;
@@ -189,13 +182,6 @@ class CustomFrameViewAsh::HeaderView
// View which contains the window caption buttons.
FrameCaptionButtonContainerView* caption_button_container_;
- // The maximize bubble widget. |maximize_bubble_| may be non-NULL but have
- // been already destroyed.
- views::Widget* maximize_bubble_;
-
- // Keeps track of whether |maximize_bubble_| is still alive.
- scoped_ptr<views::WidgetDeletionObserver> maximize_bubble_lifetime_observer_;
-
// The fraction of the header's height which is visible while in fullscreen.
// This value is meaningless when not in fullscreen.
double fullscreen_visible_fraction_;
@@ -208,7 +194,6 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
header_painter_(new ash::DefaultHeaderPainter),
avatar_icon_(NULL),
caption_button_container_(NULL),
- maximize_bubble_(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.
@@ -221,10 +206,6 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
caption_button_container_->UpdateSizeButtonVisibility(Shell::GetInstance()->
IsMaximizeModeWindowManagerEnabled());
AddChildView(caption_button_container_);
- FrameMaximizeButton* frame_maximize_button =
- caption_button_container_->GetOldStyleSizeButton();
- if (frame_maximize_button)
- frame_maximize_button->AddObserver(this);
header_painter_->Init(frame_, this, NULL, caption_button_container_);
UpdateAvatarIcon();
@@ -233,10 +214,6 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
}
CustomFrameViewAsh::HeaderView::~HeaderView() {
- FrameMaximizeButton* frame_maximize_button =
- caption_button_container_->GetOldStyleSizeButton();
- if (frame_maximize_button)
- frame_maximize_button->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
}
@@ -361,24 +338,10 @@ CustomFrameViewAsh::HeaderView::GetVisibleBoundsInScreen() const {
std::vector<gfx::Rect> bounds_in_screen;
bounds_in_screen.push_back(
gfx::Rect(visible_origin_in_screen, visible_bounds.size()));
- if (maximize_bubble_lifetime_observer_.get() &&
- maximize_bubble_lifetime_observer_->IsWidgetAlive()) {
- bounds_in_screen.push_back(maximize_bubble_->GetWindowBoundsInScreen());
- }
return bounds_in_screen;
}
///////////////////////////////////////////////////////////////////////////////
-// CustomFrameViewAsh::HeaderView, FrameMaximizeButtonObserver overrides:
-
-void CustomFrameViewAsh::HeaderView::OnMaximizeBubbleShown(
- views::Widget* bubble) {
- maximize_bubble_ = bubble;
- maximize_bubble_lifetime_observer_.reset(
- new views::WidgetDeletionObserver(bubble));
-}
-
-///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::OverlayView
// View which takes up the entire widget and contains the HeaderView. HeaderView
diff --git a/ash/metrics/user_metrics_recorder.cc b/ash/metrics/user_metrics_recorder.cc
index a71271b..a44cc78 100644
--- a/ash/metrics/user_metrics_recorder.cc
+++ b/ash/metrics/user_metrics_recorder.cc
@@ -357,24 +357,12 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE:
base::RecordAction(base::UserMetricsAction("MinButton_Clk"));
break;
- case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE:
- base::RecordAction(base::UserMetricsAction("MaxButton_Maximize"));
- break;
case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT:
base::RecordAction(base::UserMetricsAction("MaxButton_MaxLeft"));
break;
case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT:
base::RecordAction(base::UserMetricsAction("MaxButton_MaxRight"));
break;
- case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE:
- base::RecordAction(base::UserMetricsAction("MaxButton_Minimize"));
- break;
- case ash::UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE:
- base::RecordAction(base::UserMetricsAction("MaxButton_Restore"));
- break;
- case ash::UMA_WINDOW_MAXIMIZE_BUTTON_SHOW_BUBBLE:
- base::RecordAction(base::UserMetricsAction("MaxButton_ShowBubble"));
- break;
case ash::UMA_WINDOW_OVERVIEW:
base::RecordAction(
base::UserMetricsAction("WindowSelector_Overview"));
diff --git a/ash/metrics/user_metrics_recorder.h b/ash/metrics/user_metrics_recorder.h
index 618b70f..98eb652 100644
--- a/ash/metrics/user_metrics_recorder.h
+++ b/ash/metrics/user_metrics_recorder.h
@@ -97,12 +97,8 @@ enum UserMetricsAction {
UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MAXIMIZE,
UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE,
UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_RESTORE,
- UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE,
UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT,
UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT,
- UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE,
- UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE,
- UMA_WINDOW_MAXIMIZE_BUTTON_SHOW_BUBBLE,
// Thumbnail sized overview of windows triggered. This is a subset of
// UMA_WINDOW_SELECTION triggered by lingering during alt+tab cycles or
diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd
index aabbc18..825cadedc 100644
--- a/ash/resources/ash_resources.grd
+++ b/ash/resources/ash_resources.grd
@@ -241,21 +241,6 @@
<structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_OVERVIEW_CLOSE_H" file="common/window_overview_close_hover.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_OVERVIEW_CLOSE_P" file="common/window_overview_close_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT" file="common/window_position_left_normal.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT_H" file="common/window_position_left_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT_P" file="common/window_position_left_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_MIDDLE" file="common/window_position_middle_normal.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_MIDDLE_H" file="common/window_position_middle_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_MIDDLE_P" file="common/window_position_middle_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT" file="common/window_position_right_normal.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT_H" file="common/window_position_right_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT_P" file="common/window_position_right_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT_RESTORE" file="common/window_position_left_normal_restore.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT_RESTORE_H" file="common/window_position_left_hover_restore.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_LEFT_RESTORE_P" file="common/window_position_left_pressed_restore.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE" file="common/window_position_right_normal_restore.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE_H" file="common/window_position_right_hover_restore.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_WINDOW_POSITION_RIGHT_RESTORE_P" file="common/window_position_right_pressed_restore.png" />
<structure type="chrome_scaled_image" name="IDR_AVATAR_HOLDER" file="cros/avatar_holder.png" />
<structure type="chrome_scaled_image" name="IDR_AVATAR_HOLDER_MASK" file="cros/avatar_holder_mask.png" />
</structures>
diff --git a/ash/resources/default_100_percent/common/window_position_left_hover.png b/ash/resources/default_100_percent/common/window_position_left_hover.png
deleted file mode 100644
index 420d392..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_left_hover_restore.png b/ash/resources/default_100_percent/common/window_position_left_hover_restore.png
deleted file mode 100644
index f94002b..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_hover_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_left_normal.png b/ash/resources/default_100_percent/common/window_position_left_normal.png
deleted file mode 100644
index c082951..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_left_normal_restore.png b/ash/resources/default_100_percent/common/window_position_left_normal_restore.png
deleted file mode 100644
index 67312ab..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_normal_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_left_pressed.png b/ash/resources/default_100_percent/common/window_position_left_pressed.png
deleted file mode 100644
index 4201d2a..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_left_pressed_restore.png b/ash/resources/default_100_percent/common/window_position_left_pressed_restore.png
deleted file mode 100644
index 8841553..0000000
--- a/ash/resources/default_100_percent/common/window_position_left_pressed_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_middle_hover.png b/ash/resources/default_100_percent/common/window_position_middle_hover.png
deleted file mode 100644
index aaff1c5..0000000
--- a/ash/resources/default_100_percent/common/window_position_middle_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_middle_normal.png b/ash/resources/default_100_percent/common/window_position_middle_normal.png
deleted file mode 100644
index 090b669..0000000
--- a/ash/resources/default_100_percent/common/window_position_middle_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_middle_pressed.png b/ash/resources/default_100_percent/common/window_position_middle_pressed.png
deleted file mode 100644
index 66d29b0..0000000
--- a/ash/resources/default_100_percent/common/window_position_middle_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_hover.png b/ash/resources/default_100_percent/common/window_position_right_hover.png
deleted file mode 100644
index e424d95..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_hover_restore.png b/ash/resources/default_100_percent/common/window_position_right_hover_restore.png
deleted file mode 100644
index 7583d26..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_hover_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_normal.png b/ash/resources/default_100_percent/common/window_position_right_normal.png
deleted file mode 100644
index d2c4479..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_normal_restore.png b/ash/resources/default_100_percent/common/window_position_right_normal_restore.png
deleted file mode 100644
index 9da0761..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_normal_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_pressed.png b/ash/resources/default_100_percent/common/window_position_right_pressed.png
deleted file mode 100644
index 7fa9303..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/common/window_position_right_pressed_restore.png b/ash/resources/default_100_percent/common/window_position_right_pressed_restore.png
deleted file mode 100644
index 790ee0e..0000000
--- a/ash/resources/default_100_percent/common/window_position_right_pressed_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_hover.png b/ash/resources/default_200_percent/common/window_position_left_hover.png
deleted file mode 100644
index 4d79bb2..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_hover_restore.png b/ash/resources/default_200_percent/common/window_position_left_hover_restore.png
deleted file mode 100644
index 61c5387..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_hover_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_normal.png b/ash/resources/default_200_percent/common/window_position_left_normal.png
deleted file mode 100644
index 58e21b9..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_normal_restore.png b/ash/resources/default_200_percent/common/window_position_left_normal_restore.png
deleted file mode 100644
index bba0ff4..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_normal_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_pressed.png b/ash/resources/default_200_percent/common/window_position_left_pressed.png
deleted file mode 100644
index b7fae089..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_left_pressed_restore.png b/ash/resources/default_200_percent/common/window_position_left_pressed_restore.png
deleted file mode 100644
index 0f9e0c9..0000000
--- a/ash/resources/default_200_percent/common/window_position_left_pressed_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_middle_hover.png b/ash/resources/default_200_percent/common/window_position_middle_hover.png
deleted file mode 100644
index fe65289..0000000
--- a/ash/resources/default_200_percent/common/window_position_middle_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_middle_normal.png b/ash/resources/default_200_percent/common/window_position_middle_normal.png
deleted file mode 100644
index 0cda265..0000000
--- a/ash/resources/default_200_percent/common/window_position_middle_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_middle_pressed.png b/ash/resources/default_200_percent/common/window_position_middle_pressed.png
deleted file mode 100644
index f664867..0000000
--- a/ash/resources/default_200_percent/common/window_position_middle_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_hover.png b/ash/resources/default_200_percent/common/window_position_right_hover.png
deleted file mode 100644
index e31c729..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_hover.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_hover_restore.png b/ash/resources/default_200_percent/common/window_position_right_hover_restore.png
deleted file mode 100644
index e5a5be3..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_hover_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_normal.png b/ash/resources/default_200_percent/common/window_position_right_normal.png
deleted file mode 100644
index 1a8e7a2..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_normal.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_normal_restore.png b/ash/resources/default_200_percent/common/window_position_right_normal_restore.png
deleted file mode 100644
index 3cf2d4b..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_normal_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_pressed.png b/ash/resources/default_200_percent/common/window_position_right_pressed.png
deleted file mode 100644
index b5e5336..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_pressed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/common/window_position_right_pressed_restore.png b/ash/resources/default_200_percent/common/window_position_right_pressed_restore.png
deleted file mode 100644
index 62bb151..0000000
--- a/ash/resources/default_200_percent/common/window_position_right_pressed_restore.png
+++ /dev/null
Binary files differ
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index daddd1f..ab738ea 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -590,8 +590,9 @@ DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const {
return DOCKED_ALIGNMENT_NONE;
}
-bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window,
- SnapType edge) {
+bool DockedWindowLayoutManager::CanDockWindow(
+ aura::Window* window,
+ DockedAlignment desired_alignment) {
if (!switches::UseDockedWindows())
return false;
// Don't allow interactive docking of windows with transient parents such as
@@ -622,16 +623,19 @@ bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window,
return false;
// Cannot dock on the other size from an existing dock.
const DockedAlignment alignment = CalculateAlignment();
- if ((edge == SNAP_LEFT && alignment == DOCKED_ALIGNMENT_RIGHT) ||
- (edge == SNAP_RIGHT && alignment == DOCKED_ALIGNMENT_LEFT)) {
+ if (desired_alignment != DOCKED_ALIGNMENT_NONE &&
+ alignment != DOCKED_ALIGNMENT_NONE &&
+ alignment != desired_alignment) {
return false;
}
// Do not allow docking on the same side as shelf.
ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM;
if (shelf_)
shelf_alignment = shelf_->alignment();
- if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) ||
- (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) {
+ if ((desired_alignment == DOCKED_ALIGNMENT_LEFT &&
+ shelf_alignment == SHELF_ALIGNMENT_LEFT) ||
+ (desired_alignment == DOCKED_ALIGNMENT_RIGHT &&
+ shelf_alignment == SHELF_ALIGNMENT_RIGHT)) {
return false;
}
return true;
@@ -943,7 +947,7 @@ void DockedWindowLayoutManager::RestoreDockedWindow(
const gfx::Rect work_area = display.work_area();
// Evict the window if it can no longer be docked because of its height.
- if (!CanDockWindow(window, SNAP_NONE)) {
+ if (!CanDockWindow(window, DOCKED_ALIGNMENT_NONE)) {
UndockWindow(window);
RecordUmaAction(DOCKED_ACTION_EVICT, DOCKED_ACTION_SOURCE_UNKNOWN);
return;
diff --git a/ash/wm/dock/docked_window_layout_manager.h b/ash/wm/dock/docked_window_layout_manager.h
index 030d888..9a362a4 100644
--- a/ash/wm/dock/docked_window_layout_manager.h
+++ b/ash/wm/dock/docked_window_layout_manager.h
@@ -11,7 +11,6 @@
#include "ash/wm/dock/dock_types.h"
#include "ash/wm/dock/docked_window_layout_manager_observer.h"
#include "ash/wm/window_state_observer.h"
-#include "ash/wm/workspace/snap_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
@@ -119,7 +118,7 @@ class ASH_EXPORT DockedWindowLayoutManager
// Returns true when a window can be docked. Windows cannot be docked at the
// edge used by the shelf or the edge opposite from existing dock.
- bool CanDockWindow(aura::Window* window, SnapType edge);
+ bool CanDockWindow(aura::Window* window, DockedAlignment desired_alignment);
aura::Window* dock_container() const { return dock_container_; }
diff --git a/ash/wm/workspace/phantom_window_controller.cc b/ash/wm/workspace/phantom_window_controller.cc
index ba95423..23121c0c 100644
--- a/ash/wm/workspace/phantom_window_controller.cc
+++ b/ash/wm/workspace/phantom_window_controller.cc
@@ -6,18 +6,13 @@
#include <math.h>
-#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "grit/ash_resources.h"
-#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/skia_util.h"
#include "ui/views/background.h"
#include "ui/views/painter.h"
#include "ui/views/view.h"
@@ -30,32 +25,27 @@ namespace {
const int kAnimationDurationMs = 200;
// The size of the phantom window at the beginning of the show animation in
-// relation to the size of the phantom window at the end of the animation when
-// using the alternate caption button style.
-const float kAlternateStyleStartBoundsRatio = 0.85f;
+// relation to the size of the phantom window at the end of the animation.
+const float kStartBoundsRatio = 0.85f;
// The amount of pixels that the phantom window's shadow should extend past
-// the bounds passed into Show(). There is no shadow when not using the
-// alternate caption button style.
-const int kAlternateStyleShadowThickness = 15;
+// the bounds passed into Show().
+const int kShadowThickness = 15;
-// The minimum size of a phantom window including the shadow when using the
-// alternate caption button style. The minimum size is derived from the size of
-// the IDR_AURA_PHANTOM_WINDOW image assets.
-const int kAlternateStyleMinSizeWithShadow = 100;
+// The minimum size of a phantom window including the shadow. The minimum size
+// is derived from the size of the IDR_AURA_PHANTOM_WINDOW image assets.
+const int kMinSizeWithShadow = 100;
// Adjusts the phantom window's bounds so that the bounds:
// - Include the size of the shadow.
-// - Have a size equal to or larger than the minimize phantom window size.
-gfx::Rect GetAdjustedBoundsForAlternateStyle(const gfx::Rect& bounds) {
+// - Have a size equal to or larger than the minimum phantom window size.
+gfx::Rect GetAdjustedBounds(const gfx::Rect& bounds) {
int x_inset = std::max(
- static_cast<int>(
- ceil((kAlternateStyleMinSizeWithShadow - bounds.width()) / 2.0f)),
- kAlternateStyleShadowThickness);
+ static_cast<int>(ceil((kMinSizeWithShadow - bounds.width()) / 2.0f)),
+ kShadowThickness);
int y_inset = std::max(
- static_cast<int>(
- ceil((kAlternateStyleMinSizeWithShadow - bounds.height()) / 2.0f)),
- kAlternateStyleShadowThickness);
+ static_cast<int>(ceil((kMinSizeWithShadow - bounds.height()) / 2.0f)),
+ kShadowThickness);
gfx::Rect adjusted_bounds(bounds);
adjusted_bounds.Inset(-x_inset, -y_inset);
@@ -79,161 +69,38 @@ void AnimateToBounds(views::Widget* widget,
widget->SetBounds(new_bounds_in_screen);
}
-// EdgePainter ----------------------------------------------------------------
-
-// Paints the background of the phantom window for window snapping.
-class EdgePainter : public views::Painter {
- public:
- EdgePainter();
- virtual ~EdgePainter();
-
- // views::Painter:
- virtual gfx::Size GetMinimumSize() const OVERRIDE;
- virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(EdgePainter);
-};
-
-EdgePainter::EdgePainter() {
-}
-
-EdgePainter::~EdgePainter() {
-}
-
-gfx::Size EdgePainter::GetMinimumSize() const {
- return gfx::Size();
-}
-
-void EdgePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
- const int kInsetSize = 4;
- int x = kInsetSize;
- int y = kInsetSize;
- int w = size.width() - kInsetSize * 2;
- int h = size.height() - kInsetSize * 2;
- bool inset = (w > 0 && h > 0);
- if (!inset) {
- x = 0;
- y = 0;
- w = size.width();
- h = size.height();
- }
- SkPaint paint;
- paint.setColor(SkColorSetARGB(100, 0, 0, 0));
- paint.setStyle(SkPaint::kFill_Style);
- paint.setAntiAlias(true);
- const int kRoundRectSize = 4;
- canvas->sk_canvas()->drawRoundRect(
- gfx::RectToSkRect(gfx::Rect(x, y, w, h)),
- SkIntToScalar(kRoundRectSize), SkIntToScalar(kRoundRectSize), paint);
- if (!inset)
- return;
-
- paint.setColor(SkColorSetARGB(200, 255, 255, 255));
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(SkIntToScalar(2));
- canvas->sk_canvas()->drawRoundRect(
- gfx::RectToSkRect(gfx::Rect(x, y, w, h)), SkIntToScalar(kRoundRectSize),
- SkIntToScalar(kRoundRectSize), paint);
-}
-
} // namespace
// PhantomWindowController ----------------------------------------------------
PhantomWindowController::PhantomWindowController(aura::Window* window)
- : window_(window),
- phantom_below_window_(NULL) {
+ : window_(window) {
}
PhantomWindowController::~PhantomWindowController() {
}
void PhantomWindowController::Show(const gfx::Rect& bounds_in_screen) {
- if (switches::UseAlternateFrameCaptionButtonStyle())
- ShowAlternate(bounds_in_screen);
- else
- ShowLegacy(bounds_in_screen);
-}
-
-void PhantomWindowController::ShowAlternate(const gfx::Rect& bounds_in_screen) {
- gfx::Rect adjusted_bounds_in_screen =
- GetAdjustedBoundsForAlternateStyle(bounds_in_screen);
+ gfx::Rect adjusted_bounds_in_screen = GetAdjustedBounds(bounds_in_screen);
if (adjusted_bounds_in_screen == target_bounds_in_screen_)
return;
target_bounds_in_screen_ = adjusted_bounds_in_screen;
gfx::Rect start_bounds_in_screen = target_bounds_in_screen_;
int start_width = std::max(
- kAlternateStyleMinSizeWithShadow,
- static_cast<int>(
- start_bounds_in_screen.width() * kAlternateStyleStartBoundsRatio));
+ kMinSizeWithShadow,
+ static_cast<int>(start_bounds_in_screen.width() * kStartBoundsRatio));
int start_height = std::max(
- kAlternateStyleMinSizeWithShadow,
- static_cast<int>(
- start_bounds_in_screen.height() * kAlternateStyleStartBoundsRatio));
+ kMinSizeWithShadow,
+ static_cast<int>(start_bounds_in_screen.height() * kStartBoundsRatio));
start_bounds_in_screen.Inset(
floor((start_bounds_in_screen.width() - start_width) / 2.0f),
floor((start_bounds_in_screen.height() - start_height) / 2.0f));
- phantom_widget_in_target_root_ = CreatePhantomWidget(
+ phantom_widget_ = CreatePhantomWidget(
wm::GetRootWindowMatching(target_bounds_in_screen_),
start_bounds_in_screen);
- AnimateToBounds(phantom_widget_in_target_root_.get(),
- target_bounds_in_screen_);
-}
-
-void PhantomWindowController::ShowLegacy(const gfx::Rect& bounds_in_screen) {
- if (bounds_in_screen == target_bounds_in_screen_)
- return;
- target_bounds_in_screen_ = bounds_in_screen;
-
- gfx::Rect start_bounds_in_screen;
- if (!phantom_widget_in_target_root_) {
- start_bounds_in_screen = window_->GetBoundsInScreen();
- } else {
- start_bounds_in_screen =
- phantom_widget_in_target_root_->GetWindowBoundsInScreen();
- }
-
- aura::Window* target_root =
- wm::GetRootWindowMatching(target_bounds_in_screen_);
- if (!phantom_widget_in_target_root_ ||
- phantom_widget_in_target_root_->GetNativeWindow()->GetRootWindow() !=
- target_root) {
- phantom_widget_in_target_root_ =
- CreatePhantomWidget(target_root, start_bounds_in_screen);
- }
- AnimateToBounds(phantom_widget_in_target_root_.get(),
- target_bounds_in_screen_);
-
- // Create a secondary widget in a second screen if |start_bounds_in_screen|
- // lies at least partially in another screen. This allows animations to start
- // or restart in one root window and progress to another root.
- aura::Window* start_root = wm::GetRootWindowMatching(start_bounds_in_screen);
- if (start_root == target_root) {
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
- for (size_t i = 0; i < root_windows.size(); ++i) {
- if (root_windows[i] != target_root &&
- root_windows[i]->GetBoundsInScreen().Intersects(
- start_bounds_in_screen)) {
- start_root = root_windows[i];
- break;
- }
- }
- }
- if (start_root == target_root) {
- phantom_widget_in_start_root_.reset();
- } else {
- if (!phantom_widget_in_start_root_ ||
- phantom_widget_in_start_root_->GetNativeWindow()->GetRootWindow() !=
- start_root) {
- phantom_widget_in_start_root_ =
- CreatePhantomWidget(start_root, start_bounds_in_screen);
- }
- AnimateToBounds(phantom_widget_in_start_root_.get(),
- target_bounds_in_screen_);
- }
+ AnimateToBounds(phantom_widget_.get(), target_bounds_in_screen_);
}
scoped_ptr<views::Widget> PhantomWindowController::CreatePhantomWidget(
@@ -256,18 +123,11 @@ scoped_ptr<views::Widget> PhantomWindowController::CreatePhantomWidget(
phantom_widget->GetNativeWindow()->SetName("PhantomWindow");
phantom_widget->GetNativeWindow()->set_id(kShellWindowId_PhantomWindow);
phantom_widget->SetBounds(bounds_in_screen);
- if (phantom_below_window_)
- phantom_widget->StackBelow(phantom_below_window_);
- else
- phantom_widget->StackAbove(window_);
+ phantom_widget->StackAbove(window_);
- views::Painter* background_painter = NULL;
- if (switches::UseAlternateFrameCaptionButtonStyle()) {
- const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW);
- background_painter = views::Painter::CreateImageGridPainter(kImages);
- } else {
- background_painter = new EdgePainter;
- }
+ const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW);
+ views::Painter* background_painter =
+ views::Painter::CreateImageGridPainter(kImages);
views::View* content_view = new views::View;
content_view->set_background(
views::Background::CreateBackgroundPainter(true, background_painter));
diff --git a/ash/wm/workspace/phantom_window_controller.h b/ash/wm/workspace/phantom_window_controller.h
index d62b135..11d6f95 100644
--- a/ash/wm/workspace/phantom_window_controller.h
+++ b/ash/wm/workspace/phantom_window_controller.h
@@ -30,52 +30,27 @@ class ASH_EXPORT PhantomWindowController {
// Hides the phantom window without any animation.
virtual ~PhantomWindowController();
- // Animates the phantom window towards |bounds_in_screen|. The animation used
- // depends on whether the alternate caption button style is used.
+ // Shows the phantom window and animates shrinking it to |bounds_in_screen|.
void Show(const gfx::Rect& bounds_in_screen);
- // If set, the phantom window is stacked below this window, otherwise it
- // is stacked above the window passed to the constructor.
- void set_phantom_below_window(aura::Window* phantom_below_window) {
- phantom_below_window_ = phantom_below_window;
- }
-
private:
friend class PhantomWindowControllerTest;
- // Animates the phantom window towards |bounds_in_screen| when the alternate
- // caption button style is used.
- void ShowAlternate(const gfx::Rect& bounds_in_screen);
-
- // Animates the phantom window towards |bounds_in_screen| when the legacy
- // caption button style is used.
- void ShowLegacy(const gfx::Rect& bounds_in_screen);
-
// Creates, shows and returns a phantom widget at |bounds|
// with kShellWindowId_ShelfContainer in |root_window| as a parent.
scoped_ptr<views::Widget> CreatePhantomWidget(
aura::Window* root_window,
const gfx::Rect& bounds_in_screen);
- // Window the phantom is placed beneath.
+ // Window that the phantom window is stacked above.
aura::Window* window_;
- // If set, the phantom window should get stacked below this window.
- aura::Window* phantom_below_window_;
-
// Target bounds (including the shadows if any) of the animation in screen
// coordinates.
gfx::Rect target_bounds_in_screen_;
- // Phantom representation of the window which is in the root window matching
- // |target_bounds_in_screen_|.
- scoped_ptr<views::Widget> phantom_widget_in_target_root_;
-
- // Phantom representation of the window which is in the root window matching
- // the window's initial bounds. This allows animations to progress from one
- // display to the other. NULL if the phantom window starts and ends in the
- // same root window. Not used when using the alternate caption button style.
- scoped_ptr<views::Widget> phantom_widget_in_start_root_;
+ // Phantom representation of the window.
+ scoped_ptr<views::Widget> phantom_widget_;
DISALLOW_COPY_AND_ASSIGN(PhantomWindowController);
};
diff --git a/ash/wm/workspace/phantom_window_controller_unittest.cc b/ash/wm/workspace/phantom_window_controller_unittest.cc
deleted file mode 100644
index fa637d8..0000000
--- a/ash/wm/workspace/phantom_window_controller_unittest.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/wm/workspace/phantom_window_controller.h"
-
-#include "ash/ash_switches.h"
-#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
-#include "base/command_line.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/aura/window_observer.h"
-#include "ui/views/widget/widget.h"
-
-namespace ash {
-namespace {
-
-// Returns true if |window| is non-NULL and is visible.
-bool IsVisible(aura::Window* window) {
- return window && window->IsVisible();
-}
-
-// Observes |window|'s deletion.
-class WindowDeletionObserver : public aura::WindowObserver {
- public:
- WindowDeletionObserver(aura::Window* window) : window_(window) {
- window_->AddObserver(this);
- }
-
- virtual ~WindowDeletionObserver() {
- if (window_)
- window_->RemoveObserver(this);
- }
-
- // Returns true if the window has not been deleted yet.
- bool IsWindowAlive() {
- return !!window_;
- }
-
- // aura::WindowObserver:
- virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
- window_->RemoveObserver(this);
- window_ = NULL;
- }
-
- private:
- aura::Window* window_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowDeletionObserver);
-};
-
-} // namespace
-
-class PhantomWindowControllerTest : public ash::test::AshTestBase {
- public:
- PhantomWindowControllerTest() {
- }
- virtual ~PhantomWindowControllerTest() {
- }
-
- // ash::test::AshTestBase:
- virtual void SetUp() OVERRIDE {
- ash::test::AshTestBase::SetUp();
-
- window_ = CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 50, 60));
- controller_.reset(new PhantomWindowController(window_));
- }
-
- void DeleteController() {
- controller_.reset();
- }
-
- PhantomWindowController* controller() {
- return controller_.get();
- }
-
- aura::Window* window() { return window_; }
-
- aura::Window* phantom_window_in_target_root() {
- return controller_->phantom_widget_in_target_root_ ?
- controller_->phantom_widget_in_target_root_->GetNativeView() :
- NULL;
- }
-
- aura::Window* phantom_window_in_start_root() {
- return controller_->phantom_widget_in_start_root_ ?
- controller_->phantom_widget_in_start_root_->GetNativeView() :
- NULL;
- }
-
- private:
- aura::Window* window_;
- scoped_ptr<PhantomWindowController> controller_;
-
- DISALLOW_COPY_AND_ASSIGN(PhantomWindowControllerTest);
-};
-
-// Test that two phantom windows are used when animating to bounds at least
-// partially in another display when using the old caption button style.
-TEST_F(PhantomWindowControllerTest, OldCaptionButtonStyle) {
- if (!SupportsMultipleDisplays())
- return;
-
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAshDisableAlternateFrameCaptionButtonStyle);
- ASSERT_FALSE(switches::UseAlternateFrameCaptionButtonStyle());
-
- UpdateDisplay("500x400,500x400");
-
- aura::Window::Windows root_windows = Shell::GetAllRootWindows();
- EXPECT_EQ(root_windows[0], window()->GetRootWindow());
-
- // Phantom preview only in the left screen.
- controller()->Show(gfx::Rect(100, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_FALSE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[0], phantom_window_in_target_root()->GetRootWindow());
-
- // Move phantom preview into the right screen. Test that 2 windows got
- // created.
- controller()->Show(gfx::Rect(600, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_TRUE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[1], phantom_window_in_target_root()->GetRootWindow());
- EXPECT_EQ(root_windows[0], phantom_window_in_start_root()->GetRootWindow());
-
- // Move phantom preview only in the right screen. Start window should close.
- controller()->Show(gfx::Rect(700, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_FALSE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[1], phantom_window_in_target_root()->GetRootWindow());
-
- // Move phantom preview into the left screen. Start window should open.
- controller()->Show(gfx::Rect(100, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_TRUE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[0], phantom_window_in_target_root()->GetRootWindow());
- EXPECT_EQ(root_windows[1], phantom_window_in_start_root()->GetRootWindow());
-
- // Move phantom preview while in the left screen. Start window should close.
- controller()->Show(gfx::Rect(200, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_FALSE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[0], phantom_window_in_target_root()->GetRootWindow());
-
- // Move phantom preview spanning both screens with most of the preview in the
- // right screen. Two windows are created.
- controller()->Show(gfx::Rect(495, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_TRUE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[1], phantom_window_in_target_root()->GetRootWindow());
- EXPECT_EQ(root_windows[0], phantom_window_in_start_root()->GetRootWindow());
-
- // Move phantom preview back into the left screen. Phantom windows should
- // swap.
- controller()->Show(gfx::Rect(200, 100, 50, 60));
- EXPECT_TRUE(IsVisible(phantom_window_in_target_root()));
- EXPECT_TRUE(IsVisible(phantom_window_in_start_root()));
- EXPECT_EQ(root_windows[0], phantom_window_in_target_root()->GetRootWindow());
- EXPECT_EQ(root_windows[1], phantom_window_in_start_root()->GetRootWindow());
-
- // Destroy phantom controller. Both windows should close.
- WindowDeletionObserver target_deletion_observer(
- phantom_window_in_target_root());
- WindowDeletionObserver start_deletion_observer(
- phantom_window_in_start_root());
- DeleteController();
- EXPECT_FALSE(target_deletion_observer.IsWindowAlive());
- EXPECT_FALSE(start_deletion_observer.IsWindowAlive());
-}
-
-} // namespace ash
diff --git a/ash/wm/workspace/snap_types.h b/ash/wm/workspace/snap_types.h
deleted file mode 100644
index 482a7dd..0000000
--- a/ash/wm/workspace/snap_types.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_WM_WORKSPACE_SNAP_TYPES_H_
-#define ASH_WM_WORKSPACE_SNAP_TYPES_H_
-
-namespace ash {
-
-// These are the window snap types which can be used for window resizing.
-// Their main use case is the class FrameMaximizeButton.
-enum SnapType {
- SNAP_LEFT,
- SNAP_RIGHT,
- SNAP_MAXIMIZE,
- SNAP_MINIMIZE,
- SNAP_RESTORE,
- SNAP_NONE
-};
-
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_SNAP_TYPES_H_
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 75fedaa..def6ee8 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -911,7 +911,11 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
}
}
- const bool can_dock = dock_layout_->CanDockWindow(GetTarget(), snap_type_) &&
+ DCHECK(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT);
+ DockedAlignment desired_alignment = (snap_type_ == SNAP_LEFT) ?
+ DOCKED_ALIGNMENT_LEFT : DOCKED_ALIGNMENT_RIGHT;
+ const bool can_dock =
+ dock_layout_->CanDockWindow(GetTarget(), desired_alignment) &&
dock_layout_->GetAlignmentOfWindow(GetTarget()) != DOCKED_ALIGNMENT_NONE;
if (!can_dock) {
// If the window cannot be docked, undock the window. This may change the
@@ -990,7 +994,7 @@ void WorkspaceWindowResizer::RestackWindows() {
}
}
-SnapType WorkspaceWindowResizer::GetSnapType(
+WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType(
const gfx::Point& location) const {
// TODO: this likely only wants total display area, not the area of a single
// display.
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index d7d57d087..99a2df5 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -9,7 +9,6 @@
#include "ash/wm/window_resizer.h"
#include "ash/wm/workspace/magnetism_matcher.h"
-#include "ash/wm/workspace/snap_types.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
@@ -69,6 +68,13 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
private:
friend class WorkspaceWindowResizerTest;
+ // The edge to which the window should be snapped at the end of the drag.
+ enum SnapType {
+ SNAP_LEFT,
+ SNAP_RIGHT,
+ SNAP_NONE
+ };
+
// Lays out the attached windows. |bounds| is the bounds of the main window.
void LayoutAttachedWindows(gfx::Rect* bounds);
@@ -144,8 +150,9 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// top of the z-order, and the rest directly underneath it.
void RestackWindows();
- // Returns the SnapType for the specified point. SNAP_NONE is used if no
- // snapping should be used.
+ // Returns the edge to which the window should be snapped to if the user does
+ // no more dragging. SNAP_NONE is returned if the window should not be
+ // snapped.
SnapType GetSnapType(const gfx::Point& location) const;
// Returns true if |bounds_in_parent| are valid bounds for snapped state type
@@ -186,7 +193,7 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// the user drags a window to the edge of the screen.
scoped_ptr<TwoStepEdgeCycler> edge_cycler_;
- // Last SnapType.
+ // The edge to which the window should be snapped to at the end of the drag.
SnapType snap_type_;
// Number of mouse moves since the last bounds change. Only used for phantom
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c85a57a..b7dc7e5 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5977,12 +5977,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
Disable user gesture requirement for playing media elements. Activating this will allow autoplay to work.
</message>
<if expr="use_ash">
- <message name="IDS_FLAGS_ASH_FRAME_CAPTION_BUTTON_STYLE_NAME" desc="Title for the flag for the alternate frame caption button style.">
- Alternate frame caption button style
- </message>
- <message name="IDS_FLAGS_ASH_FRAME_CAPTION_BUTTON_STYLE_DESCRIPTION" desc="Description for the flag for the alternate frame caption button style.">
- Enables an experimental visual style for the frame caption buttons (minimize, maximize, close).
- </message>
<message name="IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_NAME" desc="Title for the flag which can be used to test the TouchView maximizing mode.">
Enable TouchView maximizing UI for testing
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 3f0db3e..fc66aa9 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1042,14 +1042,6 @@ const Experiment kExperiments[] = {
kOsAll,
SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
},
- { "ash-alternate-caption-button",
- IDS_FLAGS_ASH_FRAME_CAPTION_BUTTON_STYLE_NAME,
- IDS_FLAGS_ASH_FRAME_CAPTION_BUTTON_STYLE_DESCRIPTION,
- kOsCrOS,
- ENABLE_DISABLE_VALUE_TYPE(
- ash::switches::kAshEnableAlternateFrameCaptionButtonStyle,
- ash::switches::kAshDisableAlternateFrameCaptionButtonStyle),
- },
{ "ash-enable-touch-view-testing",
IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_NAME,
IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_DESCRIPTION,