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

Unified Diff: headless/app/headless_shell.cc

Issue 2805793003: Add user-agent flag to headless (Closed)
Patch Set: Add shell switches to build file Created 3 years, 8 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 | « headless/BUILD.gn ('k') | 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 d6d6adeb758a5ef06ce2821d3973911297b22c74..feeb322cb7dec35de7533967e1fcb8e904a6b50c 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -24,6 +24,7 @@
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
+#include "net/http/http_util.h"
#include "ui/gfx/geometry/size.h"
namespace headless {
@@ -519,6 +520,12 @@ int HeadlessShellMain(int argc, const char** argv) {
WebPreferences* preferences) { preferences->hide_scrollbars = true; }));
}
+ if (command_line.HasSwitch(switches::kUserAgent)) {
+ std::string ua = command_line.GetSwitchValueASCII(switches::kUserAgent);
+ if (net::HttpUtil::IsValidHeaderValue(ua))
+ builder.SetUserAgent(ua);
+ }
+
return HeadlessBrowserMain(
builder.Build(),
base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
« no previous file with comments | « headless/BUILD.gn ('k') | headless/app/headless_shell_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698