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

Unified Diff: headless/app/headless_shell.cc

Issue 2223563002: headless: expose window size through headless_shell switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: allow 0x0 size. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index 1410313ffa8b663ae36e4f6eb1454a2a551726b1..9fafa553a6bd280d0373d5ce9c65759a4288cd33 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -42,7 +42,18 @@ namespace {
const char kDevToolsHttpServerAddress[] = "127.0.0.1";
// Default file name for screenshot. Can be overriden by "--screenshot" switch.
const char kDefaultScreenshotFileName[] = "screenshot.png";
+
+bool ParseWindowSize(std::string window_size, gfx::Size* parsed_window_size) {
+ int width, height = 0;
+ if (sscanf(window_size.c_str(), "%dx%d", &width, &height) >= 2 &&
+ width >= 0 && height >= 0) {
+ parsed_window_size->set_width(width);
+ parsed_window_size->set_height(height);
+ return true;
+ }
+ return false;
}
+} // namespace
// A sample application which demonstrates the use of the headless API.
class HeadlessShell : public HeadlessWebContents::Observer, page::Observer {
@@ -352,6 +363,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;
+ if (!ParseWindowSize(window_size, &parsed_window_size)) {
+ LOG(ERROR) << "Malformed window size";
+ return EXIT_FAILURE;
+ }
+ builder.SetWindowSize(parsed_window_size);
+ }
+
return HeadlessBrowserMain(
builder.Build(),
base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698