OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
14 #include "chrome/browser/command_updater_delegate.h" | 14 #include "chrome/browser/command_updater_delegate.h" |
15 #include "chrome/browser/extensions/image_loading_tracker.h" | 15 #include "chrome/browser/extensions/image_loading_tracker.h" |
16 #include "chrome/browser/sessions/session_id.h" | 16 #include "chrome/browser/sessions/session_id.h" |
17 #include "chrome/browser/ui/base_window.h" | 17 #include "chrome/browser/ui/base_window.h" |
18 #include "chrome/browser/ui/panels/panel_constants.h" | 18 #include "chrome/browser/ui/panels/panel_constants.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
23 | 23 |
24 class GURL; | 24 class GURL; |
25 class NativePanel; | 25 class NativePanel; |
26 class PanelCollection; | 26 class PanelCollection; |
27 class PanelHost; | 27 class PanelHost; |
28 class PanelManager; | 28 class PanelManager; |
29 class Profile; | 29 class Profile; |
30 class StackedPanelCollection; | |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 class WebContents; | 33 class WebContents; |
33 struct NativeWebKeyboardEvent; | 34 struct NativeWebKeyboardEvent; |
34 } | 35 } |
35 | 36 |
36 namespace extensions { | 37 namespace extensions { |
37 class Extension; | 38 class Extension; |
38 class WindowController; | 39 class WindowController; |
39 } | 40 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 const gfx::Image& app_icon() const { return app_icon_; } | 82 const gfx::Image& app_icon() const { return app_icon_; } |
82 const SessionID& session_id() const { return session_id_; } | 83 const SessionID& session_id() const { return session_id_; } |
83 extensions::WindowController* extension_window_controller() const { | 84 extensions::WindowController* extension_window_controller() const { |
84 return extension_window_controller_.get(); | 85 return extension_window_controller_.get(); |
85 } | 86 } |
86 const std::string extension_id() const; | 87 const std::string extension_id() const; |
87 | 88 |
88 CommandUpdater* command_updater(); | 89 CommandUpdater* command_updater(); |
89 Profile* profile() const; | 90 Profile* profile() const; |
90 | 91 |
92 const extensions::Extension* GetExtension() const; | |
93 | |
91 // Returns web contents of the panel, if any. There may be none if web | 94 // Returns web contents of the panel, if any. There may be none if web |
92 // contents have not been added to the panel yet. | 95 // contents have not been added to the panel yet. |
93 content::WebContents* GetWebContents() const; | 96 content::WebContents* GetWebContents() const; |
94 | 97 |
95 void SetExpansionState(ExpansionState new_expansion_state); | 98 void SetExpansionState(ExpansionState new_expansion_state); |
96 | 99 |
97 bool IsDrawingAttention() const; | 100 bool IsDrawingAttention() const; |
98 | 101 |
99 // This function will only get called by PanelManager when full screen mode | 102 // This function will only get called by PanelManager when full screen mode |
100 // changes i.e it gets called when an app goes into full screen mode or when | 103 // changes i.e it gets called when an app goes into full screen mode or when |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 // * panel is newly created and has not been positioned yet. | 172 // * panel is newly created and has not been positioned yet. |
170 // * panel is being closed asynchronously. | 173 // * panel is being closed asynchronously. |
171 // Please use it with caution. | 174 // Please use it with caution. |
172 PanelCollection* collection() const { return collection_; } | 175 PanelCollection* collection() const { return collection_; } |
173 | 176 |
174 // Sets the current panel collection that contains this panel. | 177 // Sets the current panel collection that contains this panel. |
175 void set_collection(PanelCollection* new_collection) { | 178 void set_collection(PanelCollection* new_collection) { |
176 collection_ = new_collection; | 179 collection_ = new_collection; |
177 } | 180 } |
178 | 181 |
182 StackedPanelCollection* stack() const; | |
dcheng
2013/01/10 22:39:03
Do we want to be returning a non-const pointer her
jianli
2013/01/10 23:23:23
Yes we need non-const pointer since we need to cal
| |
183 | |
179 ExpansionState expansion_state() const { return expansion_state_; } | 184 ExpansionState expansion_state() const { return expansion_state_; } |
180 const gfx::Size& min_size() const { return min_size_; } | 185 const gfx::Size& min_size() const { return min_size_; } |
181 const gfx::Size& max_size() const { return max_size_; } | 186 const gfx::Size& max_size() const { return max_size_; } |
182 bool auto_resizable() const { return auto_resizable_; } | 187 bool auto_resizable() const { return auto_resizable_; } |
183 | 188 |
184 bool in_preview_mode() const { return in_preview_mode_; } | 189 bool in_preview_mode() const { return in_preview_mode_; } |
185 | 190 |
186 panel::Resizability CanResizeByMouse() const; | 191 panel::Resizability CanResizeByMouse() const; |
187 | 192 |
188 AttentionMode attention_mode() const { return attention_mode_; } | 193 AttentionMode attention_mode() const { return attention_mode_; } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 | 293 |
289 // Updates the title bar to display the current title and icon. | 294 // Updates the title bar to display the current title and icon. |
290 void UpdateTitleBar(); | 295 void UpdateTitleBar(); |
291 | 296 |
292 // Updates UI to reflect change in loading state. | 297 // Updates UI to reflect change in loading state. |
293 void LoadingStateChanged(bool is_loading); | 298 void LoadingStateChanged(bool is_loading); |
294 | 299 |
295 // Updates UI to reflect that the web cotents receives the focus. | 300 // Updates UI to reflect that the web cotents receives the focus. |
296 void WebContentsFocused(content::WebContents* contents); | 301 void WebContentsFocused(content::WebContents* contents); |
297 | 302 |
303 // Moves the panel by delta instantly. | |
304 void MoveByInstantly(const gfx::Vector2d& delta_origin); | |
305 | |
298 protected: | 306 protected: |
299 // Panel can only be created using PanelManager::CreatePanel() or subclass. | 307 // Panel can only be created using PanelManager::CreatePanel() or subclass. |
300 // |app_name| is the default title for Panels when the page content does not | 308 // |app_name| is the default title for Panels when the page content does not |
301 // provide a title. For extensions, this is usually the application name | 309 // provide a title. For extensions, this is usually the application name |
302 // generated from the extension id. | 310 // generated from the extension id. |
303 Panel(const std::string& app_name, | 311 Panel(const std::string& app_name, |
304 const gfx::Size& min_size, const gfx::Size& max_size); | 312 const gfx::Size& min_size, const gfx::Size& max_size); |
305 | 313 |
306 private: | 314 private: |
307 friend class PanelManager; | 315 friend class PanelManager; |
(...skipping 10 matching lines...) Expand all Loading... | |
318 virtual void OnImageLoaded(const gfx::Image& image, | 326 virtual void OnImageLoaded(const gfx::Image& image, |
319 const std::string& extension_id, | 327 const std::string& extension_id, |
320 int index) OVERRIDE; | 328 int index) OVERRIDE; |
321 | 329 |
322 // Initialize state for all supported commands. | 330 // Initialize state for all supported commands. |
323 void InitCommandState(); | 331 void InitCommandState(); |
324 | 332 |
325 // Configures the renderer for auto resize (if auto resize is enabled). | 333 // Configures the renderer for auto resize (if auto resize is enabled). |
326 void ConfigureAutoResize(content::WebContents* web_contents); | 334 void ConfigureAutoResize(content::WebContents* web_contents); |
327 | 335 |
328 const extensions::Extension* GetExtension() const; | |
329 | |
330 // Load the app's image, firing a load state change when loaded. | 336 // Load the app's image, firing a load state change when loaded. |
331 void UpdateAppIcon(); | 337 void UpdateAppIcon(); |
332 | 338 |
333 // Prepares a title string for display (removes embedded newlines, etc). | 339 // Prepares a title string for display (removes embedded newlines, etc). |
334 static void FormatTitleForDisplay(string16* title); | 340 static void FormatTitleForDisplay(string16* title); |
335 | 341 |
336 // The application name that is also the name of the window when the | 342 // The application name that is also the name of the window when the |
337 // page content does not provide a title. | 343 // page content does not provide a title. |
338 // This name should be set when the panel is created. | 344 // This name should be set when the panel is created. |
339 const std::string app_name_; | 345 const std::string app_name_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 // Used for loading app_icon_. | 393 // Used for loading app_icon_. |
388 scoped_ptr<ImageLoadingTracker> app_icon_loader_; | 394 scoped_ptr<ImageLoadingTracker> app_icon_loader_; |
389 | 395 |
390 // Icon showed in the task bar. | 396 // Icon showed in the task bar. |
391 gfx::Image app_icon_; | 397 gfx::Image app_icon_; |
392 | 398 |
393 DISALLOW_COPY_AND_ASSIGN(Panel); | 399 DISALLOW_COPY_AND_ASSIGN(Panel); |
394 }; | 400 }; |
395 | 401 |
396 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ | 402 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ |
OLD | NEW |