Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / ash / frame / caption_buttons / maximize_bubble_controller.h
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/frame/caption_buttons/caption_button_types.h"
10 #include "ash/wm/workspace/snap_types.h"
11 #include "base/memory/scoped_ptr.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace base {
18 class Timer;
19 }
20
21 namespace views {
22 class CustomButton;
23 }
24
25 namespace ash {
26
27 class FrameMaximizeButton;
28 class MaximizeBubbleControllerBubble;
29
30 // A class which shows a helper UI for the maximize button after a delay.
31 class ASH_EXPORT MaximizeBubbleController {
32  public:
33   MaximizeBubbleController(FrameMaximizeButton* frame_maximize_button,
34                            MaximizeBubbleFrameState maximize_type,
35                            int appearance_delay_ms);
36   // Called from the outside to destroy the interface to the UI visuals.
37   // The visuals will then delete when possible (maybe asynchronously).
38   virtual ~MaximizeBubbleController();
39
40   // Update the UI visuals to reflect the previewed |snap_type| snapping state.
41   void SetSnapType(SnapType snap_type);
42
43   // To achieve proper Z-sorting with the snap animation, this window will be
44   // presented above the phantom window.
45   aura::Window* GetBubbleWindow();
46
47   // Reset the delay of the menu creation (if it was not created yet).
48   void DelayCreation();
49
50   // Called to tell the owning FrameMaximizeButton that a button was clicked.
51   void OnButtonClicked(SnapType snap_type);
52
53   // Called to tell the the owning FrameMaximizeButton that the hover status
54   // for a button has changed. |snap_type| can be either SNAP_LEFT, SNAP_RIGHT,
55   // SNAP_MINIMIZE or SNAP_NONE.
56   void OnButtonHover(SnapType snap_type);
57
58   // Get the owning FrameMaximizeButton.
59   FrameMaximizeButton* frame_maximize_button() {
60     return frame_maximize_button_;
61   }
62
63   // The status of the associated window: Maximized or normal.
64   MaximizeBubbleFrameState maximize_type() const { return maximize_type_; }
65
66   // A unit test function to return buttons of the sub menu. |state| can be
67   // either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
68   views::CustomButton* GetButtonForUnitTest(SnapType state);
69
70   // Called from the the Bubble class to destroy itself: It tells the owning
71   // object that it will destroy itself asynchronously. The owner will then
72   // destroy |this|.
73   void RequestDestructionThroughOwner();
74
75  private:
76   // The function which creates the bubble once the delay is elapsed.
77   void CreateBubble();
78
79   // The owning button which is also the anchor for the menu.
80   FrameMaximizeButton* frame_maximize_button_;
81
82   // The bubble menu.
83   MaximizeBubbleControllerBubble* bubble_;
84
85   // The current maximize state of the owning window.
86   const MaximizeBubbleFrameState maximize_type_;
87
88   // The snap type with which the bubble is created. This is needed because the
89   // creation of the bubble can be delayed and SetSnapType() may be called
90   // before the bubble is created.
91   SnapType snap_type_for_creation_;
92
93   // The timer for the delayed creation of the menu.
94   scoped_ptr<base::Timer> timer_;
95
96   // The appearance delay in ms (delay and fade in & fade out delay).
97   const int appearance_delay_ms_;
98
99   DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleController);
100 };
101
102 }  // namespace ash
103
104 #endif  // ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_H_