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/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/scoped_observer.h" | |
14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
15 #include "chrome/browser/command_updater.h" | 14 #include "chrome/browser/command_updater.h" |
16 #include "chrome/browser/command_updater_delegate.h" | 15 #include "chrome/browser/command_updater_delegate.h" |
17 #include "chrome/browser/sessions/session_id.h" | 16 #include "chrome/browser/sessions/session_id.h" |
18 #include "chrome/browser/ui/panels/panel_constants.h" | 17 #include "chrome/browser/ui/panels/panel_constants.h" |
19 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
21 #include "extensions/browser/extension_registry_observer.h" | |
22 #include "ui/base/base_window.h" | 20 #include "ui/base/base_window.h" |
23 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
24 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
25 | 23 |
26 class GURL; | 24 class GURL; |
27 class NativePanel; | 25 class NativePanel; |
28 class PanelCollection; | 26 class PanelCollection; |
29 class PanelHost; | 27 class PanelHost; |
30 class PanelManager; | 28 class PanelManager; |
31 class Profile; | 29 class Profile; |
32 class StackedPanelCollection; | 30 class StackedPanelCollection; |
33 | 31 |
34 namespace content { | 32 namespace content { |
35 class WebContents; | 33 class WebContents; |
36 struct NativeWebKeyboardEvent; | 34 struct NativeWebKeyboardEvent; |
37 } | 35 } |
38 | 36 |
39 namespace extensions { | 37 namespace extensions { |
40 class Extension; | 38 class Extension; |
41 class ExtensionRegistry; | |
42 class WindowController; | 39 class WindowController; |
43 } | 40 } |
44 | 41 |
45 // A platform independent implementation of ui::BaseWindow for Panels. | 42 // A platform independent implementation of ui::BaseWindow for Panels. |
46 // This class gets the first crack at all the ui::BaseWindow calls for Panels | 43 // This class gets the first crack at all the ui::BaseWindow calls for Panels |
47 // and does one or more of the following: | 44 // and does one or more of the following: |
48 // - Do nothing. The function is not relevant to Panels. | 45 // - Do nothing. The function is not relevant to Panels. |
49 // - Do Panel specific platform independent processing and then invoke the | 46 // - Do Panel specific platform independent processing and then invoke the |
50 // function on the platform specific member. For example, restrict panel | 47 // function on the platform specific member. For example, restrict panel |
51 // size to certain limits. | 48 // size to certain limits. |
52 // - Invoke an appropriate PanelManager function to do stuff that might affect | 49 // - Invoke an appropriate PanelManager function to do stuff that might affect |
53 // other Panels. For example deleting a panel would rearrange other panels. | 50 // other Panels. For example deleting a panel would rearrange other panels. |
54 class Panel : public ui::BaseWindow, | 51 class Panel : public ui::BaseWindow, |
55 public CommandUpdaterDelegate, | 52 public CommandUpdaterDelegate, |
56 public content::NotificationObserver, | 53 public content::NotificationObserver { |
57 public extensions::ExtensionRegistryObserver { | |
58 public: | 54 public: |
59 enum ExpansionState { | 55 enum ExpansionState { |
60 // The panel is fully expanded with both title-bar and the client-area. | 56 // The panel is fully expanded with both title-bar and the client-area. |
61 EXPANDED, | 57 EXPANDED, |
62 // The panel is shown with the title-bar only. | 58 // The panel is shown with the title-bar only. |
63 TITLE_ONLY, | 59 TITLE_ONLY, |
64 // The panel is shown with 3-pixel line. | 60 // The panel is shown with 3-pixel line. |
65 MINIMIZED | 61 MINIMIZED |
66 }; | 62 }; |
67 | 63 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Overridden from CommandUpdaterDelegate: | 138 // Overridden from CommandUpdaterDelegate: |
143 virtual void ExecuteCommandWithDisposition( | 139 virtual void ExecuteCommandWithDisposition( |
144 int id, | 140 int id, |
145 WindowOpenDisposition disposition) OVERRIDE; | 141 WindowOpenDisposition disposition) OVERRIDE; |
146 | 142 |
147 // content::NotificationObserver overrides. | 143 // content::NotificationObserver overrides. |
148 virtual void Observe(int type, | 144 virtual void Observe(int type, |
149 const content::NotificationSource& source, | 145 const content::NotificationSource& source, |
150 const content::NotificationDetails& details) OVERRIDE; | 146 const content::NotificationDetails& details) OVERRIDE; |
151 | 147 |
152 // extensions::ExtensionRegistryObserver implementation. | |
153 virtual void OnExtensionUnloaded( | |
154 content::BrowserContext* browser_context, | |
155 const extensions::Extension* extension, | |
156 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | |
157 | |
158 // Construct a native panel implementation. | 148 // Construct a native panel implementation. |
159 static NativePanel* CreateNativePanel(Panel* panel, | 149 static NativePanel* CreateNativePanel(Panel* panel, |
160 const gfx::Rect& bounds, | 150 const gfx::Rect& bounds, |
161 bool always_on_top); | 151 bool always_on_top); |
162 | 152 |
163 NativePanel* native_panel() const { return native_panel_; } | 153 NativePanel* native_panel() const { return native_panel_; } |
164 | 154 |
165 // Invoked when the native panel has detected a mouse click on the | 155 // Invoked when the native panel has detected a mouse click on the |
166 // panel's titlebar, minimize or restore buttons. Behavior of the | 156 // panel's titlebar, minimize or restore buttons. Behavior of the |
167 // click may be modified as indicated by |modifier|. | 157 // click may be modified as indicated by |modifier|. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 ExpansionState expansion_state_; | 385 ExpansionState expansion_state_; |
396 | 386 |
397 // The CommandUpdater manages the window commands. | 387 // The CommandUpdater manages the window commands. |
398 CommandUpdater command_updater_; | 388 CommandUpdater command_updater_; |
399 | 389 |
400 content::NotificationRegistrar registrar_; | 390 content::NotificationRegistrar registrar_; |
401 const SessionID session_id_; | 391 const SessionID session_id_; |
402 scoped_ptr<extensions::WindowController> extension_window_controller_; | 392 scoped_ptr<extensions::WindowController> extension_window_controller_; |
403 scoped_ptr<PanelHost> panel_host_; | 393 scoped_ptr<PanelHost> panel_host_; |
404 | 394 |
405 // Listen to extension unloaded notification. | |
406 ScopedObserver<extensions::ExtensionRegistry, | |
407 extensions::ExtensionRegistryObserver> | |
408 extension_registry_observer_; | |
409 | |
410 // Icon showed in the task bar. | 395 // Icon showed in the task bar. |
411 gfx::Image app_icon_; | 396 gfx::Image app_icon_; |
412 | 397 |
413 base::WeakPtrFactory<Panel> image_loader_ptr_factory_; | 398 base::WeakPtrFactory<Panel> image_loader_ptr_factory_; |
414 | 399 |
415 DISALLOW_COPY_AND_ASSIGN(Panel); | 400 DISALLOW_COPY_AND_ASSIGN(Panel); |
416 }; | 401 }; |
417 | 402 |
418 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ | 403 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ |
OLD | NEW |