chrome: Support configuration of user agent and locale (see issue #2969)

This change adds support for CefSettings and command-line configuration of
user_agent, user_agent_product (formerly product_version) and locale.
This commit is contained in:
Marshall Greenblatt
2021-04-27 12:39:09 -04:00
parent 328de502ac
commit c03a6f4386
10 changed files with 53 additions and 18 deletions

View File

@ -1,22 +1,24 @@
diff --git components/embedder_support/user_agent_utils.cc components/embedder_support/user_agent_utils.cc
index 569518f209aeb..a4944e7060570 100644
index 569518f209aeb..0cf7c2cc23c43 100644
--- components/embedder_support/user_agent_utils.cc
+++ components/embedder_support/user_agent_utils.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/strings/strcat.h"
#include "build/branding_buildflags.h"
+#include "chrome/common/chrome_switches.h"
+#include "cef/libcef/common/cef_switches.h"
#include "components/embedder_support/switches.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/web_contents.h"
@@ -20,6 +21,10 @@
@@ -20,6 +21,12 @@
namespace embedder_support {
std::string GetProduct() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kProductVersion))
+ return command_line->GetSwitchValueASCII(switches::kProductVersion);
+ if (command_line->HasSwitch(switches::kUserAgentProductAndVersion)) {
+ return command_line->GetSwitchValueASCII(
+ switches::kUserAgentProductAndVersion);
+ }
+
return version_info::GetProductNameAndVersionForUserAgent();
}