| 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" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 gfx::Rect overflow_area(adjusted_work_area_); | 111 gfx::Rect overflow_area(adjusted_work_area_); |
| 112 overflow_area.set_width(kOverflowStripThickness); | 112 overflow_area.set_width(kOverflowStripThickness); |
| 113 overflow_strip_->SetDisplayArea(overflow_area); | 113 overflow_strip_->SetDisplayArea(overflow_area); |
| 114 } | 114 } |
| 115 | 115 |
| 116 Panel* PanelManager::CreatePanel(Browser* browser) { | 116 Panel* PanelManager::CreatePanel(Browser* browser) { |
| 117 int width = browser->override_bounds().width(); | 117 int width = browser->override_bounds().width(); |
| 118 int height = browser->override_bounds().height(); | 118 int height = browser->override_bounds().height(); |
| 119 Panel* panel = new Panel(browser, gfx::Size(width, height)); | 119 Panel* panel = new Panel(browser, gfx::Size(width, height)); |
| 120 panel->MoveToStrip(docked_strip_.get()); | 120 docked_strip_->AddPanel(panel); |
| 121 | 121 |
| 122 content::NotificationService::current()->Notify( | 122 content::NotificationService::current()->Notify( |
| 123 chrome::NOTIFICATION_PANEL_ADDED, | 123 chrome::NOTIFICATION_PANEL_ADDED, |
| 124 content::Source<Panel>(panel), | 124 content::Source<Panel>(panel), |
| 125 content::NotificationService::NoDetails()); | 125 content::NotificationService::NoDetails()); |
| 126 | 126 |
| 127 if (num_panels() == 1) { | 127 if (num_panels() == 1) { |
| 128 full_screen_mode_timer_.Start(FROM_HERE, | 128 full_screen_mode_timer_.Start(FROM_HERE, |
| 129 base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs), | 129 base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs), |
| 130 this, &PanelManager::CheckFullScreenMode); | 130 this, &PanelManager::CheckFullScreenMode); |
| 131 } | 131 } |
| 132 | 132 |
| 133 return panel; | 133 return panel; |
| 134 } | 134 } |
| 135 | 135 |
| 136 int PanelManager::StartingRightPosition() const { | 136 int PanelManager::StartingRightPosition() const { |
| 137 return docked_strip_->StartingRightPosition(); | 137 return docked_strip_->StartingRightPosition(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void PanelManager::CheckFullScreenMode() { | 140 void PanelManager::CheckFullScreenMode() { |
| 141 bool is_full_screen_new = IsFullScreenMode(); | 141 bool is_full_screen_new = IsFullScreenMode(); |
| 142 if (is_full_screen_ == is_full_screen_new) | 142 if (is_full_screen_ == is_full_screen_new) |
| 143 return; | 143 return; |
| 144 is_full_screen_ = is_full_screen_new; | 144 is_full_screen_ = is_full_screen_new; |
| 145 docked_strip_->OnFullScreenModeChanged(is_full_screen_); | 145 docked_strip_->OnFullScreenModeChanged(is_full_screen_); |
| 146 overflow_strip_->OnFullScreenModeChanged(is_full_screen_); | 146 overflow_strip_->OnFullScreenModeChanged(is_full_screen_); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void PanelManager::OnPanelClosed(Panel* panel) { | 149 void PanelManager::OnPanelClosed(Panel* panel) { |
| 150 if (num_panels() == 0) | 150 if (num_panels() == 1) |
| 151 full_screen_mode_timer_.Stop(); | 151 full_screen_mode_timer_.Stop(); |
| 152 | 152 |
| 153 drag_controller_->OnPanelClosed(panel); | 153 drag_controller_->OnPanelClosed(panel); |
| 154 panel->panel_strip()->RemovePanel(panel); |
| 154 | 155 |
| 155 content::NotificationService::current()->Notify( | 156 content::NotificationService::current()->Notify( |
| 156 chrome::NOTIFICATION_PANEL_CLOSED, | 157 chrome::NOTIFICATION_PANEL_CLOSED, |
| 157 content::Source<Panel>(panel), | 158 content::Source<Panel>(panel), |
| 158 content::NotificationService::NoDetails()); | 159 content::NotificationService::NoDetails()); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void PanelManager::StartDragging(Panel* panel) { | 162 void PanelManager::StartDragging(Panel* panel) { |
| 162 drag_controller_->StartDragging(panel); | 163 drag_controller_->StartDragging(panel); |
| 163 } | 164 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 185 | 186 |
| 186 void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) { | 187 void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) { |
| 187 // Explicit resizing is not allowed for auto-resizable panels for now. | 188 // Explicit resizing is not allowed for auto-resizable panels for now. |
| 188 // http://crbug.com/109343 | 189 // http://crbug.com/109343 |
| 189 if (panel->auto_resizable()) | 190 if (panel->auto_resizable()) |
| 190 return; | 191 return; |
| 191 | 192 |
| 192 docked_strip_->ResizePanelWindow(panel, new_size); | 193 docked_strip_->ResizePanelWindow(panel, new_size); |
| 193 } | 194 } |
| 194 | 195 |
| 196 void PanelManager::ChangePanelLayout(Panel* panel, |
| 197 PanelStrip::Type new_layout) { |
| 198 PanelStrip* current_strip = panel->panel_strip(); |
| 199 DCHECK(current_strip); |
| 200 DCHECK_NE(current_strip->type(), new_layout); |
| 201 current_strip->RemovePanel(panel); |
| 202 |
| 203 switch (new_layout) { |
| 204 case PanelStrip::DETACHED: |
| 205 detached_strip_->AddPanel(panel); |
| 206 break; |
| 207 case PanelStrip::DOCKED: |
| 208 docked_strip_->AddPanel(panel); |
| 209 break; |
| 210 case PanelStrip::IN_OVERFLOW: |
| 211 overflow_strip_->AddPanel(panel); |
| 212 break; |
| 213 default: |
| 214 NOTREACHED(); |
| 215 } |
| 216 |
| 217 content::NotificationService::current()->Notify( |
| 218 chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE, |
| 219 content::Source<Panel>(panel), |
| 220 content::NotificationService::NoDetails()); |
| 221 } |
| 222 |
| 195 bool PanelManager::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const { | 223 bool PanelManager::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const { |
| 196 return docked_strip_->ShouldBringUpTitlebars(mouse_x, mouse_y); | 224 return docked_strip_->ShouldBringUpTitlebars(mouse_x, mouse_y); |
| 197 } | 225 } |
| 198 | 226 |
| 199 void PanelManager::BringUpOrDownTitlebars(bool bring_up) { | 227 void PanelManager::BringUpOrDownTitlebars(bool bring_up) { |
| 200 docked_strip_->BringUpOrDownTitlebars(bring_up); | 228 docked_strip_->BringUpOrDownTitlebars(bring_up); |
| 201 } | 229 } |
| 202 | 230 |
| 203 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() { | 231 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() { |
| 204 // Note that we do not care about the desktop bar aligned to the top edge | 232 // Note that we do not care about the desktop bar aligned to the top edge |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 return panels; | 301 return panels; |
| 274 } | 302 } |
| 275 | 303 |
| 276 int PanelManager::overflow_strip_width() const { | 304 int PanelManager::overflow_strip_width() const { |
| 277 return kOverflowStripThickness; | 305 return kOverflowStripThickness; |
| 278 } | 306 } |
| 279 | 307 |
| 280 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { | 308 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { |
| 281 panel_mouse_watcher_.reset(watcher); | 309 panel_mouse_watcher_.reset(watcher); |
| 282 } | 310 } |
| OLD | NEW |