Commit 67876516 authored by Domenic Denicola's avatar Domenic Denicola Committed by Chromium LUCI CQ

Origin-keyed agent clusters: rename in header parser

942aca88 switched us from parsing the
Origin-Isolation header to parsing the Origin-Agent-Cluster header.
However, it left the file/function/field names unchanged. This followup
aligns them with the new name.

Bug: 1158853
Change-Id: I1d4c931c9480ba9bd1d952112f7013555abe65d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617466
Commit-Queue: Domenic Denicola <domenic@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843541}
parent 1582b199
...@@ -2098,7 +2098,7 @@ bool NavigationRequest::IsOptInIsolationRequested() { ...@@ -2098,7 +2098,7 @@ bool NavigationRequest::IsOptInIsolationRequested() {
return false; return false;
if (base::FeatureList::IsEnabled(features::kOriginIsolationHeader) && if (base::FeatureList::IsEnabled(features::kOriginIsolationHeader) &&
response_head_->parsed_headers->origin_isolation) { response_head_->parsed_headers->origin_agent_cluster) {
return true; return true;
} }
......
...@@ -79,8 +79,8 @@ component("cpp") { ...@@ -79,8 +79,8 @@ component("cpp") {
"network_switches.h", "network_switches.h",
"not_implemented_url_loader_factory.cc", "not_implemented_url_loader_factory.cc",
"not_implemented_url_loader_factory.h", "not_implemented_url_loader_factory.h",
"origin_isolation_parser.cc", "origin_agent_cluster_parser.cc",
"origin_isolation_parser.h", "origin_agent_cluster_parser.h",
"parsed_headers.cc", "parsed_headers.cc",
"parsed_headers.h", "parsed_headers.h",
"request_destination.cc", "request_destination.cc",
...@@ -336,7 +336,7 @@ source_set("tests") { ...@@ -336,7 +336,7 @@ source_set("tests") {
"network_mojom_traits_unittest.cc", "network_mojom_traits_unittest.cc",
"network_quality_tracker_unittest.cc", "network_quality_tracker_unittest.cc",
"optional_trust_token_params_unittest.cc", "optional_trust_token_params_unittest.cc",
"origin_isolation_parser_unittest.cc", "origin_agent_cluster_parser_unittest.cc",
"proxy_config_mojom_traits_unittest.cc", "proxy_config_mojom_traits_unittest.cc",
"schemeful_site_mojom_traits_unittest.cc", "schemeful_site_mojom_traits_unittest.cc",
"simple_url_loader_unittest.cc", "simple_url_loader_unittest.cc",
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/network/public/cpp/origin_isolation_parser.h" #include "services/network/public/cpp/origin_agent_cluster_parser.h"
#include "net/http/structured_headers.h" #include "net/http/structured_headers.h"
namespace network { namespace network {
bool ParseOriginIsolation(const std::string& header_value) { bool ParseOriginAgentCluster(const std::string& header_value) {
const auto item = net::structured_headers::ParseItem(header_value); const auto item = net::structured_headers::ParseItem(header_value);
return item && item->item.is_boolean() && item->item.GetBoolean(); return item && item->item.is_boolean() && item->item.GetBoolean();
} }
......
...@@ -2,22 +2,22 @@ ...@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_ISOLATION_PARSER_H_ #ifndef SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_AGENT_CLUSTER_PARSER_H_
#define SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_ISOLATION_PARSER_H_ #define SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_AGENT_CLUSTER_PARSER_H_
#include <string> #include <string>
#include "base/component_export.h" #include "base/component_export.h"
namespace network { namespace network {
// Parsing is done following the Origin-Isolation spec draft: // This part of the spec specifically handles header parsing:
// https://github.com/whatwg/html/pull/5545 // https://html.spec.whatwg.org/C/#initialise-the-document-object
// //
// See the comment in network::PopulateParsedHeaders for restrictions on this // See the comment in network::PopulateParsedHeaders for restrictions on this
// function. // function.
COMPONENT_EXPORT(NETWORK_CPP) COMPONENT_EXPORT(NETWORK_CPP)
bool ParseOriginIsolation(const std::string&); bool ParseOriginAgentCluster(const std::string&);
} // namespace network } // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_ISOLATION_PARSER_H_ #endif // SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_AGENT_CLUSTER_PARSER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/public/cpp/origin_agent_cluster_parser.h"
#include <string>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
TEST(OriginAgentClusterHeaderTest, Parse) {
EXPECT_EQ(ParseOriginAgentCluster(""), false);
EXPECT_EQ(ParseOriginAgentCluster("?1"), true);
EXPECT_EQ(ParseOriginAgentCluster("?0"), false);
EXPECT_EQ(ParseOriginAgentCluster("?1;param"), true);
EXPECT_EQ(ParseOriginAgentCluster("?1;param=value"), true);
EXPECT_EQ(ParseOriginAgentCluster("?1;param=value;param2=value2"), true);
EXPECT_EQ(ParseOriginAgentCluster("true"), false);
EXPECT_EQ(ParseOriginAgentCluster("\"?1\""), false);
EXPECT_EQ(ParseOriginAgentCluster("1"), false);
EXPECT_EQ(ParseOriginAgentCluster("?2"), false);
EXPECT_EQ(ParseOriginAgentCluster("(?1)"), false);
}
} // namespace network
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/public/cpp/origin_isolation_parser.h"
#include <string>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
TEST(OriginIsolationHeaderTest, Parse) {
EXPECT_EQ(ParseOriginIsolation(""), false);
EXPECT_EQ(ParseOriginIsolation("?1"), true);
EXPECT_EQ(ParseOriginIsolation("?0"), false);
EXPECT_EQ(ParseOriginIsolation("?1;param"), true);
EXPECT_EQ(ParseOriginIsolation("?1;param=value"), true);
EXPECT_EQ(ParseOriginIsolation("?1;param=value;param2=value2"), true);
EXPECT_EQ(ParseOriginIsolation("true"), false);
EXPECT_EQ(ParseOriginIsolation("\"?1\""), false);
EXPECT_EQ(ParseOriginIsolation("1"), false);
EXPECT_EQ(ParseOriginIsolation("?2"), false);
EXPECT_EQ(ParseOriginIsolation("(?1)"), false);
}
} // namespace network
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "services/network/public/cpp/cross_origin_embedder_policy_parser.h" #include "services/network/public/cpp/cross_origin_embedder_policy_parser.h"
#include "services/network/public/cpp/cross_origin_opener_policy_parser.h" #include "services/network/public/cpp/cross_origin_opener_policy_parser.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/origin_isolation_parser.h" #include "services/network/public/cpp/origin_agent_cluster_parser.h"
#include "services/network/public/cpp/x_frame_options_parser.h" #include "services/network/public/cpp/x_frame_options_parser.h"
namespace network { namespace network {
...@@ -32,12 +32,12 @@ mojom::ParsedHeadersPtr PopulateParsedHeaders( ...@@ -32,12 +32,12 @@ mojom::ParsedHeadersPtr PopulateParsedHeaders(
parsed_headers->cross_origin_opener_policy = ParseCrossOriginOpenerPolicy( parsed_headers->cross_origin_opener_policy = ParseCrossOriginOpenerPolicy(
*headers, parsed_headers->cross_origin_embedder_policy); *headers, parsed_headers->cross_origin_embedder_policy);
// TODO(https://crbug.com/1157917): we implement the change at std::string origin_agent_cluster;
// https://github.com/whatwg/html/pull/6214 but all the class and function if (headers->GetNormalizedHeader("Origin-Agent-Cluster",
// names are not yet updated. &origin_agent_cluster)) {
std::string origin_isolation; parsed_headers->origin_agent_cluster =
if (headers->GetNormalizedHeader("Origin-Agent-Cluster", &origin_isolation)) ParseOriginAgentCluster(origin_agent_cluster);
parsed_headers->origin_isolation = ParseOriginIsolation(origin_isolation); }
std::string accept_ch; std::string accept_ch;
if (headers->GetNormalizedHeader("Accept-CH", &accept_ch)) if (headers->GetNormalizedHeader("Accept-CH", &accept_ch))
......
...@@ -28,8 +28,8 @@ struct ParsedHeaders { ...@@ -28,8 +28,8 @@ struct ParsedHeaders {
// Cross-Origin-opener-Policy-Report-Only headers. // Cross-Origin-opener-Policy-Report-Only headers.
CrossOriginOpenerPolicy cross_origin_opener_policy; CrossOriginOpenerPolicy cross_origin_opener_policy;
// The parsed value of the Origin-Isolation header. // The parsed value of the Origin-Agent-Cluster header.
bool origin_isolation = false; bool origin_agent_cluster = false;
// The parsed Accept-CH from response headers. // The parsed Accept-CH from response headers.
// //
......
...@@ -204,7 +204,7 @@ blink::ParsedHeadersPtr ConvertToBlink(ParsedHeadersPtr parsed_headers) { ...@@ -204,7 +204,7 @@ blink::ParsedHeadersPtr ConvertToBlink(ParsedHeadersPtr parsed_headers) {
ConvertToBlink(std::move(parsed_headers->allow_csp_from)), ConvertToBlink(std::move(parsed_headers->allow_csp_from)),
std::move(parsed_headers->cross_origin_embedder_policy), std::move(parsed_headers->cross_origin_embedder_policy),
std::move(parsed_headers->cross_origin_opener_policy), std::move(parsed_headers->cross_origin_opener_policy),
parsed_headers->origin_isolation, parsed_headers->origin_agent_cluster,
parsed_headers->accept_ch.has_value() parsed_headers->accept_ch.has_value()
? base::make_optional( ? base::make_optional(
ConvertToBlink(parsed_headers->accept_ch.value())) ConvertToBlink(parsed_headers->accept_ch.value()))
......
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