| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 void PanelManager::StartDragging(Panel* panel) { |
| 163 docked_strip_->StartDragging(panel); | 167 drag_controller_->StartDragging(panel); |
| 164 } | 168 } |
| 165 | 169 |
| 166 void PanelManager::Drag(int delta_x) { | 170 void PanelManager::Drag(int delta_x, int delta_y) { |
| 167 docked_strip_->Drag(delta_x); | 171 drag_controller_->Drag(delta_x, delta_y); |
| 168 } | 172 } |
| 169 | 173 |
| 170 void PanelManager::EndDragging(bool cancelled) { | 174 void PanelManager::EndDragging(bool cancelled) { |
| 171 docked_strip_->EndDragging(cancelled); | 175 drag_controller_->EndDragging(cancelled); |
| 172 } | 176 } |
| 173 | 177 |
| 174 void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { | 178 void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { |
| 175 docked_strip_->OnPanelExpansionStateChanged(panel); | 179 docked_strip_->OnPanelExpansionStateChanged(panel); |
| 176 } | 180 } |
| 177 | 181 |
| 178 void PanelManager::OnPreferredWindowSizeChanged( | 182 void PanelManager::OnPreferredWindowSizeChanged( |
| 179 Panel* panel, const gfx::Size& preferred_window_size) { | 183 Panel* panel, const gfx::Size& preferred_window_size) { |
| 180 if (!auto_sizing_enabled_) { | 184 if (!auto_sizing_enabled_) { |
| 181 LOG(INFO) << "Resizing auto-resizable Panels is not supported yet."; | 185 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(); | 241 Layout(); |
| 238 } | 242 } |
| 239 | 243 |
| 240 void PanelManager::OnAutoHidingDesktopBarVisibilityChanged( | 244 void PanelManager::OnAutoHidingDesktopBarVisibilityChanged( |
| 241 AutoHidingDesktopBar::Alignment alignment, | 245 AutoHidingDesktopBar::Alignment alignment, |
| 242 AutoHidingDesktopBar::Visibility visibility) { | 246 AutoHidingDesktopBar::Visibility visibility) { |
| 243 docked_strip_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); | 247 docked_strip_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); |
| 244 } | 248 } |
| 245 | 249 |
| 246 void PanelManager::CloseAll() { | 250 void PanelManager::CloseAll() { |
| 251 DCHECK(!drag_controller_->IsDragging()); |
| 252 |
| 253 detached_strip_->CloseAll(); |
| 247 docked_strip_->CloseAll(); | 254 docked_strip_->CloseAll(); |
| 248 overflow_strip_->CloseAll(); | 255 overflow_strip_->CloseAll(); |
| 249 } | 256 } |
| 250 | 257 |
| 251 int PanelManager::num_panels() const { | 258 int PanelManager::num_panels() const { |
| 252 return docked_strip_->num_panels() + overflow_strip_->num_panels(); | 259 return detached_strip_->num_panels() + |
| 260 docked_strip_->num_panels() + |
| 261 overflow_strip_->num_panels(); |
| 253 } | 262 } |
| 254 | 263 |
| 255 std::vector<Panel*> PanelManager::panels() const { | 264 std::vector<Panel*> PanelManager::panels() const { |
| 256 std::vector<Panel*> panels; | 265 std::vector<Panel*> panels; |
| 266 for (DetachedPanelStrip::Panels::const_iterator iter = |
| 267 detached_strip_->panels().begin(); |
| 268 iter != detached_strip_->panels().end(); ++iter) |
| 269 panels.push_back(*iter); |
| 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 |