Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / panels / panel_stack_view.h
blob56f8ce87aebca8d6be0dc753b330951ec8ee88a7
1 // Copyright (c) 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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_
8 #include <list>
9 #include <map>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/panels/native_panel_stack_window.h"
13 #include "ui/gfx/animation/animation_delegate.h"
14 #include "ui/views/focus/widget_focus_manager.h"
15 #include "ui/views/widget/widget_delegate.h"
16 #include "ui/views/widget/widget_observer.h"
18 #if defined(OS_WIN)
19 #include "chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.h"
20 #include "ui/base/win/hwnd_subclass.h"
21 #endif
23 namespace gfx {
24 class LinearAnimation;
26 namespace views {
27 class Widget;
30 // A native window that acts as the owner of all panels in the stack, in order
31 // to make all panels appear as a single window on the taskbar or launcher.
32 class PanelStackView : public NativePanelStackWindow,
33 public views::WidgetFocusChangeListener,
34 #if defined(OS_WIN)
35 public ui::HWNDMessageFilter,
36 public TaskbarWindowThumbnailerDelegateWin,
37 #endif
38 public gfx::AnimationDelegate {
39 public:
40 explicit PanelStackView(NativePanelStackWindowDelegate* delegate);
41 ~PanelStackView() override;
43 protected:
44 // Overridden from NativePanelStackWindow:
45 void Close() override;
46 void AddPanel(Panel* panel) override;
47 void RemovePanel(Panel* panel) override;
48 void MergeWith(NativePanelStackWindow* another) override;
49 bool IsEmpty() const override;
50 bool HasPanel(Panel* panel) const override;
51 void MovePanelsBy(const gfx::Vector2d& delta) override;
52 void BeginBatchUpdatePanelBounds(bool animate) override;
53 void AddPanelBoundsForBatchUpdate(Panel* panel,
54 const gfx::Rect& new_bounds) override;
55 void EndBatchUpdatePanelBounds() override;
56 bool IsAnimatingPanelBounds() const override;
57 void Minimize() override;
58 bool IsMinimized() const override;
59 void DrawSystemAttention(bool draw_attention) override;
60 void OnPanelActivated(Panel* panel) override;
62 private:
63 typedef std::list<Panel*> Panels;
65 // The map value is old bounds of the panel.
66 typedef std::map<Panel*, gfx::Rect> BoundsUpdates;
68 // Overridden from views::WidgetFocusChangeListener:
69 void OnNativeFocusChanged(gfx::NativeView focused_now) override;
71 // Overridden from AnimationDelegate:
72 void AnimationEnded(const gfx::Animation* animation) override;
73 void AnimationProgressed(const gfx::Animation* animation) override;
74 void AnimationCanceled(const gfx::Animation* animation) override;
76 // Updates the bounds of panels as specified in batch update data.
77 void UpdatePanelsBounds();
79 // Notifies the delegate that the updates of the panel bounds are completed.
80 void NotifyBoundsUpdateCompleted();
82 // Computes/updates the minimum bounds that could fit all panels.
83 gfx::Rect GetStackWindowBounds() const;
84 void UpdateStackWindowBounds();
86 views::Widget* CreateWindowWithBounds(const gfx::Rect& bounds);
87 void EnsureWindowCreated();
89 // Makes the stack window own the panel window such that multiple panels
90 // stacked together could appear as a single window on the taskbar or
91 // launcher.
92 static void MakeStackWindowOwnPanelWindow(Panel* panel,
93 PanelStackView* stack_window);
95 #if defined(OS_WIN)
96 // Overridden from ui::HWNDMessageFilter:
97 bool FilterMessage(HWND hwnd,
98 UINT message,
99 WPARAM w_param,
100 LPARAM l_param,
101 LRESULT* l_result) override;
103 // Overridden from TaskbarWindowThumbnailerDelegateWin:
104 std::vector<HWND> GetSnapshotWindowHandles() const override;
106 // Updates the live preview snapshot when something changes, like
107 // adding/removing/moving/resizing a stacked panel.
108 void RefreshLivePreviewThumbnail();
110 // Updates the bounds of the widget window in a deferred way.
111 void DeferUpdateNativeWindowBounds(HDWP defer_window_pos_info,
112 views::Widget* window,
113 const gfx::Rect& bounds);
114 #endif
116 NativePanelStackWindowDelegate* delegate_;
118 views::Widget* window_; // Weak pointer, own us.
120 // Tracks all panels that are enclosed by this window.
121 Panels panels_;
123 // Is the taskbar icon of the underlying window being flashed in order to
124 // draw the user's attention?
125 bool is_drawing_attention_;
127 #if defined(OS_WIN)
128 // The custom live preview snapshot is always provided for the stack window.
129 // This is because the system might not show the snapshot correctly for
130 // a small window, like collapsed panel.
131 scoped_ptr<TaskbarWindowThumbnailerWin> thumbnailer_;
132 #endif
134 // For batch bounds update.
135 bool animate_bounds_updates_;
136 bool bounds_updates_started_;
137 BoundsUpdates bounds_updates_;
139 // Used to animate the bounds changes at a synchronized pace.
140 scoped_ptr<gfx::LinearAnimation> bounds_animator_;
142 DISALLOW_COPY_AND_ASSIGN(PanelStackView);
145 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_STACK_VIEW_H_