#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt_helper.h"
#include "base/hash/hash.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h"
#include "chrome/browser/ui/profiles/profile_customization_bubble_sync_controller.h"
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
#include "chrome/common/webui_url_constants.h"
#include "components/sync/service/sync_service.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/extension_registry.h"
namespace {
constexpr char kPrivacySandboxPromptHelperEventHistogram[] = …;
PrivacySandboxService::PromptType GetRequiredPromptType(Profile* profile) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool HasExtensionNtpOverride(
extensions::ExtensionRegistry* extension_registry) {
for (const auto& extension : extension_registry->enabled_extensions()) {
const auto& overrides =
extensions::URLOverrides::GetChromeURLOverrides(extension.get());
if (overrides.find(chrome::kChromeUINewTabHost) != overrides.end()) {
return true;
}
}
return false;
}
bool IsChromeControlledNtpUrl(const GURL& url) {
const auto ntp_origin = url::Origin::Create(url);
return ntp_origin ==
url::Origin::Create(GURL(chrome::kChromeUINewTabPageURL)) ||
ntp_origin == url::Origin::Create(
GURL(chrome::kChromeUINewTabPageThirdPartyURL));
}
#endif
}
PrivacySandboxPromptHelper::~PrivacySandboxPromptHelper() = default;
PrivacySandboxPromptHelper::PrivacySandboxPromptHelper(
content::WebContents* web_contents)
: … { … }
void PrivacySandboxPromptHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
bool PrivacySandboxPromptHelper::ProfileRequiresPrompt(Profile* profile) { … }
Profile* PrivacySandboxPromptHelper::profile() { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrivacySandboxPromptHelper);