| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |