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 #include "chrome/browser/ui/panels/panel_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/fullscreen.h" | 10 #include "chrome/browser/fullscreen.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/panels/detached_panel_strip.h" | |
13 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 14 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
14 #include "chrome/browser/ui/panels/overflow_panel_strip.h" | 15 #include "chrome/browser/ui/panels/overflow_panel_strip.h" |
16 #include "chrome/browser/ui/panels/panel_drag_controller.h" | |
15 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 17 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
16 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
19 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
21 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
22 | 24 |
23 namespace { | 25 namespace { |
24 const int kOverflowStripThickness = 26; | 26 const int kOverflowStripThickness = 26; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 extension_id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj"); | 58 extension_id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj"); |
57 } | 59 } |
58 | 60 |
59 return true; | 61 return true; |
60 } | 62 } |
61 | 63 |
62 PanelManager::PanelManager() | 64 PanelManager::PanelManager() |
63 : panel_mouse_watcher_(PanelMouseWatcher::Create()), | 65 : panel_mouse_watcher_(PanelMouseWatcher::Create()), |
64 auto_sizing_enabled_(true), | 66 auto_sizing_enabled_(true), |
65 is_full_screen_(false) { | 67 is_full_screen_(false) { |
68 detached_strip_.reset(new DetachedPanelStrip(this)); | |
66 docked_strip_.reset(new DockedPanelStrip(this)); | 69 docked_strip_.reset(new DockedPanelStrip(this)); |
67 overflow_strip_.reset(new OverflowPanelStrip(this)); | 70 overflow_strip_.reset(new OverflowPanelStrip(this)); |
71 drag_controller_.reset(new PanelDragController()); | |
68 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); | 72 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); |
69 OnDisplayChanged(); | 73 OnDisplayChanged(); |
70 } | 74 } |
71 | 75 |
72 PanelManager::~PanelManager() { | 76 PanelManager::~PanelManager() { |
73 } | 77 } |
74 | 78 |
75 void PanelManager::OnDisplayChanged() { | 79 void PanelManager::OnDisplayChanged() { |
76 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
77 // On OSX, panels should be dropped all the way to the bottom edge of the | 81 // On OSX, panels should be dropped all the way to the bottom edge of the |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 if (num_panels() == 0) | 156 if (num_panels() == 0) |
153 full_screen_mode_timer_.Stop(); | 157 full_screen_mode_timer_.Stop(); |
154 #endif | 158 #endif |
155 | 159 |
156 content::NotificationService::current()->Notify( | 160 content::NotificationService::current()->Notify( |
157 chrome::NOTIFICATION_PANEL_REMOVED, | 161 chrome::NOTIFICATION_PANEL_REMOVED, |
158 content::Source<Panel>(panel), | 162 content::Source<Panel>(panel), |
159 content::NotificationService::NoDetails()); | 163 content::NotificationService::NoDetails()); |
160 } | 164 } |
161 | 165 |
162 void PanelManager::StartDragging(Panel* panel) { | 166 bool PanelManager::CanDrag(Panel* panel) const { |
163 docked_strip_->StartDragging(panel); | 167 return panel->panel_strip()->CanDragPanel(panel); |
164 } | 168 } |
165 | 169 |
166 void PanelManager::Drag(int delta_x) { | 170 void PanelManager::StartDragging(Panel* panel) { |
167 docked_strip_->Drag(delta_x); | 171 drag_controller_->StartDragging(panel); |
172 } | |
173 | |
174 void PanelManager::Drag(int delta_x, int delta_y) { | |
175 drag_controller_->Drag(delta_x, delta_y); | |
168 } | 176 } |
169 | 177 |
170 void PanelManager::EndDragging(bool cancelled) { | 178 void PanelManager::EndDragging(bool cancelled) { |
171 docked_strip_->EndDragging(cancelled); | 179 drag_controller_->EndDragging(cancelled); |
172 } | 180 } |
173 | 181 |
174 void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { | 182 void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { |
175 docked_strip_->OnPanelExpansionStateChanged(panel); | 183 docked_strip_->OnPanelExpansionStateChanged(panel); |
176 } | 184 } |
177 | 185 |
178 void PanelManager::OnPreferredWindowSizeChanged( | 186 void PanelManager::OnPreferredWindowSizeChanged( |
179 Panel* panel, const gfx::Size& preferred_window_size) { | 187 Panel* panel, const gfx::Size& preferred_window_size) { |
180 if (!auto_sizing_enabled_) { | 188 if (!auto_sizing_enabled_) { |
181 LOG(INFO) << "Resizing auto-resizable Panels is not supported yet."; | 189 LOG(INFO) << "Resizing auto-resizable Panels is not supported yet."; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 Layout(); | 245 Layout(); |
238 } | 246 } |
239 | 247 |
240 void PanelManager::OnAutoHidingDesktopBarVisibilityChanged( | 248 void PanelManager::OnAutoHidingDesktopBarVisibilityChanged( |
241 AutoHidingDesktopBar::Alignment alignment, | 249 AutoHidingDesktopBar::Alignment alignment, |
242 AutoHidingDesktopBar::Visibility visibility) { | 250 AutoHidingDesktopBar::Visibility visibility) { |
243 docked_strip_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); | 251 docked_strip_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); |
244 } | 252 } |
245 | 253 |
246 void PanelManager::CloseAll() { | 254 void PanelManager::CloseAll() { |
255 DCHECK(!drag_controller_->dragging_panel()); | |
256 | |
257 detached_strip_->CloseAll(); | |
247 docked_strip_->CloseAll(); | 258 docked_strip_->CloseAll(); |
248 overflow_strip_->CloseAll(); | 259 overflow_strip_->CloseAll(); |
249 } | 260 } |
250 | 261 |
251 int PanelManager::num_panels() const { | 262 int PanelManager::num_panels() const { |
252 return docked_strip_->num_panels() + overflow_strip_->num_panels(); | 263 return detached_strip_->num_panels() + |
264 docked_strip_->num_panels() + | |
265 overflow_strip_->num_panels(); | |
253 } | 266 } |
254 | 267 |
255 std::vector<Panel*> PanelManager::panels() const { | 268 std::vector<Panel*> PanelManager::panels() const { |
jennb
2012/02/17 21:28:45
Need to include detached panels here.
jianli
2012/02/17 23:52:56
Done.
| |
256 std::vector<Panel*> panels; | 269 std::vector<Panel*> panels; |
257 for (DockedPanelStrip::Panels::const_iterator iter = | 270 for (DockedPanelStrip::Panels::const_iterator iter = |
258 docked_strip_->panels().begin(); | 271 docked_strip_->panels().begin(); |
259 iter != docked_strip_->panels().end(); ++iter) | 272 iter != docked_strip_->panels().end(); ++iter) |
260 panels.push_back(*iter); | 273 panels.push_back(*iter); |
261 for (OverflowPanelStrip::Panels::const_iterator iter = | 274 for (OverflowPanelStrip::Panels::const_iterator iter = |
262 overflow_strip_->panels().begin(); | 275 overflow_strip_->panels().begin(); |
263 iter != overflow_strip_->panels().end(); ++iter) | 276 iter != overflow_strip_->panels().end(); ++iter) |
264 panels.push_back(*iter); | 277 panels.push_back(*iter); |
265 return panels; | 278 return panels; |
266 } | 279 } |
267 | 280 |
268 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { | 281 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { |
269 panel_mouse_watcher_.reset(watcher); | 282 panel_mouse_watcher_.reset(watcher); |
270 } | 283 } |
OLD | NEW |