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

Unified Diff: headless/public/headless_browser.cc

Issue 2720673003: [headless] Use version for product name and user agent. (Closed)
Patch Set: use headless/public/version.h instead. Created 3 years, 10 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/public/headless_browser.h ('k') | headless/public/headless_browser_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_browser.cc
diff --git a/headless/public/headless_browser.cc b/headless/public/headless_browser.cc
index 474809c240472670875a672e0fcd87ed7212d43c..caa24e794d9a5e553e756bf59c315659c33c8fca 100644
--- a/headless/public/headless_browser.cc
+++ b/headless/public/headless_browser.cc
@@ -7,17 +7,22 @@
#include <utility>
#include "content/public/common/user_agent.h"
+#include "headless/public/version.h"
using Options = headless::HeadlessBrowser::Options;
using Builder = headless::HeadlessBrowser::Options::Builder;
namespace headless {
-// Product name for building the default user agent string.
namespace {
+// Product name for building the default user agent string.
const char kProductName[] = "HeadlessChrome";
constexpr gfx::Size kDefaultWindowSize(800, 600);
+
+std::string GetProductNameAndVersion() {
+ return std::string(kProductName) + "/" + PRODUCT_VERSION;
}
+} // namespace
Options::Options(int argc, const char** argv)
: argc(argc),
@@ -26,7 +31,8 @@ Options::Options(int argc, const char** argv)
single_process_mode(false),
disable_sandbox(false),
gl_implementation("osmesa"),
- user_agent(content::BuildUserAgentFromProduct(kProductName)),
+ product_name_and_version(GetProductNameAndVersion()),
+ user_agent(content::BuildUserAgentFromProduct(product_name_and_version)),
window_size(kDefaultWindowSize),
incognito_mode(true),
enable_crash_reporter(false) {}
@@ -43,6 +49,12 @@ Builder::Builder() : options_(0, nullptr) {}
Builder::~Builder() {}
+Builder& Builder::SetProductNameAndVersion(
+ const std::string& product_name_and_version) {
+ options_.product_name_and_version = product_name_and_version;
+ return *this;
+}
+
Builder& Builder::SetUserAgent(const std::string& user_agent) {
options_.user_agent = user_agent;
return *this;
« no previous file with comments | « headless/public/headless_browser.h ('k') | headless/public/headless_browser_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698