#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/privacy_sandbox/tracking_protection_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service_factory.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/webui/ntp/cookie_controls_handler.h"
#include "chrome/browser/ui/webui/webui_util_desktop.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/content_settings/core/common/cookie_controls_enforcement.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "components/reading_list/features/reading_list_switches.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
#include "ui/base/theme_provider.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "ui/chromeos/devicetype_utils.h"
#endif
BrowserThread;
namespace {
const char kLearnMoreIncognitoUrl[] = …"https://support.google.com/chromebook/?p=incognito";
#else
"https://support.google.com/chrome/?p=incognito";
#endif
const char kLearnMoreGuestSessionUrl[] = …"https://support.google.com/chromebook/?p=chromebook_guest";
#else
"https://support.google.com/chrome/?p=ui_guest";
#endif
std::string ReplaceTemplateExpressions(
const scoped_refptr<base::RefCountedMemory>& bytes,
const ui::TemplateReplacements& replacements) { … }
}
SkColor GetThemeColor(const ui::NativeTheme* native_theme,
const ui::ColorProvider& cp,
int id) { … }
std::string GetNewTabBackgroundPositionCSS(
const ui::ThemeProvider& theme_provider) { … }
std::string GetNewTabBackgroundTilingCSS(
const ui::ThemeProvider& theme_provider) { … }
NTPResourceCache::NTPResourceCache(Profile* profile)
: … { … }
NTPResourceCache::~NTPResourceCache() = default;
NTPResourceCache::WindowType NTPResourceCache::GetWindowType(Profile* profile) { … }
base::RefCountedMemory* NTPResourceCache::GetNewTabGuestHTML() { … }
base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(
WindowType win_type,
const content::WebContents::Getter& wc_getter) { … }
base::RefCountedMemory* NTPResourceCache::GetNewTabCSS(
WindowType win_type,
const content::WebContents::Getter& wc_getter) { … }
void NTPResourceCache::OnThemeChanged() { … }
void NTPResourceCache::Shutdown() { … }
void NTPResourceCache::OnNativeThemeUpdated(ui::NativeTheme* updated_theme) { … }
void NTPResourceCache::OnPreferenceChanged() { … }
void NTPResourceCache::Invalidate() { … }
void NTPResourceCache::CreateNewTabIncognitoHTML(
const content::WebContents::Getter& wc_getter) { … }
void NTPResourceCache::CreateNewTabGuestHTML() { … }
void NTPResourceCache::CreateNewTabIncognitoCSS(
const content::WebContents::Getter& wc_getter) { … }
void NTPResourceCache::CreateNewTabCSS(
const content::WebContents::Getter& wc_getter) { … }
void NTPResourceCache::OnPolicyChanged(const base::Value* previous,
const base::Value* current) { … }