Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/ui/panels/panel.h

Issue 7537030: Make panel adjust bounds per preferred size change notification on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
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
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 // NULL might be returned if the tab has not been added.
200 RenderViewHost* GetRenderViewHost() const;
201
202 // Requests RenderViewHost not to show the scrollbars till |max_size_| since
203 // the panel can grow to |max_size_|.
204 void RequestRenderViewHostToDisableScrollbars(
205 RenderViewHost* render_view_host);
206
207 // This is the minimum size that the panel can shrink to.
208 gfx::Size min_size_;
209
210 // This is the size beyond which the panel is not going to grow to accomodate
211 // the growing content and WebKit would add the scrollbars in such case.
212 gfx::Size max_size_;
213
180 // Platform specifc implementation for panels. It'd be one of 214 // Platform specifc implementation for panels. It'd be one of
181 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. 215 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa.
182 NativePanel* native_panel_; // Weak, owns us. 216 NativePanel* native_panel_; // Weak, owns us.
183 217
184 ExpansionState expansion_state_; 218 ExpansionState expansion_state_;
185 219
220 NotificationRegistrar registrar_;
221
186 DISALLOW_COPY_AND_ASSIGN(Panel); 222 DISALLOW_COPY_AND_ASSIGN(Panel);
187 }; 223 };
188 224
189 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ 225 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698