| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/caption_buttons/frame_maximize_button.h" | 5 #include "ash/wm/caption_buttons/frame_maximize_button.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
| 12 #include "ash/touch/touch_uma.h" | 12 #include "ash/touch/touch_uma.h" |
| 13 #include "ash/wm/caption_buttons/frame_maximize_button_observer.h" |
| 13 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" | 14 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" |
| 14 #include "ash/wm/window_animations.h" | 15 #include "ash/wm/window_animations.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/workspace/phantom_window_controller.h" | 17 #include "ash/wm/workspace/phantom_window_controller.h" |
| 17 #include "ash/wm/workspace/snap_sizer.h" | 18 #include "ash/wm/workspace/snap_sizer.h" |
| 18 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
| 19 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 | 96 |
| 96 FrameMaximizeButton::~FrameMaximizeButton() { | 97 FrameMaximizeButton::~FrameMaximizeButton() { |
| 97 // Before the window gets destroyed, the maximizer dialog needs to be shut | 98 // Before the window gets destroyed, the maximizer dialog needs to be shut |
| 98 // down since it would otherwise call into a deleted object. | 99 // down since it would otherwise call into a deleted object. |
| 99 maximizer_.reset(); | 100 maximizer_.reset(); |
| 100 if (observing_frame_) | 101 if (observing_frame_) |
| 101 OnWindowDestroying(frame_->GetNativeWindow()); | 102 OnWindowDestroying(frame_->GetNativeWindow()); |
| 102 } | 103 } |
| 103 | 104 |
| 105 void FrameMaximizeButton::AddObserver(FrameMaximizeButtonObserver* observer) { |
| 106 observer_list_.AddObserver(observer); |
| 107 } |
| 108 |
| 109 void FrameMaximizeButton::RemoveObserver( |
| 110 FrameMaximizeButtonObserver* observer) { |
| 111 observer_list_.RemoveObserver(observer); |
| 112 } |
| 113 |
| 104 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { | 114 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { |
| 105 // Make sure to only show hover operations when no button is pressed and | 115 // Make sure to only show hover operations when no button is pressed and |
| 106 // a similar snap operation in progress does not get re-applied. | 116 // a similar snap operation in progress does not get re-applied. |
| 107 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_)) | 117 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_)) |
| 108 return; | 118 return; |
| 109 // Prime the mouse location with the center of the (local) button. | 119 // Prime the mouse location with the center of the (local) button. |
| 110 press_location_ = gfx::Point(width() / 2, height() / 2); | 120 press_location_ = gfx::Point(width() / 2, height() / 2); |
| 111 // Then get an adjusted mouse position to initiate the effect. | 121 // Then get an adjusted mouse position to initiate the effect. |
| 112 gfx::Point location = press_location_; | 122 gfx::Point location = press_location_; |
| 113 switch (type) { | 123 switch (type) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 Cancel(true); | 160 Cancel(true); |
| 151 // Tell our menu to close. | 161 // Tell our menu to close. |
| 152 maximizer_.reset(); | 162 maximizer_.reset(); |
| 153 snap_type_ = snap_type; | 163 snap_type_ = snap_type; |
| 154 // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed, | 164 // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed, |
| 155 // The ownership of the snap_sizer is taken now. | 165 // The ownership of the snap_sizer is taken now. |
| 156 scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release()); | 166 scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release()); |
| 157 Snap(snap_sizer.get()); | 167 Snap(snap_sizer.get()); |
| 158 } | 168 } |
| 159 | 169 |
| 170 void FrameMaximizeButton::OnMaximizeBubbleShown(views::Widget* bubble) { |
| 171 FOR_EACH_OBSERVER(FrameMaximizeButtonObserver, |
| 172 observer_list_, |
| 173 OnMaximizeBubbleShown(bubble)); |
| 174 } |
| 175 |
| 160 void FrameMaximizeButton::DestroyMaximizeMenu() { | 176 void FrameMaximizeButton::DestroyMaximizeMenu() { |
| 161 Cancel(false); | 177 Cancel(false); |
| 162 } | 178 } |
| 163 | 179 |
| 164 void FrameMaximizeButton::OnWindowBoundsChanged( | 180 void FrameMaximizeButton::OnWindowBoundsChanged( |
| 165 aura::Window* window, | 181 aura::Window* window, |
| 166 const gfx::Rect& old_bounds, | 182 const gfx::Rect& old_bounds, |
| 167 const gfx::Rect& new_bounds) { | 183 const gfx::Rect& new_bounds) { |
| 168 Cancel(false); | 184 Cancel(false); |
| 169 } | 185 } |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 return FRAME_STATE_SNAP_LEFT; | 589 return FRAME_STATE_SNAP_LEFT; |
| 574 if (bounds.right() == screen.right()) | 590 if (bounds.right() == screen.right()) |
| 575 return FRAME_STATE_SNAP_RIGHT; | 591 return FRAME_STATE_SNAP_RIGHT; |
| 576 // If we come here, it is likely caused by the fact that the | 592 // If we come here, it is likely caused by the fact that the |
| 577 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 593 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
| 578 // we allow all maximize operations (and keep the restore rectangle). | 594 // we allow all maximize operations (and keep the restore rectangle). |
| 579 return FRAME_STATE_NONE; | 595 return FRAME_STATE_NONE; |
| 580 } | 596 } |
| 581 | 597 |
| 582 } // namespace ash | 598 } // namespace ash |
| OLD | NEW |