Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / panels / panel_view.h
blob0b02557cb41e192f8e3ca29bbe15bd7378f4fb2d
1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_VIEW_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/panels/native_panel.h"
10 #include "ui/gfx/animation/animation_delegate.h"
11 #include "ui/views/widget/widget_delegate.h"
12 #include "ui/views/widget/widget_observer.h"
14 #if defined(OS_WIN)
15 #include "ui/base/win/hwnd_subclass.h"
16 #endif
18 class AutoKeepAlive;
19 class Panel;
20 class PanelBoundsAnimation;
21 class PanelFrameView;
22 class TaskbarWindowThumbnailerWin;
24 namespace views {
25 class WebView;
28 class PanelView : public NativePanel,
29 public views::WidgetObserver,
30 public views::WidgetDelegateView,
31 #if defined(OS_WIN)
32 public ui::HWNDMessageFilter,
33 #endif
34 public gfx::AnimationDelegate {
35 public:
36 // The size of inside area used for mouse resizing.
37 static const int kResizeInsideBoundsSize = 5;
39 PanelView(Panel* panel, const gfx::Rect& bounds, bool always_on_top);
40 ~PanelView() override;
42 // Overridden from NativePanel:
43 void ShowPanel() override;
44 void ShowPanelInactive() override;
45 gfx::Rect GetPanelBounds() const override;
46 void SetPanelBounds(const gfx::Rect& bounds) override;
47 void SetPanelBoundsInstantly(const gfx::Rect& bounds) override;
48 void ClosePanel() override;
49 void ActivatePanel() override;
50 void DeactivatePanel() override;
51 bool IsPanelActive() const override;
52 void PreventActivationByOS(bool prevent_activation) override;
53 gfx::NativeWindow GetNativePanelWindow() override;
54 void UpdatePanelTitleBar() override;
55 void UpdatePanelLoadingAnimations(bool should_animate) override;
56 void PanelWebContentsFocused(content::WebContents* contents) override;
57 void PanelCut() override;
58 void PanelCopy() override;
59 void PanelPaste() override;
60 void DrawAttention(bool draw_attention) override;
61 bool IsDrawingAttention() const override;
62 void HandlePanelKeyboardEvent(
63 const content::NativeWebKeyboardEvent& event) override;
64 void FullScreenModeChanged(bool is_full_screen) override;
65 bool IsPanelAlwaysOnTop() const override;
66 void SetPanelAlwaysOnTop(bool on_top) override;
67 void UpdatePanelMinimizeRestoreButtonVisibility() override;
68 void SetWindowCornerStyle(panel::CornerStyle corner_style) override;
69 void PanelExpansionStateChanging(Panel::ExpansionState old_state,
70 Panel::ExpansionState new_state) override;
71 void AttachWebContents(content::WebContents* contents) override;
72 void DetachWebContents(content::WebContents* contents) override;
73 gfx::Size WindowSizeFromContentSize(
74 const gfx::Size& content_size) const override;
75 gfx::Size ContentSizeFromWindowSize(
76 const gfx::Size& window_size) const override;
77 int TitleOnlyHeight() const override;
78 void MinimizePanelBySystem() override;
79 bool IsPanelMinimizedBySystem() const override;
80 bool IsPanelShownOnActiveDesktop() const override;
81 void ShowShadow(bool show) override;
82 NativePanelTesting* CreateNativePanelTesting() override;
84 // Overridden from views::View:
85 gfx::Size GetMinimumSize() const override;
86 gfx::Size GetMaximumSize() const override;
88 // Return true if the mouse event is handled.
89 // |mouse_location| is in screen coordinate system.
90 bool OnTitlebarMousePressed(const gfx::Point& mouse_location);
91 bool OnTitlebarMouseDragged(const gfx::Point& mouse_location);
92 bool OnTitlebarMouseReleased(panel::ClickModifier modifier);
93 bool OnTitlebarMouseCaptureLost();
95 PanelFrameView* GetFrameView() const;
96 bool IsAnimatingBounds() const;
98 Panel* panel() const { return panel_.get(); }
99 views::Widget* window() const { return window_; }
100 bool force_to_paint_as_inactive() const {
101 return force_to_paint_as_inactive_;
104 // PanelStackView might want to update the stored bounds directly since it
105 // has already taken care of updating the window bounds directly.
106 void set_cached_bounds_directly(const gfx::Rect& bounds) { bounds_ = bounds; }
108 private:
109 enum MouseDraggingState {
110 NO_DRAGGING,
111 DRAGGING_STARTED,
112 DRAGGING_ENDED
115 // Overridden from views::WidgetDelegate:
116 void OnDisplayChanged() override;
117 void OnWorkAreaChanged() override;
118 bool WillProcessWorkAreaChange() const override;
119 views::View* GetContentsView() override;
120 views::NonClientFrameView* CreateNonClientFrameView(
121 views::Widget* widget) override;
122 bool CanResize() const override;
123 bool CanMaximize() const override;
124 bool CanMinimize() const override;
125 views::Widget* GetWidget() override;
126 const views::Widget* GetWidget() const override;
127 base::string16 GetWindowTitle() const override;
128 gfx::ImageSkia GetWindowAppIcon() override;
129 gfx::ImageSkia GetWindowIcon() override;
130 void WindowClosing() override;
131 void DeleteDelegate() override;
132 void OnWindowBeginUserBoundsChange() override;
133 void OnWindowEndUserBoundsChange() override;
135 // Overridden from views::View:
136 void Layout() override;
137 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
139 // Overridden from views::WidgetObserver:
140 void OnWidgetDestroying(views::Widget* widget) override;
141 void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
142 void OnWidgetBoundsChanged(views::Widget* widget,
143 const gfx::Rect& new_bounds) override;
145 // Overridden from ui::HWNDMessageFilter:
146 #if defined(OS_WIN)
147 virtual bool FilterMessage(HWND hwnd,
148 UINT message,
149 WPARAM w_param,
150 LPARAM l_param,
151 LRESULT* l_result) override;
152 #endif
154 // Overridden from AnimationDelegate:
155 void AnimationEnded(const gfx::Animation* animation) override;
156 void AnimationProgressed(const gfx::Animation* animation) override;
158 void UpdateLoadingAnimations(bool should_animate);
159 void UpdateWindowTitle();
160 void UpdateWindowIcon();
161 void SetBoundsInternal(const gfx::Rect& bounds, bool animate);
162 bool EndDragging(bool cancelled);
164 // Sets the bounds of the underlying window to |new_bounds|. Note that this
165 // might update the window style to work around the minimum overlapped
166 // window height limitation.
167 void SetWidgetBounds(const gfx::Rect& new_bounds);
169 #if defined(OS_WIN)
170 // Sets |attribute_value_to_set| and/or clears |attribute_value_to_reset| for
171 // the attibute denoted by |attribute_index|. This is used to update the style
172 // or extended style for the native window.
173 void UpdateWindowAttribute(int attribute_index,
174 int attribute_value_to_set,
175 int attribute_value_to_reset,
176 bool update_frame);
177 #endif
179 scoped_ptr<Panel> panel_;
180 gfx::Rect bounds_;
182 // The window that holds all panel views. Lifetime managed by native widget.
183 // See widget.h.
184 views::Widget* window_;
186 // Close gets called more than once, so use this to do one-time clean up once.
187 bool window_closed_;
189 // The view hosting the web contents. Will be destroyed when child views
190 // of this class are destroyed.
191 views::WebView* web_view_;
193 // True if the panel should always stay on top of other windows.
194 bool always_on_top_;
196 // Is the panel receiving the focus?
197 bool focused_;
199 // True if the user is resizing the panel.
200 bool user_resizing_;
202 #if defined(OS_WIN)
203 // True if the user is resizing the interior edge of a stack.
204 bool user_resizing_interior_stacked_panel_edge_;
206 // The original full size of the resizing panel before the resizing states.
207 gfx::Size original_full_size_of_resizing_panel_;
209 // The original full size of the panel below the resizing panel before the
210 // resizing starts.
211 gfx::Size original_full_size_of_panel_below_resizing_panel_;
212 #endif
215 // Is the mouse button currently down?
216 bool mouse_pressed_;
218 // Location the mouse was pressed at or dragged to last time when we process
219 // the mouse event. Used in drag-and-drop.
220 // This point is represented in the screen coordinate system.
221 gfx::Point last_mouse_location_;
223 // Is the titlebar currently being dragged? That is, has the cursor
224 // moved more than kDragThreshold away from its starting position?
225 MouseDraggingState mouse_dragging_state_;
227 // Used to animate the bounds change.
228 scoped_ptr<PanelBoundsAnimation> bounds_animator_;
229 gfx::Rect animation_start_bounds_;
231 // Is the panel in highlighted state to draw people's attention?
232 bool is_drawing_attention_;
234 // Should we force to paint the panel as inactive? This is needed when we need
235 // to capture the screenshot before an active panel goes minimized.
236 bool force_to_paint_as_inactive_;
238 // The last view that had focus in the panel. This is saved so that focus can
239 // be restored properly when a drag ends.
240 views::View* old_focused_view_;
242 scoped_ptr<AutoKeepAlive> keep_alive_;
244 #if defined(OS_WIN)
245 // Used to provide custom taskbar thumbnail for Windows 7 and later.
246 scoped_ptr<TaskbarWindowThumbnailerWin> thumbnailer_;
247 #endif
249 DISALLOW_COPY_AND_ASSIGN(PanelView);
252 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_VIEW_H_