Commit 517b72b5 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Add DCHECK for chrome-proxy header in previews handler

Bug: 1011457
Change-Id: I2ce266270a5189bb3dc4d09de2d193b3d0737209
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846042Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704241}
parent 6ae8da10
......@@ -12,6 +12,7 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/previews/previews_lite_page_redirect_url_loader_interceptor.h"
#include "chrome/browser/profiles/profile.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h"
#include "components/previews/core/previews_experiments.h"
#include "components/previews/core/previews_lite_page_redirect.h"
#include "content/public/browser/browser_context.h"
......@@ -130,6 +131,9 @@ void PreviewsLitePageRedirectURLLoader::StartRedirectToPreview(
network_loader_factory,
int frame_tree_node_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(data_reduction_proxy::DataReductionProxyRequestOptions::
GetSessionKeyFromRequestHeaders(chrome_proxy_headers)
.has_value());
GURL original_url = modified_resource_request_.url;
GURL lite_page_url =
......
......@@ -9,6 +9,7 @@
#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/stl_util.h"
......@@ -71,8 +72,14 @@ net::HttpRequestHeaders GetChromeProxyHeaders(
uint64_t page_id) {
net::HttpRequestHeaders headers;
// Return empty headers for unittests.
if (!browser_context)
if (!browser_context) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
"add-chrome-proxy-header-for-lpr-tests")) {
headers.SetHeader(data_reduction_proxy::chrome_proxy_header(),
"s=secret");
}
return headers;
}
auto* settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
......
......@@ -74,6 +74,9 @@ class PreviewsLitePageRedirectURLLoaderInterceptorTest : public testing::Test {
void TearDown() override {}
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
"add-chrome-proxy-header-for-lpr-tests");
interceptor_ =
std::make_unique<PreviewsLitePageRedirectURLLoaderInterceptor>(
shared_factory_, 1, 2);
......
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