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

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

Issue 11072002: Combined window positioning and show state determiniation in the WindowSizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/browser_window_state.h" 5 #include "chrome/browser/ui/browser_window_state.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "chrome/browser/defaults.h" 9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Save to the session storage service, used when reloading a past session. 73 // Save to the session storage service, used when reloading a past session.
74 // Note that we don't want to be the ones who cause lazy initialization of 74 // Note that we don't want to be the ones who cause lazy initialization of
75 // the session service. This function gets called during initial window 75 // the session service. This function gets called during initial window
76 // showing, and we don't want to bring in the session service this early. 76 // showing, and we don't want to bring in the session service this early.
77 SessionService* session_service = 77 SessionService* session_service =
78 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); 78 SessionServiceFactory::GetForProfileIfExisting(browser->profile());
79 if (session_service) 79 if (session_service)
80 session_service->SetWindowBounds(browser->session_id(), bounds, show_state); 80 session_service->SetWindowBounds(browser->session_id(), bounds, show_state);
81 } 81 }
82 82
83 gfx::Rect GetSavedWindowBounds(const Browser* browser) { 83 gfx::Rect GetSavedWindowBoundsAndShowState(const Browser* browser,
84 ui::WindowShowState& show_state) {
84 gfx::Rect restored_bounds = browser->override_bounds(); 85 gfx::Rect restored_bounds = browser->override_bounds();
85 WindowSizer::GetBrowserWindowBounds(browser->app_name(), 86 WindowSizer::GetBrowserWindowBoundsAndShowState(browser->app_name(),
86 restored_bounds, 87 restored_bounds,
87 browser, 88 browser,
88 &restored_bounds); 89 &restored_bounds,
90 show_state);
89 91
90 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 92 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
91 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode); 93 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode);
92 bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode); 94 bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode);
93 if (record_mode || playback_mode) { 95 if (record_mode || playback_mode) {
94 // In playback/record mode we always fix the size of the browser and 96 // In playback/record mode we always fix the size of the browser and
95 // move it to (0,0). The reason for this is two reasons: First we want 97 // move it to (0,0). The reason for this is two reasons: First we want
96 // resize/moves in the playback to still work, and Second we want 98 // resize/moves in the playback to still work, and Second we want
97 // playbacks to work (as much as possible) on machines w/ different 99 // playbacks to work (as much as possible) on machines w/ different
98 // screen sizes. 100 // screen sizes.
(...skipping 12 matching lines...) Expand all
111 std::string str = 113 std::string str =
112 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition); 114 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition);
113 int x, y; 115 int x, y;
114 if (ParseCommaSeparatedIntegers(str, &x, &y)) 116 if (ParseCommaSeparatedIntegers(str, &x, &y))
115 restored_bounds.set_origin(gfx::Point(x, y)); 117 restored_bounds.set_origin(gfx::Point(x, y));
116 } 118 }
117 119
118 return restored_bounds; 120 return restored_bounds;
119 } 121 }
120 122
121 ui::WindowShowState GetSavedWindowShowState(const Browser* browser) {
122 // Only tabbed browsers use the command line or preference state, with the
123 // exception of devtools.
124 bool show_state = !browser->is_type_tabbed() && !browser->is_devtools();
125
126 #if defined(USE_AURA)
127 // Apps save state on aura.
128 show_state &= !browser->is_app();
129 #endif
130
131 if (show_state)
132 return browser->initial_show_state();
133
134 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
135 return ui::SHOW_STATE_MAXIMIZED;
136
137 if (browser->initial_show_state() != ui::SHOW_STATE_DEFAULT)
138 return browser->initial_show_state();
139
140 const DictionaryValue* window_pref = browser->profile()->GetPrefs()->
141 GetDictionary(GetWindowPlacementKey(browser).c_str());
142 bool maximized = false;
143 window_pref->GetBoolean("maximized", &maximized);
144
145 return maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_DEFAULT;
146 }
147
148 } // namespace chrome 123 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698