Index: chrome/browser/ui/panels/panel_manager.cc |
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc |
index c918b8a0d9c510fdc0e6ec7146f1df72df4e3fa5..75e96c7f3339667bf00ae670a85f7ffca3588e96 100644 |
--- a/chrome/browser/ui/panels/panel_manager.cc |
+++ b/chrome/browser/ui/panels/panel_manager.cc |
@@ -117,7 +117,7 @@ Panel* PanelManager::CreatePanel(Browser* browser) { |
int width = browser->override_bounds().width(); |
int height = browser->override_bounds().height(); |
Panel* panel = new Panel(browser, gfx::Size(width, height)); |
- panel->MoveToStrip(docked_strip_.get()); |
+ docked_strip_->AddPanel(panel); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_PANEL_ADDED, |
@@ -147,10 +147,11 @@ void PanelManager::CheckFullScreenMode() { |
} |
void PanelManager::OnPanelClosed(Panel* panel) { |
- if (num_panels() == 0) |
+ if (num_panels() == 1) |
full_screen_mode_timer_.Stop(); |
drag_controller_->OnPanelClosed(panel); |
+ panel->panel_strip()->RemovePanel(panel); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_PANEL_CLOSED, |
@@ -192,6 +193,40 @@ void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) { |
docked_strip_->ResizePanelWindow(panel, new_size); |
} |
+void PanelManager::ChangePanelLayout(Panel* panel, |
+ PanelStrip::Type new_layout) { |
+ PanelStrip* current_strip = panel->panel_strip(); |
+ DCHECK(current_strip); |
+ DCHECK_NE(current_strip->type(), new_layout); |
+ current_strip->RemovePanel(panel); |
+ |
+ switch (new_layout) { |
jianli
2012/03/02 00:11:41
Probably better to set the target strip in switch/
jennb
2012/03/02 01:26:32
Done.
|
+ case PanelStrip::DETACHED: |
+ detached_strip_->AddPanel(panel); |
+ break; |
+ case PanelStrip::DOCKED: |
+ docked_strip_->AddPanel(panel); |
+ break; |
+ case PanelStrip::IN_OVERFLOW: |
+ overflow_strip_->AddPanel(panel); |
+ break; |
+ default: |
+ NOTREACHED(); |
+ } |
+ |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE, |
+ content::Source<Panel>(panel), |
+ content::NotificationService::NoDetails()); |
+} |
+ |
+void PanelManager::MovePanelsOutOfOverflowIfCanFit() { |
+ Panel* overflow_panel; |
+ while ((overflow_panel = overflow_strip_->first_panel()) && |
+ docked_strip_->CanFitPanel(overflow_panel)) |
+ ChangePanelLayout(overflow_panel, PanelStrip::DOCKED); |
+} |
+ |
bool PanelManager::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const { |
return docked_strip_->ShouldBringUpTitlebars(mouse_x, mouse_y); |
} |