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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer.cc

Issue 23567007: More cleanup in window_sizer/window_sizer_ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 7 years, 3 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/window_sizer/window_sizer.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return false; 91 return false;
92 92
93 // If a reference browser is set, use its window. Otherwise find last 93 // If a reference browser is set, use its window. Otherwise find last
94 // active. Panels are never used as reference browsers as panels are 94 // active. Panels are never used as reference browsers as panels are
95 // specially positioned. 95 // specially positioned.
96 BrowserWindow* window = NULL; 96 BrowserWindow* window = NULL;
97 // Window may be null if browser is just starting up. 97 // Window may be null if browser is just starting up.
98 if (browser_ && browser_->window()) { 98 if (browser_ && browser_->window()) {
99 window = browser_->window(); 99 window = browser_->window();
100 } else { 100 } else {
101 // This code is only ran on the native desktop (on the ash desktop, 101 // This code is only ran on the native desktop (on the ash
102 // GetBoundsOverrideAsh should take over below before this is reached). 102 // desktop, GetTabbedBrowserBoundsAsh should take over below
103 // TODO(gab): This code should go in a native desktop specific window 103 // before this is reached). TODO(gab): This code should go in a
104 // sizer as part of fixing crbug.com/175812. 104 // native desktop specific window sizer as part of fixing
105 // crbug.com/175812.
105 const BrowserList* native_browser_list = 106 const BrowserList* native_browser_list =
106 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); 107 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
107 for (BrowserList::const_reverse_iterator it = 108 for (BrowserList::const_reverse_iterator it =
108 native_browser_list->begin_last_active(); 109 native_browser_list->begin_last_active();
109 it != native_browser_list->end_last_active(); ++it) { 110 it != native_browser_list->end_last_active(); ++it) {
110 Browser* last_active = *it; 111 Browser* last_active = *it;
111 if (last_active && last_active->is_type_tabbed()) { 112 if (last_active && last_active->is_type_tabbed()) {
112 window = last_active->window(); 113 window = last_active->window();
113 DCHECK(window); 114 DCHECK(window);
114 break; 115 break;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 gfx::Rect* bounds, 187 gfx::Rect* bounds,
187 ui::WindowShowState* show_state) const { 188 ui::WindowShowState* show_state) const {
188 DCHECK(bounds); 189 DCHECK(bounds);
189 DCHECK(show_state); 190 DCHECK(show_state);
190 // Pre-populate the window state with our default. 191 // Pre-populate the window state with our default.
191 *show_state = GetWindowDefaultShowState(); 192 *show_state = GetWindowDefaultShowState();
192 *bounds = specified_bounds; 193 *bounds = specified_bounds;
193 if (bounds->IsEmpty()) { 194 if (bounds->IsEmpty()) {
194 #if defined(USE_ASH) 195 #if defined(USE_ASH)
195 // See if ash should decide the window placement. 196 // See if ash should decide the window placement.
196 // TODO(beng): insufficient but currently necessary. 197 if (IsTabbedBrowserInAsh()) {
197 // http://crbug.com/133312 198 GetTabbedBrowserBoundsAsh(bounds, show_state);
198 if (chrome::ShouldOpenAshOnStartup() &&
199 GetBoundsOverrideAsh(bounds, show_state))
200 return; 199 return;
200 } else if (chrome::ShouldOpenAshOnStartup() &&
201 browser_ && browser_->host_desktop_type() ==
202 chrome::HOST_DESKTOP_TYPE_ASH) {
203 // Saved bounds's show state takes precedence over one in last
204 // bounds in ash. If you have a question or an issue, please
205 // contact oshima@chromium.org.
206 GetSavedWindowBounds(bounds, show_state);
207 }
201 #endif 208 #endif
202 // See if there's last active window's placement information. 209 // See if there's last active window's placement information.
203 if (GetLastWindowBounds(bounds, show_state)) 210 if (GetLastWindowBounds(bounds, show_state))
204 return; 211 return;
205 // See if there's saved placement information. 212 // See if there's saved placement information.
206 if (GetSavedWindowBounds(bounds, show_state)) 213 if (GetSavedWindowBounds(bounds, show_state))
207 return; 214 return;
208 // No saved placement, figure out some sensible default size based on 215 // No saved placement, figure out some sensible default size based on
209 // the user's screen size. 216 // the user's screen size.
210 GetDefaultWindowBounds(bounds); 217 GetDefaultWindowBounds(bounds);
211 } else { 218 } else {
212 #if defined(USE_ASH) 219 #if defined(USE_ASH)
213 // In case of a popup with an 'unspecified' location in ash, we are 220 // In case of a popup with an 'unspecified' location in ash, we are
214 // looking for a good screen location. We are interpreting (0,0) as an 221 // looking for a good screen location. We are interpreting (0,0) as an
215 // unspecified location. 222 // unspecified location.
216 if (chrome::ShouldOpenAshOnStartup() && 223 if (IsPopupBrowserInAsh() && bounds->origin().IsOrigin()) {
217 browser_ && browser_->is_type_popup() &&
218 bounds->x() == 0 && bounds->y() == 0) {
219 *bounds = ChromeShellDelegate::instance()->window_positioner()-> 224 *bounds = ChromeShellDelegate::instance()->window_positioner()->
220 GetPopupPosition(*bounds); 225 GetPopupPosition(*bounds);
221 return; 226 return;
222 } 227 }
223 #endif 228 #endif
224 // In case that there was a bound given we need to make sure that it is 229 // In case that there was a bound given we need to make sure that it is
225 // visible and fits on the screen. 230 // visible and fits on the screen.
226 // Find the size of the work area of the monitor that intersects the bounds 231 // Find the size of the work area of the monitor that intersects the bounds
227 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining 232 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining
228 // does not exactly what we want: It makes only sure that "a minimal part" 233 // does not exactly what we want: It makes only sure that "a minimal part"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 397
393 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) 398 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
394 return ui::SHOW_STATE_MAXIMIZED; 399 return ui::SHOW_STATE_MAXIMIZED;
395 400
396 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) 401 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT)
397 return browser_->initial_show_state(); 402 return browser_->initial_show_state();
398 403
399 // Otherwise we use the default which can be overridden later on. 404 // Otherwise we use the default which can be overridden later on.
400 return ui::SHOW_STATE_DEFAULT; 405 return ui::SHOW_STATE_DEFAULT;
401 } 406 }
407
408 #if defined(USE_ASH)
409 bool WindowSizer::IsTabbedBrowserInAsh() const {
410 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312
411 return chrome::ShouldOpenAshOnStartup() &&
412 browser_ &&
413 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
414 browser_->is_type_tabbed();
415 }
416
417 bool WindowSizer::IsPopupBrowserInAsh() const {
418 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312
419 return chrome::ShouldOpenAshOnStartup() &&
420 browser_ &&
421 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
422 browser_->is_type_popup();
423 }
424 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer.h ('k') | chrome/browser/ui/window_sizer/window_sizer_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698