Commit b2747ad0 authored by Wez's avatar Wez Committed by Chromium LUCI CQ

Revert "[fuchsia] Allow system config to request Android-ish user agent OS."

This reverts commit f3dce521.

Reason for revert: We have no urgent need for this feature so removing
it in favour of introducing a caller (vs system) controlled API.

Original change's description:
> [fuchsia] Allow system config to request Android-ish user agent OS.
>
> Allow WebEngine to be configured to report an Android-like UserAgent
> via the system-provided config-data, to allow it to be fetch the right
> form of content for the device form-factor.
>
> This will likely be replaced with options to configure the Client Hints
> reported, on a per-instance basis, once those are standardized.
>
> Bug: b/171582703, 1010256
> Change-Id: I9db408be09ec9b9a78facc7b078d635b96c3637b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522071
> Commit-Queue: Wez <wez@chromium.org>
> Commit-Queue: John Abd-El-Malek <jam@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Auto-Submit: Wez <wez@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#825042}

Bug: b/171582703
Bug: 1010256
Change-Id: If513affc89195fb78eafb1e9160e583b41708f38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574976
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834031}
parent 75996c7a
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "base/command_line.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
...@@ -103,22 +102,13 @@ std::string WebEngineContentBrowserClient::GetProduct() { ...@@ -103,22 +102,13 @@ std::string WebEngineContentBrowserClient::GetProduct() {
} }
std::string WebEngineContentBrowserClient::GetUserAgent() { std::string WebEngineContentBrowserClient::GetUserAgent() {
std::string user_agent; std::string user_agent = content::BuildUserAgentFromProduct(GetProduct());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseLegacyAndroidUserAgent)) {
user_agent =
content::BuildUserAgentFromOSAndProduct("Linux; Android", GetProduct());
} else {
user_agent = content::BuildUserAgentFromProduct(GetProduct());
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUserAgentProductAndVersion)) { switches::kUserAgentProductAndVersion)) {
user_agent += user_agent +=
" " + base::CommandLine::ForCurrentProcess()->GetSwitchValueNative( " " + base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kUserAgentProductAndVersion); switches::kUserAgentProductAndVersion);
} }
return user_agent; return user_agent;
} }
......
...@@ -169,7 +169,6 @@ bool MaybeAddCommandLineArgsFromConfig(const base::Value& config, ...@@ -169,7 +169,6 @@ bool MaybeAddCommandLineArgsFromConfig(const base::Value& config,
switches::kForceMaxTextureSize, switches::kForceMaxTextureSize,
switches::kMaxDecodedImageSizeMb, switches::kMaxDecodedImageSizeMb,
switches::kRendererProcessLimit, switches::kRendererProcessLimit,
switches::kUseLegacyAndroidUserAgent,
switches::kWebglAntialiasingMode, switches::kWebglAntialiasingMode,
switches::kWebglMSAASampleCount, switches::kWebglMSAASampleCount,
}; };
......
...@@ -19,7 +19,6 @@ const char kCorsExemptHeaders[] = "cors-exempt-headers"; ...@@ -19,7 +19,6 @@ const char kCorsExemptHeaders[] = "cors-exempt-headers";
const char kEnableCastStreamingReceiver[] = "enable-cast-streaming-receiver"; const char kEnableCastStreamingReceiver[] = "enable-cast-streaming-receiver";
const char kCdmDataDirectory[] = "cdm-data-directory"; const char kCdmDataDirectory[] = "cdm-data-directory";
const char kCdmDataQuotaBytes[] = "cdm-data-quota-bytes"; const char kCdmDataQuotaBytes[] = "cdm-data-quota-bytes";
const char kUseLegacyAndroidUserAgent[] = "use-legacy-android-user-agent";
const char kDataQuotaBytes[] = "data-quota-bytes"; const char kDataQuotaBytes[] = "data-quota-bytes";
} // namespace switches } // namespace switches
...@@ -56,9 +56,6 @@ extern const char kCdmDataDirectory[]; ...@@ -56,9 +56,6 @@ extern const char kCdmDataDirectory[];
// Quota to apply to the CDM user data directory, in bytes. // Quota to apply to the CDM user data directory, in bytes.
extern const char kCdmDataQuotaBytes[]; extern const char kCdmDataQuotaBytes[];
// Enables reporting of an Android-like User Agent string.
extern const char kUseLegacyAndroidUserAgent[];
// Soft quota to apply to the Context's persistent data directory, in bytes. // Soft quota to apply to the Context's persistent data directory, in bytes.
extern const char kDataQuotaBytes[]; extern const char kDataQuotaBytes[];
......
...@@ -71,7 +71,7 @@ class WebEngineIntegrationMediaTest : public WebEngineIntegrationTest { ...@@ -71,7 +71,7 @@ class WebEngineIntegrationMediaTest : public WebEngineIntegrationTest {
std::unique_ptr<media::FakeAudioConsumerService> fake_audio_consumer_service_; std::unique_ptr<media::FakeAudioConsumerService> fake_audio_consumer_service_;
}; };
class WebEngineIntegrationUserAgentTest : public WebEngineIntegrationTestBase { class WebEngineIntegrationUserAgentTest : public WebEngineIntegrationTest {
protected: protected:
GURL GetEchoUserAgentUrl() { GURL GetEchoUserAgentUrl() {
static std::string echo_user_agent_header_path = static std::string echo_user_agent_header_path =
...@@ -81,8 +81,6 @@ class WebEngineIntegrationUserAgentTest : public WebEngineIntegrationTestBase { ...@@ -81,8 +81,6 @@ class WebEngineIntegrationUserAgentTest : public WebEngineIntegrationTestBase {
}; };
TEST_F(WebEngineIntegrationUserAgentTest, ValidProductOnly) { TEST_F(WebEngineIntegrationUserAgentTest, ValidProductOnly) {
StartWebEngine(base::CommandLine(base::CommandLine::NO_PROGRAM));
// Create a Context with just an embedder product specified. // Create a Context with just an embedder product specified.
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
create_params.set_user_agent_product(kValidUserAgentProduct); create_params.set_user_agent_product(kValidUserAgentProduct);
...@@ -95,19 +93,12 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductOnly) { ...@@ -95,19 +93,12 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductOnly) {
ExecuteJavaScriptWithStringResult("document.body.innerText;"); ExecuteJavaScriptWithStringResult("document.body.innerText;");
EXPECT_TRUE(result.find(kValidUserAgentProduct) != std::string::npos); EXPECT_TRUE(result.find(kValidUserAgentProduct) != std::string::npos);
// The UserAgent header should also include the desktop-ish Fuchsia
// platform & OS information, by default.
constexpr char kFuchsiaUserAgentContents[] = "(X11; Fuchsia)";
EXPECT_TRUE(result.find(kFuchsiaUserAgentContents) != std::string::npos);
// Query & verify that the navigator.userAgent contains the product tag. // Query & verify that the navigator.userAgent contains the product tag.
result = ExecuteJavaScriptWithStringResult("navigator.userAgent;"); result = ExecuteJavaScriptWithStringResult("navigator.userAgent;");
EXPECT_TRUE(result.find(kValidUserAgentProduct) != std::string::npos); EXPECT_TRUE(result.find(kValidUserAgentProduct) != std::string::npos);
} }
TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndVersion) { TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndVersion) {
StartWebEngine(base::CommandLine(base::CommandLine::NO_PROGRAM));
// Create a Context with both product and version specified. // Create a Context with both product and version specified.
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
create_params.set_user_agent_product(kValidUserAgentProduct); create_params.set_user_agent_product(kValidUserAgentProduct);
...@@ -129,8 +120,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndVersion) { ...@@ -129,8 +120,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndVersion) {
} }
TEST_F(WebEngineIntegrationUserAgentTest, InvalidProduct) { TEST_F(WebEngineIntegrationUserAgentTest, InvalidProduct) {
StartWebEngine(base::CommandLine(base::CommandLine::NO_PROGRAM));
// Try to create a Context with an invalid embedder product tag. // Try to create a Context with an invalid embedder product tag.
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
create_params.set_user_agent_product(kInvalidUserAgentProduct); create_params.set_user_agent_product(kInvalidUserAgentProduct);
...@@ -138,8 +127,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, InvalidProduct) { ...@@ -138,8 +127,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, InvalidProduct) {
} }
TEST_F(WebEngineIntegrationUserAgentTest, VersionOnly) { TEST_F(WebEngineIntegrationUserAgentTest, VersionOnly) {
StartWebEngine(base::CommandLine(base::CommandLine::NO_PROGRAM));
// Try to create a Context with an embedder version but no product. // Try to create a Context with an embedder version but no product.
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
create_params.set_user_agent_version(kValidUserAgentVersion); create_params.set_user_agent_version(kValidUserAgentVersion);
...@@ -147,8 +134,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, VersionOnly) { ...@@ -147,8 +134,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, VersionOnly) {
} }
TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndInvalidVersion) { TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndInvalidVersion) {
StartWebEngine(base::CommandLine(base::CommandLine::NO_PROGRAM));
// Try to create a Context with valid product tag, but invalid version. // Try to create a Context with valid product tag, but invalid version.
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
create_params.set_user_agent_product(kValidUserAgentProduct); create_params.set_user_agent_product(kValidUserAgentProduct);
...@@ -156,25 +141,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndInvalidVersion) { ...@@ -156,25 +141,6 @@ TEST_F(WebEngineIntegrationUserAgentTest, ValidProductAndInvalidVersion) {
CreateContextAndExpectError(std::move(create_params), ZX_ERR_INVALID_ARGS); CreateContextAndExpectError(std::move(create_params), ZX_ERR_INVALID_ARGS);
} }
TEST_F(WebEngineIntegrationUserAgentTest, UseLegacyAndroidUserAgent) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch("use-legacy-android-user-agent");
StartWebEngine(std::move(command_line));
// Create a Context with both product and version specified.
fuchsia::web::CreateContextParams create_params = DefaultContextParams();
CreateContextAndFrameAndLoadUrl(std::move(create_params),
GetEchoUserAgentUrl());
// Query & verify that the UserAgent header echoed into the document body
// contains the legacy Android data.
constexpr char kLegacyAndroidUserAgentContents[] = "(Linux; Android)";
std::string result =
ExecuteJavaScriptWithStringResult("document.body.innerText;");
EXPECT_TRUE(result.find(kLegacyAndroidUserAgentContents) !=
std::string::npos);
}
// Check that if the CreateContextParams has |remote_debugging_port| set then: // Check that if the CreateContextParams has |remote_debugging_port| set then:
// - DevTools becomes available when the first debuggable Frame is created. // - DevTools becomes available when the first debuggable Frame is created.
// - DevTools closes when the last debuggable Frame is closed. // - DevTools closes when the last debuggable Frame is closed.
......
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