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; |
18 class RenderViewHost; | |
16 | 19 |
17 // A platform independent implementation of BrowserWindow for Panels. This | 20 // A platform independent implementation of BrowserWindow for Panels. This |
18 // class would get the first crack at all the BrowserWindow calls for Panels and | 21 // class would get the first crack at all the BrowserWindow calls for Panels and |
19 // do one or more of the following: | 22 // do one or more of the following: |
20 // - Do nothing. The function is not relevant to Panels. | 23 // - Do nothing. The function is not relevant to Panels. |
21 // - Throw an exceptions. The function shouldn't be called for Panels. | 24 // - Throw an exceptions. The function shouldn't be called for Panels. |
22 // - Do Panel specific platform independent processing and then invoke the | 25 // - Do Panel specific platform independent processing and then invoke the |
23 // function on the platform specific BrowserWindow member. For example, | 26 // function on the platform specific BrowserWindow member. For example, |
24 // Panel size is restricted to certain limits. | 27 // Panel size is restricted to certain limits. |
25 // - Invoke an appropriate PanelManager function to do stuff that might affect | 28 // - Invoke an appropriate PanelManager function to do stuff that might affect |
26 // other Panels. For example deleting a panel would rearrange other panels. | 29 // other Panels. For example deleting a panel would rearrange other panels. |
27 class Panel : public BrowserWindow { | 30 class Panel : public BrowserWindow, public NotificationObserver { |
28 public: | 31 public: |
29 enum ExpansionState { | 32 enum ExpansionState { |
30 // The panel is fully expanded with both title-bar and the client-area. | 33 // The panel is fully expanded with both title-bar and the client-area. |
31 EXPANDED, | 34 EXPANDED, |
32 // The panel is shown with the title-bar only. | 35 // The panel is shown with the title-bar only. |
33 TITLE_ONLY, | 36 TITLE_ONLY, |
34 // The panel is shown with 3-pxiel line. | 37 // The panel is shown with 3-pxiel line. |
35 MINIMIZED | 38 MINIMIZED |
36 }; | 39 }; |
37 | 40 |
38 virtual ~Panel(); | 41 virtual ~Panel(); |
39 | 42 |
40 // Returns the PanelManager associated with this panel. | 43 // Returns the PanelManager associated with this panel. |
41 PanelManager* manager() const; | 44 PanelManager* manager() const; |
42 | 45 |
43 void SetExpansionState(ExpansionState new_expansion_state); | 46 void SetExpansionState(ExpansionState new_expansion_state); |
44 | 47 |
45 bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const; | 48 bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const; |
46 | 49 |
47 bool IsDrawingAttention() const; | 50 bool IsDrawingAttention() const; |
48 | 51 |
52 // Gets or sets the restored height, which is the full height of the panel | |
53 // when it is expanded. | |
54 int GetRestoredHeight() const; | |
Dmitry Titov
2011/08/09 21:08:16
I wonder why don't we just let PanelManager to get
jianli
2011/08/09 22:15:49
Personally I would like PanelManager to know nothi
| |
55 void SetRestoredHeight(int height); | |
56 | |
49 // BrowserWindow overrides. | 57 // BrowserWindow overrides. |
50 virtual void Show() OVERRIDE; | 58 virtual void Show() OVERRIDE; |
51 virtual void ShowInactive() OVERRIDE; | 59 virtual void ShowInactive() OVERRIDE; |
52 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 60 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
53 virtual void Close() OVERRIDE; | 61 virtual void Close() OVERRIDE; |
54 virtual void Activate() OVERRIDE; | 62 virtual void Activate() OVERRIDE; |
55 virtual void Deactivate() OVERRIDE; | 63 virtual void Deactivate() OVERRIDE; |
56 virtual bool IsActive() const OVERRIDE; | 64 virtual bool IsActive() const OVERRIDE; |
57 virtual void FlashFrame() OVERRIDE; | 65 virtual void FlashFrame() OVERRIDE; |
58 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; | 66 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 virtual void PrepareForInstant() OVERRIDE; | 145 virtual void PrepareForInstant() OVERRIDE; |
138 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; | 146 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; |
139 virtual void HideInstant(bool instant_is_active) OVERRIDE; | 147 virtual void HideInstant(bool instant_is_active) OVERRIDE; |
140 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 148 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
141 virtual WindowOpenDisposition GetDispositionForPopupBounds( | 149 virtual WindowOpenDisposition GetDispositionForPopupBounds( |
142 const gfx::Rect& bounds) OVERRIDE; | 150 const gfx::Rect& bounds) OVERRIDE; |
143 virtual FindBar* CreateFindBar() OVERRIDE; | 151 virtual FindBar* CreateFindBar() OVERRIDE; |
144 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
145 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; | 153 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; |
146 #endif | 154 #endif |
155 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE; | |
156 | |
157 // NotificationObserver overrides. | |
158 virtual void Observe(int type, | |
159 const NotificationSource& source, | |
160 const NotificationDetails& details) OVERRIDE; | |
147 | 161 |
148 // Construct a native panel BrowserWindow implementation for the specified | 162 // Construct a native panel BrowserWindow implementation for the specified |
149 // |browser|. | 163 // |browser|. |
150 static NativePanel* CreateNativePanel(Browser* browser, | 164 static NativePanel* CreateNativePanel(Browser* browser, |
151 Panel* panel, | 165 Panel* panel, |
152 const gfx::Rect& bounds); | 166 const gfx::Rect& bounds); |
153 | 167 |
154 // Gets the extension from the browser that a panel is created from. | 168 // Gets the extension from the browser that a panel is created from. |
155 // Returns NULL if it cannot be found. | 169 // Returns NULL if it cannot be found. |
156 static const Extension* GetExtension(Browser* browser); | 170 static const Extension* GetExtension(Browser* browser); |
157 | 171 |
158 #ifdef UNIT_TEST | 172 #ifdef UNIT_TEST |
159 NativePanel* native_panel() { return native_panel_; } | 173 NativePanel* native_panel() { return native_panel_; } |
160 #endif | 174 #endif |
161 | 175 |
162 Browser* browser() const; | 176 Browser* browser() const; |
163 ExpansionState expansion_state() const { return expansion_state_; } | 177 ExpansionState expansion_state() const { return expansion_state_; } |
178 const gfx::Size& min_size() const { return min_size_; } | |
179 const gfx::Size& max_size() const { return max_size_; } | |
164 | 180 |
165 protected: | 181 protected: |
166 virtual void DestroyBrowser() OVERRIDE; | 182 virtual void DestroyBrowser() OVERRIDE; |
167 | 183 |
168 private: | 184 private: |
169 friend class PanelManager; | 185 friend class PanelManager; |
170 | 186 |
171 // Panel can only be created using PanelManager::CreatePanel(). | 187 // Panel can only be created using PanelManager::CreatePanel(). |
172 Panel(Browser* browser, const gfx::Rect& bounds); | 188 Panel(Browser* browser, const gfx::Rect& bounds); |
173 | 189 |
174 // This is different from BrowserWindow::SetBounds(): | 190 // This is different from BrowserWindow::SetBounds(): |
175 // * SetPanelBounds() is only called by PanelManager to manage its position. | 191 // * SetPanelBounds() is only called by PanelManager to manage its position. |
176 // * SetBounds() is called by the API to try to change the bounds, which is | 192 // * SetBounds() is called by the API to try to change the bounds, which is |
177 // not allowed for Panel. | 193 // not allowed for Panel. |
178 void SetPanelBounds(const gfx::Rect& bounds); | 194 void SetPanelBounds(const gfx::Rect& bounds); |
179 | 195 |
196 // Updates the maximum size. | |
197 void SetMaxSize(const gfx::Size& max_size); | |
198 | |
199 void RequestRenderViewHostToDisableScrollbars( | |
200 RenderViewHost* render_view_host); | |
201 | |
202 // This is the minimum size that the panel can shrink to. | |
203 gfx::Size min_size_; | |
204 | |
205 // This is the size beyond which the panel is not going to grow to accomodate | |
206 // the growing content and WebKit would add the scrollbars in such case. | |
207 gfx::Size max_size_; | |
208 | |
180 // Platform specifc implementation for panels. It'd be one of | 209 // Platform specifc implementation for panels. It'd be one of |
181 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. | 210 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. |
182 NativePanel* native_panel_; // Weak, owns us. | 211 NativePanel* native_panel_; // Weak, owns us. |
183 | 212 |
184 ExpansionState expansion_state_; | 213 ExpansionState expansion_state_; |
185 | 214 |
215 NotificationRegistrar registrar_; | |
216 | |
186 DISALLOW_COPY_AND_ASSIGN(Panel); | 217 DISALLOW_COPY_AND_ASSIGN(Panel); |
187 }; | 218 }; |
188 | 219 |
189 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ | 220 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ |
OLD | NEW |