OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/common/notification_observer.h" | |
13 #include "content/common/notification_registrar.h" | |
12 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
13 | 15 |
14 class NativePanel; | 16 class NativePanel; |
15 class PanelManager; | 17 class PanelManager; |
16 | 18 |
17 // A platform independent implementation of BrowserWindow for Panels. This | 19 // A platform independent implementation of BrowserWindow for Panels. This |
18 // class would get the first crack at all the BrowserWindow calls for Panels and | 20 // class would get the first crack at all the BrowserWindow calls for Panels and |
19 // do one or more of the following: | 21 // do one or more of the following: |
20 // - Do nothing. The function is not relevant to Panels. | 22 // - Do nothing. The function is not relevant to Panels. |
21 // - Throw an exceptions. The function shouldn't be called for Panels. | 23 // - Throw an exceptions. The function shouldn't be called for Panels. |
22 // - Do Panel specific platform independent processing and then invoke the | 24 // - Do Panel specific platform independent processing and then invoke the |
23 // function on the platform specific BrowserWindow member. For example, | 25 // function on the platform specific BrowserWindow member. For example, |
24 // Panel size is restricted to certain limits. | 26 // Panel size is restricted to certain limits. |
25 // - Invoke an appropriate PanelManager function to do stuff that might affect | 27 // - Invoke an appropriate PanelManager function to do stuff that might affect |
26 // other Panels. For example deleting a panel would rearrange other panels. | 28 // other Panels. For example deleting a panel would rearrange other panels. |
27 class Panel : public BrowserWindow { | 29 class Panel : public BrowserWindow, public NotificationObserver { |
28 public: | 30 public: |
29 enum ExpansionState { | 31 enum ExpansionState { |
30 // The panel is fully expanded with both title-bar and the client-area. | 32 // The panel is fully expanded with both title-bar and the client-area. |
31 EXPANDED, | 33 EXPANDED, |
32 // The panel is shown with the title-bar only. | 34 // The panel is shown with the title-bar only. |
33 TITLE_ONLY, | 35 TITLE_ONLY, |
34 // The panel is shown with 3-pxiel line. | 36 // The panel is shown with 3-pxiel line. |
35 MINIMIZED | 37 MINIMIZED |
36 }; | 38 }; |
37 | 39 |
38 virtual ~Panel(); | 40 virtual ~Panel(); |
39 | 41 |
40 // Returns the PanelManager associated with this panel. | 42 // Returns the PanelManager associated with this panel. |
41 PanelManager* manager() const; | 43 PanelManager* manager() const; |
42 | 44 |
43 void SetExpansionState(ExpansionState new_expansion_state); | 45 void SetExpansionState(ExpansionState new_expansion_state); |
44 | 46 |
45 bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const; | 47 bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const; |
46 | 48 |
47 bool IsDrawingAttention() const; | 49 bool IsDrawingAttention() const; |
48 | 50 |
51 // Returns the size of the non-client area, that is, the window size minus | |
52 // the size of the client area. | |
53 gfx::Size GetNonClientAreaSize() const; | |
54 | |
49 // BrowserWindow overrides. | 55 // BrowserWindow overrides. |
50 virtual void Show() OVERRIDE; | 56 virtual void Show() OVERRIDE; |
51 virtual void ShowInactive() OVERRIDE; | 57 virtual void ShowInactive() OVERRIDE; |
52 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 58 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
53 virtual void Close() OVERRIDE; | 59 virtual void Close() OVERRIDE; |
54 virtual void Activate() OVERRIDE; | 60 virtual void Activate() OVERRIDE; |
55 virtual void Deactivate() OVERRIDE; | 61 virtual void Deactivate() OVERRIDE; |
56 virtual bool IsActive() const OVERRIDE; | 62 virtual bool IsActive() const OVERRIDE; |
57 virtual void FlashFrame() OVERRIDE; | 63 virtual void FlashFrame() OVERRIDE; |
58 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; | 64 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 #endif | 140 #endif |
135 virtual void PrepareForInstant() OVERRIDE; | 141 virtual void PrepareForInstant() OVERRIDE; |
136 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; | 142 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; |
137 virtual void HideInstant(bool instant_is_active) OVERRIDE; | 143 virtual void HideInstant(bool instant_is_active) OVERRIDE; |
138 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 144 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
139 virtual WindowOpenDisposition GetDispositionForPopupBounds( | 145 virtual WindowOpenDisposition GetDispositionForPopupBounds( |
140 const gfx::Rect& bounds) OVERRIDE; | 146 const gfx::Rect& bounds) OVERRIDE; |
141 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
142 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; | 148 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; |
143 #endif | 149 #endif |
150 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE; | |
151 | |
152 // NotificationObserver overrides. | |
153 virtual void Observe(int type, | |
154 const NotificationSource& source, | |
155 const NotificationDetails& details) OVERRIDE; | |
144 | 156 |
145 // Construct a native panel BrowserWindow implementation for the specified | 157 // Construct a native panel BrowserWindow implementation for the specified |
146 // |browser|. | 158 // |browser|. |
147 static NativePanel* CreateNativePanel(Browser* browser, | 159 static NativePanel* CreateNativePanel(Browser* browser, |
148 Panel* panel, | 160 Panel* panel, |
149 const gfx::Rect& bounds); | 161 const gfx::Rect& bounds); |
150 | 162 |
151 // Gets the extension from the browser that a panel is created from. | 163 // Gets the extension from the browser that a panel is created from. |
152 // Returns NULL if it cannot be found. | 164 // Returns NULL if it cannot be found. |
153 static const Extension* GetExtension(Browser* browser); | 165 static const Extension* GetExtension(Browser* browser); |
154 | 166 |
155 #ifdef UNIT_TEST | 167 #ifdef UNIT_TEST |
156 NativePanel* native_panel() { return native_panel_; } | 168 NativePanel* native_panel() { return native_panel_; } |
157 #endif | 169 #endif |
158 | 170 |
159 Browser* browser() const; | 171 Browser* browser() const; |
160 ExpansionState expansion_state() const { return expansion_state_; } | 172 ExpansionState expansion_state() const { return expansion_state_; } |
161 | 173 |
162 protected: | 174 protected: |
163 virtual void DestroyBrowser() OVERRIDE; | 175 virtual void DestroyBrowser() OVERRIDE; |
164 | 176 |
165 private: | 177 private: |
166 friend class PanelManager; | 178 friend class PanelManager; |
167 | 179 |
168 // Panel can only be created using PanelManager::CreatePanel(). | 180 // Panel can only be created using PanelManager::CreatePanel(). |
169 Panel(Browser* browser, const gfx::Rect& bounds); | 181 Panel(Browser* browser, const gfx::Rect& bounds); |
170 | 182 |
183 // Called from PanelManager to update the bounds that should be used when the | |
184 // panel is expanded. | |
185 void SetRestoredBounds(const gfx::Rect& bounds); | |
186 | |
171 // This is different from BrowserWindow::SetBounds(): | 187 // This is different from BrowserWindow::SetBounds(): |
172 // * SetPanelBounds() is only called by PanelManager to manage its position. | 188 // * SetPanelBounds() is only called by PanelManager to manage its position. |
173 // * SetBounds() is called by the API to try to change the bounds, which is | 189 // * SetBounds() is called by the API to try to change the bounds, which is |
174 // not allowed for Panel. | 190 // not allowed for Panel. |
175 void SetPanelBounds(const gfx::Rect& bounds); | 191 void SetPanelBounds(const gfx::Rect& bounds); |
176 | 192 |
193 // Updates the maximum size. | |
194 void SetMaximumSize(const gfx::Size& max_size); | |
195 | |
196 // The initial size. The panel cannot shrink to be smaller than that. | |
Dmitry Titov
2011/08/05 19:02:20
As discussed, lets rename all these into "minimum_
jianli
2011/08/09 19:56:16
Done.
| |
197 // Used by PanelManager in updating the panel bounds as responding to the | |
198 // dynamic content update. | |
199 gfx::Size initial_size_; | |
200 | |
201 // The maximum size that the panel can grow to. Note that the maximum width is | |
202 // affected by the available horizontal space when panels are added, removed, | |
Dmitry Titov
2011/08/05 19:02:20
Lets add comment about how this size is used - to
jianli
2011/08/09 19:56:16
Done.
| |
203 // or size changed. | |
204 gfx::Size max_size_; | |
205 | |
177 // Platform specifc implementation for panels. It'd be one of | 206 // Platform specifc implementation for panels. It'd be one of |
178 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. | 207 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. |
179 NativePanel* native_panel_; // Weak, owns us. | 208 NativePanel* native_panel_; // Weak, owns us. |
180 | 209 |
181 ExpansionState expansion_state_; | 210 ExpansionState expansion_state_; |
182 | 211 |
212 NotificationRegistrar registrar_; | |
213 | |
183 DISALLOW_COPY_AND_ASSIGN(Panel); | 214 DISALLOW_COPY_AND_ASSIGN(Panel); |
184 }; | 215 }; |
185 | 216 |
186 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ | 217 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ |
OLD | NEW |