Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 9560002: Cleanup to keep panel from manipulating its panel strip assignment directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed unneeded includes Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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) {
jianli 2012/03/02 00:11:41 Probably better to set the target strip in switch/
jennb 2012/03/02 01:26:32 Done.
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
223 void PanelManager::MovePanelsOutOfOverflowIfCanFit() {
224 Panel* overflow_panel;
225 while ((overflow_panel = overflow_strip_->first_panel()) &&
226 docked_strip_->CanFitPanel(overflow_panel))
227 ChangePanelLayout(overflow_panel, PanelStrip::DOCKED);
228 }
229
195 bool PanelManager::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const { 230 bool PanelManager::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const {
196 return docked_strip_->ShouldBringUpTitlebars(mouse_x, mouse_y); 231 return docked_strip_->ShouldBringUpTitlebars(mouse_x, mouse_y);
197 } 232 }
198 233
199 void PanelManager::BringUpOrDownTitlebars(bool bring_up) { 234 void PanelManager::BringUpOrDownTitlebars(bool bring_up) {
200 docked_strip_->BringUpOrDownTitlebars(bring_up); 235 docked_strip_->BringUpOrDownTitlebars(bring_up);
201 } 236 }
202 237
203 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() { 238 void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() {
204 // Note that we do not care about the desktop bar aligned to the top edge 239 // 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
273 return panels; 308 return panels;
274 } 309 }
275 310
276 int PanelManager::overflow_strip_width() const { 311 int PanelManager::overflow_strip_width() const {
277 return kOverflowStripThickness; 312 return kOverflowStripThickness;
278 } 313 }
279 314
280 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { 315 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) {
281 panel_mouse_watcher_.reset(watcher); 316 panel_mouse_watcher_.reset(watcher);
282 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698