| 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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/timer.h" | 13 #include "base/timer.h" |
| 14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" | 14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" |
| 15 #include "chrome/browser/ui/panels/panel.h" | 15 #include "chrome/browser/ui/panels/panel.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 | 17 |
| 18 // TODO(jennb): Clean up by removing functions below that cause this | |
| 19 // to be required. | |
| 20 #ifdef UNIT_TEST | |
| 21 #include "chrome/browser/ui/panels/panel_strip.h" | |
| 22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | |
| 23 #endif | |
| 24 | |
| 25 class Browser; | 18 class Browser; |
| 26 class PanelMouseWatcher; | 19 class PanelMouseWatcher; |
| 27 class PanelOverflowStrip; | 20 class PanelOverflowStrip; |
| 28 class PanelStrip; | 21 class PanelStrip; |
| 29 | 22 |
| 30 // This class manages a set of panels. | 23 // This class manages a set of panels. |
| 31 class PanelManager : public AutoHidingDesktopBar::Observer { | 24 class PanelManager : public AutoHidingDesktopBar::Observer { |
| 32 public: | 25 public: |
| 33 typedef std::vector<Panel*> Panels; | 26 typedef std::vector<Panel*> Panels; |
| 34 | 27 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 61 |
| 69 // Brings up or down the titlebars for all minimized panels. | 62 // Brings up or down the titlebars for all minimized panels. |
| 70 void BringUpOrDownTitlebars(bool bring_up); | 63 void BringUpOrDownTitlebars(bool bring_up); |
| 71 | 64 |
| 72 // Returns the next browser window which could be either panel window or | 65 // Returns the next browser window which could be either panel window or |
| 73 // tabbed window, to switch to if the given panel is going to be deactivated. | 66 // tabbed window, to switch to if the given panel is going to be deactivated. |
| 74 // Returns NULL if such window cannot be found. | 67 // Returns NULL if such window cannot be found. |
| 75 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; | 68 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; |
| 76 | 69 |
| 77 int num_panels() const; | 70 int num_panels() const; |
| 78 bool is_dragging_panel() const; | |
| 79 int StartingRightPosition() const; | 71 int StartingRightPosition() const; |
| 80 const Panels& panels() const; | 72 const Panels& panels() const; |
| 81 | 73 |
| 82 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { | 74 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { |
| 83 return auto_hiding_desktop_bar_; | 75 return auto_hiding_desktop_bar_; |
| 84 } | 76 } |
| 85 | 77 |
| 86 PanelMouseWatcher* mouse_watcher() const { | 78 PanelMouseWatcher* mouse_watcher() const { |
| 87 return panel_mouse_watcher_.get(); | 79 return panel_mouse_watcher_.get(); |
| 88 } | 80 } |
| 89 | 81 |
| 90 PanelStrip* panel_strip() const { | 82 PanelStrip* panel_strip() const { |
| 91 return panel_strip_.get(); | 83 return panel_strip_.get(); |
| 92 } | 84 } |
| 93 | 85 |
| 94 bool is_full_screen() const { return is_full_screen_; } | 86 bool is_full_screen() const { return is_full_screen_; } |
| 95 PanelOverflowStrip* panel_overflow_strip() const { | 87 PanelOverflowStrip* panel_overflow_strip() const { |
| 96 return panel_overflow_strip_.get(); | 88 return panel_overflow_strip_.get(); |
| 97 } | 89 } |
| 98 | 90 |
| 91 // Tests may want to use a mock panel mouse watcher. |
| 92 void SetMouseWatcher(PanelMouseWatcher* watcher); |
| 93 |
| 99 #ifdef UNIT_TEST | 94 #ifdef UNIT_TEST |
| 100 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } | |
| 101 | |
| 102 const gfx::Rect& work_area() const { | |
| 103 return work_area_; | |
| 104 } | |
| 105 | |
| 106 void set_auto_hiding_desktop_bar( | 95 void set_auto_hiding_desktop_bar( |
| 107 AutoHidingDesktopBar* auto_hiding_desktop_bar) { | 96 AutoHidingDesktopBar* auto_hiding_desktop_bar) { |
| 108 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; | 97 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; |
| 109 } | 98 } |
| 110 | 99 |
| 111 void set_mouse_watcher(PanelMouseWatcher* watcher) { | |
| 112 panel_mouse_watcher_.reset(watcher); | |
| 113 } | |
| 114 | |
| 115 void enable_auto_sizing(bool enabled) { | 100 void enable_auto_sizing(bool enabled) { |
| 116 auto_sizing_enabled_ = enabled; | 101 auto_sizing_enabled_ = enabled; |
| 117 } | 102 } |
| 118 | 103 |
| 104 const gfx::Rect& work_area() const { |
| 105 return work_area_; |
| 106 } |
| 107 |
| 119 void SetWorkAreaForTesting(const gfx::Rect& work_area) { | 108 void SetWorkAreaForTesting(const gfx::Rect& work_area) { |
| 120 SetWorkArea(work_area); | 109 SetWorkArea(work_area); |
| 121 } | 110 } |
| 122 | |
| 123 void remove_delays_for_testing() { | |
| 124 panel_strip_->remove_delays_for_testing(); | |
| 125 } | |
| 126 | |
| 127 int minimized_panel_count() { | |
| 128 return panel_strip_->minimized_panel_count(); | |
| 129 } | |
| 130 #endif | 111 #endif |
| 131 | 112 |
| 132 private: | 113 private: |
| 133 friend struct base::DefaultLazyInstanceTraits<PanelManager>; | 114 friend struct base::DefaultLazyInstanceTraits<PanelManager>; |
| 134 | 115 |
| 135 PanelManager(); | 116 PanelManager(); |
| 136 virtual ~PanelManager(); | 117 virtual ~PanelManager(); |
| 137 | 118 |
| 138 // Overridden from AutoHidingDesktopBar::Observer: | 119 // Overridden from AutoHidingDesktopBar::Observer: |
| 139 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE; | 120 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Timer used to track if the current active app is in full screen mode. | 163 // Timer used to track if the current active app is in full screen mode. |
| 183 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; | 164 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; |
| 184 | 165 |
| 185 // True if current active app is in full screen mode. | 166 // True if current active app is in full screen mode. |
| 186 bool is_full_screen_; | 167 bool is_full_screen_; |
| 187 | 168 |
| 188 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 169 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
| 189 }; | 170 }; |
| 190 | 171 |
| 191 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 172 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| OLD | NEW |