Chromium Code Reviews| Index: headless/app/headless_shell.cc |
| diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc |
| index 1410313ffa8b663ae36e4f6eb1454a2a551726b1..fb6cba31b420c7499d7cd64d81724e01e3016a9e 100644 |
| --- a/headless/app/headless_shell.cc |
| +++ b/headless/app/headless_shell.cc |
| @@ -42,7 +42,14 @@ namespace { |
| const char kDevToolsHttpServerAddress[] = "127.0.0.1"; |
| // Default file name for screenshot. Can be overriden by "--screenshot" switch. |
| const char kDefaultScreenshotFileName[] = "screenshot.png"; |
| + |
| +gfx::Size WindowSizeFromString(std::string window_size) { |
| + int width, height = 0; |
| + if (sscanf(window_size.c_str(), "%dx%d", &width, &height) >= 2) |
| + return gfx::Size(width, height); |
| + return gfx::Size(); |
| } |
| +} // namespace |
| // A sample application which demonstrates the use of the headless API. |
| class HeadlessShell : public HeadlessWebContents::Observer, page::Observer { |
| @@ -352,6 +359,17 @@ int main(int argc, const char** argv) { |
| builder.SetIncognitoMode(false); |
| } |
| + if (command_line.HasSwitch(headless::switches::kWindowSize)) { |
| + std::string window_size = |
| + command_line.GetSwitchValueASCII(headless::switches::kWindowSize); |
| + gfx::Size parsed_window_size = WindowSizeFromString(window_size); |
| + if (parsed_window_size.IsEmpty()) { |
|
Sami
2016/08/05 18:18:25
0x0 might be useful in some cases -- could we allo
Eric Seckler
2016/08/05 18:40:02
Done.
|
| + LOG(ERROR) << "Malformed window size"; |
| + return EXIT_FAILURE; |
| + } |
| + builder.SetWindowSize(parsed_window_size); |
| + } |
| + |
| return HeadlessBrowserMain( |
| builder.Build(), |
| base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |