#include "chrome/browser/ui/webui/new_tab_page/untrusted_source.h"
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/files/file_util.h"
#include "base/i18n/rtl.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/new_tab_page/one_google_bar/one_google_bar_data.h"
#include "chrome/browser/new_tab_page/one_google_bar/one_google_bar_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/search/ntp_user_data_logger.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/new_tab_page_resources.h"
#include "components/search/ntp_features.h"
#include "content/public/common/url_constants.h"
#include "net/base/url_util.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "third_party/re2/src/re2/re2.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
#include "url/url_util.h"
namespace {
constexpr int kMaxUriDecodeLen = …;
std::string FormatTemplate(int resource_id,
const ui::TemplateReplacements& replacements) { … }
std::string ReadBackgroundImageData(const base::FilePath& path) { … }
void ServeBackgroundImageData(content::URLDataSource::GotDataCallback callback,
std::string data_string) { … }
}
UntrustedSource::UntrustedSource(Profile* profile)
: … { … }
UntrustedSource::~UntrustedSource() = default;
std::string UntrustedSource::GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) { … }
std::string UntrustedSource::GetSource() { … }
void UntrustedSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) { … }
std::string UntrustedSource::GetMimeType(const GURL& url) { … }
bool UntrustedSource::AllowCaching() { … }
bool UntrustedSource::ShouldReplaceExistingSource() { … }
bool UntrustedSource::ShouldServeMimeTypeAsContentTypeHeader() { … }
bool UntrustedSource::ShouldServiceRequest(
const GURL& url,
content::BrowserContext* browser_context,
int render_process_id) { … }
void UntrustedSource::OnOneGoogleBarDataUpdated() { … }
void UntrustedSource::OnOneGoogleBarServiceShuttingDown() { … }
void UntrustedSource::ServeBackgroundImage(
const GURL& url,
const GURL& url_2x,
const std::string& size,
const std::string& repeat_x,
const std::string& repeat_y,
const std::string& position_x,
const std::string& position_y,
const std::string& scrim_display,
content::URLDataSource::GotDataCallback callback) { … }