Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / wm / maximize_mode / maximize_mode_window_state.h
blob093f46be0203ff2c303422a64e7b91376c77ea54
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_
8 #include "ash/wm/window_state.h"
10 namespace ash {
11 class MaximizeModeWindowManager;
13 // The MaximizeModeWindowState implementation which reduces all possible window
14 // states to minimized and maximized. If a window cannot be maximized it will be
15 // set to normal. If a window cannot fill the entire workspace it will be
16 // centered within the workspace.
17 class MaximizeModeWindowState : public wm::WindowState::State {
18 public:
19 // Called when the window position might need to be updated.
20 static void UpdateWindowPosition(wm::WindowState* window_state,
21 bool animated);
23 // The |window|'s state object will be modified to use this new window mode
24 // state handler. Upon destruction it will restore the previous state handler
25 // and call |creator::WindowStateDestroyed()| to inform that the window mode
26 // was reverted to the old window manager.
27 MaximizeModeWindowState(aura::Window* window,
28 MaximizeModeWindowManager* creator);
29 virtual ~MaximizeModeWindowState();
31 // Leaves the maximize mode by reverting to previous state object.
32 void LeaveMaximizeMode(wm::WindowState* window_state);
34 // WindowState::State overrides:
35 virtual void OnWMEvent(wm::WindowState* window_state,
36 const wm::WMEvent* event) OVERRIDE;
38 virtual wm::WindowStateType GetType() const OVERRIDE;
39 virtual void AttachState(wm::WindowState* window_state,
40 wm::WindowState::State* previous_state) OVERRIDE;
41 virtual void DetachState(wm::WindowState* window_state) OVERRIDE;
43 private:
44 // Updates the window to |new_state_type| and resulting bounds:
45 // Either full screen, maximized centered or minimized. If the state does not
46 // change, only the bounds will be changed. If |animate| is set, the bound
47 // change get animated.
48 void UpdateWindow(wm::WindowState* window_state,
49 wm::WindowStateType new_state_type,
50 bool animate);
52 // Depending on the capabilities of the window we either return
53 // |WINDOW_STATE_TYPE_MAXIMIZED| or |WINDOW_STATE_TYPE_NORMAL|.
54 wm::WindowStateType GetMaximizedOrCenteredWindowType(
55 wm::WindowState* window_state);
57 // Updates the bounds to the maximum possible bounds according to the current
58 // window state. If |animated| is set we animate the change.
59 void UpdateBounds(wm::WindowState* window_state, bool animated);
61 // The original state object of the window.
62 scoped_ptr<wm::WindowState::State> old_state_;
64 // The state object for this object which owns this instance.
65 aura::Window* window_;
67 // The creator which needs to be informed when this state goes away.
68 MaximizeModeWindowManager* creator_;
70 // The current state type. Due to the nature of this state, this can only be
71 // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}.
72 wm::WindowStateType current_state_type_;
74 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowState);
77 } // namespace ash
79 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_