#include "chrome/browser/enterprise/connectors/device_trust/navigation_throttle.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/common_types.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/device_trust_constants.h"
#include "chrome/browser/enterprise/connectors/device_trust/common/metrics_utils.h"
#include "chrome/browser/enterprise/connectors/device_trust/device_trust_service.h"
#include "chrome/browser/enterprise/connectors/device_trust/device_trust_service_factory.h"
#include "chrome/browser/enterprise/signals/user_permission_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/device_signals_consent/consent_requester.h"
#include "components/device_signals/core/browser/pref_names.h"
#include "components/device_signals/core/browser/user_permission_service.h"
#include "components/device_signals/core/common/signals_features.h"
#include "components/enterprise/connectors/core/connectors_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_response_headers.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#endif
namespace enterprise_connectors {
DeviceTrustCallback;
namespace {
constexpr char kErrorPropertyName[] = …;
constexpr char kSpecificErrorCodePropertyName[] = …;
const std::string CreateErrorJsonString(
const DeviceTrustResponse& dt_response) { … }
bool VerifyURL(GURL url) { … }
Profile* GetProfile(content::NavigationHandle* navigation_handle) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
DTOrigin GetAttestationFlowOrigin(content::BrowserContext* context) {
if (context->IsOffTheRecord() && ash::ProfileHelper::IsSigninProfile(
Profile::FromBrowserContext(context))) {
return DTOrigin::kLoginScreen;
}
return DTOrigin::kInSession;
}
#endif
}
constexpr char kDeviceTrustHeader[] = …;
constexpr char kDeviceTrustHeaderValue[] = …;
constexpr char kVerifiedAccessChallengeHeader[] = …;
constexpr char kVerifiedAccessResponseHeader[] = …;
std::unique_ptr<DeviceTrustNavigationThrottle>
DeviceTrustNavigationThrottle::MaybeCreateThrottleFor(
content::NavigationHandle* navigation_handle) { … }
DeviceTrustNavigationThrottle::DeviceTrustNavigationThrottle(
DeviceTrustService* device_trust_service,
device_signals::UserPermissionService* user_permission_service,
content::NavigationHandle* navigation_handle)
: … { … }
DeviceTrustNavigationThrottle::~DeviceTrustNavigationThrottle() = default;
content::NavigationThrottle::ThrottleCheckResult
DeviceTrustNavigationThrottle::WillStartRequest() { … }
content::NavigationThrottle::ThrottleCheckResult
DeviceTrustNavigationThrottle::WillRedirectRequest() { … }
const char* DeviceTrustNavigationThrottle::GetNameForLogging() { … }
content::NavigationThrottle::ThrottleCheckResult
DeviceTrustNavigationThrottle::MayTriggerConsentDialog() { … }
content::NavigationThrottle::ThrottleCheckResult
DeviceTrustNavigationThrottle::AddHeadersIfNeeded() { … }
void DeviceTrustNavigationThrottle::ReplyChallengeResponseAndResume(
base::TimeTicks start_time,
const DeviceTrustResponse& dt_response) { … }
void DeviceTrustNavigationThrottle::OnResponseTimedOut(
base::TimeTicks start_time) { … }
void DeviceTrustNavigationThrottle::OnConsentPrefUpdated() { … }
}