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 #include "chrome/browser/ui/panels/panel_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/fullscreen.h" | |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
11 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 12 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
12 #include "chrome/browser/ui/panels/panel_strip.h" | 13 #include "chrome/browser/ui/panels/panel_strip.h" |
13 #include "chrome/browser/ui/window_sizer.h" | 14 #include "chrome/browser/ui/window_sizer.h" |
14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 const int kOverflowStripThickness = 24; | 20 const int kOverflowStripThickness = 24; |
20 | 21 |
21 // Width of spacing around panel strip and the left/right edges of the screen. | 22 // Width of spacing around panel strip and the left/right edges of the screen. |
22 const int kPanelStripLeftMargin = kOverflowStripThickness + 6; | 23 const int kPanelStripLeftMargin = kOverflowStripThickness + 6; |
23 const int kPanelStripRightMargin = 24; | 24 const int kPanelStripRightMargin = 24; |
24 | 25 |
25 // Height of panel strip is based on the factor of the working area. | 26 // Height of panel strip is based on the factor of the working area. |
26 const double kPanelStripHeightFactor = 0.5; | 27 const double kPanelStripHeightFactor = 0.5; |
27 | 28 |
29 static const int kFullScreenModeCheckInterval = 1000; | |
jianli
2011/12/02 00:04:45
nit: either add comment to mention ms or add ms su
prasadt
2011/12/02 00:29:39
Done.
| |
30 | |
28 } // namespace | 31 } // namespace |
29 | 32 |
30 // static | 33 // static |
31 PanelManager* PanelManager::GetInstance() { | 34 PanelManager* PanelManager::GetInstance() { |
32 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; | 35 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; |
33 return instance.Pointer(); | 36 return instance.Pointer(); |
34 } | 37 } |
35 | 38 |
36 PanelManager::PanelManager() | 39 PanelManager::PanelManager() |
37 : panel_mouse_watcher_(PanelMouseWatcher::Create()), | 40 : panel_mouse_watcher_(PanelMouseWatcher::Create()), |
38 auto_sizing_enabled_(true) { | 41 auto_sizing_enabled_(true), |
42 is_full_screen_mode_on_(false) { | |
39 panel_strip_.reset(new PanelStrip(this)); | 43 panel_strip_.reset(new PanelStrip(this)); |
40 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); | 44 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); |
41 OnDisplayChanged(); | 45 OnDisplayChanged(); |
42 } | 46 } |
43 | 47 |
44 PanelManager::~PanelManager() { | 48 PanelManager::~PanelManager() { |
45 } | 49 } |
46 | 50 |
47 void PanelManager::OnDisplayChanged() { | 51 void PanelManager::OnDisplayChanged() { |
48 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( | 52 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 int width = browser->override_bounds().width(); | 87 int width = browser->override_bounds().width(); |
84 int height = browser->override_bounds().height(); | 88 int height = browser->override_bounds().height(); |
85 Panel* panel = new Panel(browser, gfx::Size(width, height)); | 89 Panel* panel = new Panel(browser, gfx::Size(width, height)); |
86 panel_strip_->AddPanel(panel); | 90 panel_strip_->AddPanel(panel); |
87 | 91 |
88 content::NotificationService::current()->Notify( | 92 content::NotificationService::current()->Notify( |
89 chrome::NOTIFICATION_PANEL_ADDED, | 93 chrome::NOTIFICATION_PANEL_ADDED, |
90 content::Source<Panel>(panel), | 94 content::Source<Panel>(panel), |
91 content::NotificationService::NoDetails()); | 95 content::NotificationService::NoDetails()); |
92 | 96 |
97 if (num_panels() == 1) { | |
98 full_screen_mode_timer_.Start(FROM_HERE, | |
99 base::TimeDelta::FromMilliseconds(kFullScreenModeCheckInterval), | |
100 this, &PanelManager::CheckFullScreenMode); | |
101 } | |
102 | |
93 return panel; | 103 return panel; |
94 } | 104 } |
95 | 105 |
96 int PanelManager::StartingRightPosition() const { | 106 int PanelManager::StartingRightPosition() const { |
97 return panel_strip_->StartingRightPosition(); | 107 return panel_strip_->StartingRightPosition(); |
98 } | 108 } |
99 | 109 |
110 void PanelManager::CheckFullScreenMode() { | |
111 bool is_full_screen_mode_on_new = IsFullScreenMode(); | |
112 if (is_full_screen_mode_on_ == is_full_screen_mode_on_new) | |
113 return; | |
114 is_full_screen_mode_on_ = is_full_screen_mode_on_new; | |
115 panel_strip_->OnFullScreenModeChanged(is_full_screen_mode_on_); | |
116 } | |
117 | |
100 void PanelManager::Remove(Panel* panel) { | 118 void PanelManager::Remove(Panel* panel) { |
101 if (panel_strip_->Remove(panel)) | 119 if (panel_strip_->Remove(panel)) |
102 return; | 120 return; |
103 // TODO(jianli): else try removing from overflow strip | 121 // TODO(jianli): else try removing from overflow strip |
104 } | 122 } |
105 | 123 |
106 void PanelManager::OnPanelRemoved(Panel* panel) { | 124 void PanelManager::OnPanelRemoved(Panel* panel) { |
107 content::NotificationService::current()->Notify( | 125 content::NotificationService::current()->Notify( |
108 chrome::NOTIFICATION_PANEL_REMOVED, | 126 chrome::NOTIFICATION_PANEL_REMOVED, |
109 content::Source<Panel>(panel), | 127 content::Source<Panel>(panel), |
110 content::NotificationService::NoDetails()); | 128 content::NotificationService::NoDetails()); |
129 | |
130 if (num_panels() == 0) | |
131 full_screen_mode_timer_.Stop(); | |
111 } | 132 } |
112 | 133 |
113 void PanelManager::StartDragging(Panel* panel) { | 134 void PanelManager::StartDragging(Panel* panel) { |
114 panel_strip_->StartDragging(panel); | 135 panel_strip_->StartDragging(panel); |
115 } | 136 } |
116 | 137 |
117 void PanelManager::Drag(int delta_x) { | 138 void PanelManager::Drag(int delta_x) { |
118 panel_strip_->Drag(delta_x); | 139 panel_strip_->Drag(delta_x); |
119 } | 140 } |
120 | 141 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 // TODO(jianli): + overflow_strip_->num_panels(); | 224 // TODO(jianli): + overflow_strip_->num_panels(); |
204 } | 225 } |
205 | 226 |
206 bool PanelManager::is_dragging_panel() const { | 227 bool PanelManager::is_dragging_panel() const { |
207 return panel_strip_->is_dragging_panel(); | 228 return panel_strip_->is_dragging_panel(); |
208 } | 229 } |
209 | 230 |
210 const PanelManager::Panels& PanelManager::panels() const { | 231 const PanelManager::Panels& PanelManager::panels() const { |
211 return panel_strip_->panels(); | 232 return panel_strip_->panels(); |
212 } | 233 } |
OLD | NEW |