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

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

Issue 2844843002: Override MAXIMIZED window show state if window size / position is manually specified. (Closed)
Patch Set: Added missing unittest file. Created 3 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 *bounds = browser->override_bounds(); 154 *bounds = browser->override_bounds();
155 WindowSizer::GetBrowserWindowBoundsAndShowState(browser->app_name(), 155 WindowSizer::GetBrowserWindowBoundsAndShowState(browser->app_name(),
156 *bounds, 156 *bounds,
157 browser, 157 browser,
158 bounds, 158 bounds,
159 show_state); 159 show_state);
160 160
161 const base::CommandLine& parsed_command_line = 161 const base::CommandLine& parsed_command_line =
162 *base::CommandLine::ForCurrentProcess(); 162 *base::CommandLine::ForCurrentProcess();
163 163
164 if (parsed_command_line.HasSwitch(switches::kWindowSize)) { 164 internal::UpdateWindowBoundsAndShowStateFromCommandLine(parsed_command_line,
165 bounds, show_state);
166 }
167
168 namespace internal {
169
170 void UpdateWindowBoundsAndShowStateFromCommandLine(
171 const base::CommandLine& command_line,
172 gfx::Rect* bounds,
173 ui::WindowShowState* show_state) {
174 // Allow command-line flags to override the window size and position. If
175 // either of these is specified then set the show state to NORMAL so that
176 // they are immediately respected.
177 if (command_line.HasSwitch(switches::kWindowSize)) {
178 std::string str = command_line.GetSwitchValueASCII(switches::kWindowSize);
179 int width, height;
180 if (ParseCommaSeparatedIntegers(str, &width, &height)) {
181 bounds->set_size(gfx::Size(width, height));
182 *show_state = ui::SHOW_STATE_NORMAL;
183 }
184 }
185 if (command_line.HasSwitch(switches::kWindowPosition)) {
165 std::string str = 186 std::string str =
166 parsed_command_line.GetSwitchValueASCII(switches::kWindowSize); 187 command_line.GetSwitchValueASCII(switches::kWindowPosition);
167 int width, height;
168 if (ParseCommaSeparatedIntegers(str, &width, &height))
169 bounds->set_size(gfx::Size(width, height));
170 }
171 if (parsed_command_line.HasSwitch(switches::kWindowPosition)) {
172 std::string str =
173 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition);
174 int x, y; 188 int x, y;
175 if (ParseCommaSeparatedIntegers(str, &x, &y)) 189 if (ParseCommaSeparatedIntegers(str, &x, &y)) {
176 bounds->set_origin(gfx::Point(x, y)); 190 bounds->set_origin(gfx::Point(x, y));
191 *show_state = ui::SHOW_STATE_NORMAL;
192 }
177 } 193 }
178 } 194 }
179 195
196 } // namespace internal
197
180 } // namespace chrome 198 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_window_state.h ('k') | chrome/browser/ui/browser_window_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698