#include "content/browser/reduce_accept_language/reduce_accept_language_utils.h"
#include <optional>
#include "base/strings/string_util.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/features.h"
#include "url/origin.h"
namespace content {
namespace {
std::string GetFirstUserAcceptLanguage(
const std::vector<std::string>& user_accept_language) { … }
}
ReduceAcceptLanguageUtils::PersistLanguageResult::PersistLanguageResult() =
default;
ReduceAcceptLanguageUtils::PersistLanguageResult::PersistLanguageResult(
const PersistLanguageResult& other) = default;
ReduceAcceptLanguageUtils::PersistLanguageResult::~PersistLanguageResult() =
default;
ReduceAcceptLanguageUtils::ReduceAcceptLanguageUtils(
ReduceAcceptLanguageControllerDelegate& delegate)
: … { … }
ReduceAcceptLanguageUtils::~ReduceAcceptLanguageUtils() = default;
std::optional<ReduceAcceptLanguageUtils> ReduceAcceptLanguageUtils::Create(
BrowserContext* browser_context) { … }
bool ReduceAcceptLanguageUtils::DoesAcceptLanguageMatchContentLanguage(
const std::string& accept_language,
const std::string& content_language) { … }
bool ReduceAcceptLanguageUtils::OriginCanReduceAcceptLanguage(
const url::Origin& request_origin) { … }
bool ReduceAcceptLanguageUtils::CheckDisableReduceAcceptLanguageOriginTrial(
const GURL& request_url,
FrameTreeNode* frame_tree_node,
OriginTrialsControllerDelegate* origin_trials_delegate) { … }
std::optional<std::string>
ReduceAcceptLanguageUtils::GetFirstMatchPreferredLanguage(
const std::vector<std::string>& preferred_languages,
const std::vector<std::string>& available_languages) { … }
std::optional<std::string>
ReduceAcceptLanguageUtils::AddNavigationRequestAcceptLanguageHeaders(
const url::Origin& request_origin,
FrameTreeNode* frame_tree_node,
net::HttpRequestHeaders* headers) { … }
bool ReduceAcceptLanguageUtils::ReadAndPersistAcceptLanguageForNavigation(
const url::Origin& request_origin,
const net::HttpRequestHeaders& request_headers,
const network::mojom::ParsedHeadersPtr& parsed_headers) { … }
std::optional<std::string>
ReduceAcceptLanguageUtils::LookupReducedAcceptLanguage(
const url::Origin& request_origin,
FrameTreeNode* frame_tree_node) { … }
std::optional<url::Origin>
ReduceAcceptLanguageUtils::GetOriginForLanguageLookup(
const url::Origin& request_origin,
FrameTreeNode* frame_tree_node) { … }
void ReduceAcceptLanguageUtils::RemoveReducedAcceptLanguage(
const url::Origin& origin,
FrameTreeNode* frame_tree_node) { … }
ReduceAcceptLanguageUtils::PersistLanguageResult
ReduceAcceptLanguageUtils::GetLanguageToPersist(
const std::string& initial_accept_language,
const std::vector<std::string>& content_languages,
const std::vector<std::string>& preferred_languages,
const std::vector<std::string>& available_languages) { … }
}