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

Side by Side Diff: headless/app/headless_shell.cc

Issue 2622773003: headless: Allow both WW,HH and WWxHH forms for specifying window size (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <sstream> 6 #include <sstream>
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 38
39 namespace headless { 39 namespace headless {
40 namespace { 40 namespace {
41 // Address where to listen to incoming DevTools connections. 41 // Address where to listen to incoming DevTools connections.
42 const char kDevToolsHttpServerAddress[] = "127.0.0.1"; 42 const char kDevToolsHttpServerAddress[] = "127.0.0.1";
43 // Default file name for screenshot. Can be overriden by "--screenshot" switch. 43 // Default file name for screenshot. Can be overriden by "--screenshot" switch.
44 const char kDefaultScreenshotFileName[] = "screenshot.png"; 44 const char kDefaultScreenshotFileName[] = "screenshot.png";
45 45
46 bool ParseWindowSize(std::string window_size, gfx::Size* parsed_window_size) { 46 bool ParseWindowSize(std::string window_size, gfx::Size* parsed_window_size) {
47 int width, height = 0; 47 int width, height = 0;
48 if (sscanf(window_size.c_str(), "%dx%d", &width, &height) >= 2 && 48 if (sscanf(window_size.c_str(), "%d%*[x,]%d", &width, &height) >= 2 &&
49 width >= 0 && height >= 0) { 49 width >= 0 && height >= 0) {
50 parsed_window_size->set_width(width); 50 parsed_window_size->set_width(width);
51 parsed_window_size->set_height(height); 51 parsed_window_size->set_height(height);
52 return true; 52 return true;
53 } 53 }
54 return false; 54 return false;
55 } 55 }
56 } // namespace 56 } // namespace
57 57
58 // An application which implements a simple headless browser. 58 // An application which implements a simple headless browser.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 471 }
472 builder.SetWindowSize(parsed_window_size); 472 builder.SetWindowSize(parsed_window_size);
473 } 473 }
474 474
475 return HeadlessBrowserMain( 475 return HeadlessBrowserMain(
476 builder.Build(), 476 builder.Build(),
477 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); 477 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
478 } 478 }
479 479
480 } // namespace headless 480 } // namespace headless
OLDNEW
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698