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() {
return false;
if (base::FeatureList::IsEnabled(features::kOriginIsolationHeader) &&
response_head_->parsed_headers->origin_isolation) {
response_head_->parsed_headers->origin_agent_cluster) {
return true;
}
......
......@@ -79,8 +79,8 @@ component("cpp") {
"network_switches.h",
"not_implemented_url_loader_factory.cc",
"not_implemented_url_loader_factory.h",
"origin_isolation_parser.cc",
"origin_isolation_parser.h",
"origin_agent_cluster_parser.cc",
"origin_agent_cluster_parser.h",
"parsed_headers.cc",
"parsed_headers.h",
"request_destination.cc",
......@@ -336,7 +336,7 @@ source_set("tests") {
"network_mojom_traits_unittest.cc",
"network_quality_tracker_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",
"schemeful_site_mojom_traits_unittest.cc",
"simple_url_loader_unittest.cc",
......
......@@ -2,12 +2,12 @@
// 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 "services/network/public/cpp/origin_agent_cluster_parser.h"
#include "net/http/structured_headers.h"
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);
return item && item->item.is_boolean() && item->item.GetBoolean();
}
......
......@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_ISOLATION_PARSER_H_
#define SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_ISOLATION_PARSER_H_
#ifndef SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_AGENT_CLUSTER_PARSER_H_
#define SERVICES_NETWORK_PUBLIC_CPP_ORIGIN_AGENT_CLUSTER_PARSER_H_
#include <string>
#include "base/component_export.h"
namespace network {
// Parsing is done following the Origin-Isolation spec draft:
// https://github.com/whatwg/html/pull/5545
// This part of the spec specifically handles header parsing:
// https://html.spec.whatwg.org/C/#initialise-the-document-object
//
// See the comment in network::PopulateParsedHeaders for restrictions on this
// function.
COMPONENT_EXPORT(NETWORK_CPP)
bool ParseOriginIsolation(const std::string&);
bool ParseOriginAgentCluster(const std::string&);
} // 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 @@
#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/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"
namespace network {
......@@ -32,12 +32,12 @@ mojom::ParsedHeadersPtr PopulateParsedHeaders(
parsed_headers->cross_origin_opener_policy = ParseCrossOriginOpenerPolicy(
*headers, parsed_headers->cross_origin_embedder_policy);
// TODO(https://crbug.com/1157917): we implement the change at
// https://github.com/whatwg/html/pull/6214 but all the class and function
// names are not yet updated.
std::string origin_isolation;
if (headers->GetNormalizedHeader("Origin-Agent-Cluster", &origin_isolation))
parsed_headers->origin_isolation = ParseOriginIsolation(origin_isolation);
std::string origin_agent_cluster;
if (headers->GetNormalizedHeader("Origin-Agent-Cluster",
&origin_agent_cluster)) {
parsed_headers->origin_agent_cluster =
ParseOriginAgentCluster(origin_agent_cluster);
}
std::string accept_ch;
if (headers->GetNormalizedHeader("Accept-CH", &accept_ch))
......
......@@ -28,8 +28,8 @@ struct ParsedHeaders {
// Cross-Origin-opener-Policy-Report-Only headers.
CrossOriginOpenerPolicy cross_origin_opener_policy;
// The parsed value of the Origin-Isolation header.
bool origin_isolation = false;
// The parsed value of the Origin-Agent-Cluster header.
bool origin_agent_cluster = false;
// The parsed Accept-CH from response headers.
//
......
......@@ -204,7 +204,7 @@ blink::ParsedHeadersPtr ConvertToBlink(ParsedHeadersPtr parsed_headers) {
ConvertToBlink(std::move(parsed_headers->allow_csp_from)),
std::move(parsed_headers->cross_origin_embedder_policy),
std::move(parsed_headers->cross_origin_opener_policy),
parsed_headers->origin_isolation,
parsed_headers->origin_agent_cluster,
parsed_headers->accept_ch.has_value()
? base::make_optional(
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