Commit 820846a9 authored by David Black's avatar David Black Committed by Commit Bot

Adds user agent to LibAssistant internal config.

Setting user agent via InternalOptions is deprecated in LibAssistant
1.42s. Prior to upreving LibAssistant we need to set user agent via
internal config.

A follow up CL will remove the code which sets user agent via
InternalOptions and we will uprev that change in tandem with upreving
the 1.42s changes to avoid breaking the public build.

Bug: b:138583234
Change-Id: I110a7f16ea53f38eaeac7f7065e628f7eec1ffc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724829Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#681886}
parent e4548b72
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "base/values.h" #include "base/values.h"
#include "build/util/webkit_version.h"
#include "chromeos/assistant/internal/internal_constants.h" #include "chromeos/assistant/internal/internal_constants.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/util/version_loader.h" #include "chromeos/dbus/util/version_loader.h"
...@@ -21,6 +23,21 @@ ...@@ -21,6 +23,21 @@
namespace chromeos { namespace chromeos {
namespace assistant { namespace assistant {
namespace {
void CreateUserAgent(std::string* user_agent) {
DCHECK(user_agent->empty());
base::StringAppendF(user_agent,
"Mozilla/5.0 (X11; CrOS %s %s; %s) "
"AppleWebKit/%d.%d (KHTML, like Gecko)",
base::SysInfo::OperatingSystemArchitecture().c_str(),
base::SysInfo::OperatingSystemVersion().c_str(),
base::SysInfo::GetLsbReleaseBoard().c_str(),
WEBKIT_VERSION_MAJOR, WEBKIT_VERSION_MINOR);
}
} // namespace
// Get the root path for assistant files. // Get the root path for assistant files.
base::FilePath GetRootPath() { base::FilePath GetRootPath() {
base::FilePath home_dir; base::FilePath home_dir;
...@@ -53,6 +70,10 @@ std::string CreateLibAssistantConfig() { ...@@ -53,6 +70,10 @@ std::string CreateLibAssistantConfig() {
Value internal(Type::DICTIONARY); Value internal(Type::DICTIONARY);
internal.SetKey("surface_type", Value("OPA_CROS")); internal.SetKey("surface_type", Value("OPA_CROS"));
std::string user_agent;
CreateUserAgent(&user_agent);
internal.SetKey("user_agent", Value(user_agent));
// Prevent LibAssistant from automatically playing ready message TTS during // Prevent LibAssistant from automatically playing ready message TTS during
// the startup sequence when the version of LibAssistant has been upgraded. // the startup sequence when the version of LibAssistant has been upgraded.
internal.SetKey("override_ready_message", Value(true)); internal.SetKey("override_ready_message", Value(true));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment