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

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: 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..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)));
« 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