#include "components/autofill/content/browser/risk/fingerprint.h"
#include <utility>
#include "base/check.h"
#include "base/cpu.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
#include "components/autofill/content/common/content_autofill_features.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/font_list_async.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/webplugininfo.h"
#include "gpu/config/gpu_info.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ppapi/buildflags/buildflags.h"
#include "services/device/public/cpp/geolocation/geoposition.h"
#include "services/device/public/mojom/geolocation.mojom.h"
#include "services/device/public/mojom/geolocation_client_id.mojom.h"
#include "services/device/public/mojom/geolocation_context.mojom.h"
#include "services/device/public/mojom/geoposition.mojom.h"
#include "ui/display/display.h"
#include "ui/display/display_util.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_PLUGINS)
#include "content/public/browser/plugin_service.h"
#endif
namespace autofill {
namespace risk {
namespace {
const int32_t kFingerprinterVersion = …;
const int kTimeoutSeconds = …;
base::TimeDelta GetTimezoneOffset() { … }
std::string GetOperatingSystemVersion() { … }
void AddFontsToFingerprint(const base::Value::List& fonts,
Fingerprint::MachineCharacteristics* machine) { … }
void AddPluginsToFingerprint(const std::vector<content::WebPluginInfo>& plugins,
Fingerprint::MachineCharacteristics* machine) { … }
void AddAcceptLanguagesToFingerprint(
const std::string& accept_languages_str,
Fingerprint::MachineCharacteristics* machine) { … }
void AddScreenInfoToFingerprint(const display::ScreenInfo& screen_info,
Fingerprint::MachineCharacteristics* machine) { … }
void AddCpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) { … }
void AddGpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine,
content::GpuDataManager& gpu_data_manager) { … }
class FingerprintDataLoader : public content::GpuDataManagerObserver { … };
FingerprintDataLoader::FingerprintDataLoader(
uint64_t obfuscated_gaia_id,
const gfx::Rect& window_bounds,
const gfx::Rect& content_bounds,
const display::ScreenInfo& screen_info,
const std::string& version,
const std::string& charset,
const std::string& accept_languages,
base::Time install_time,
const std::string& app_locale,
const std::string& user_agent,
base::TimeDelta timeout,
base::OnceCallback<void(std::unique_ptr<Fingerprint>)> callback)
: … { … }
void FingerprintDataLoader::OnGpuInfoUpdate() { … }
void FingerprintDataLoader::OnGotFonts(base::Value::List fonts) { … }
void FingerprintDataLoader::OnGotPlugins(
const std::vector<content::WebPluginInfo>& plugins) { … }
void FingerprintDataLoader::OnGotGeoposition(
device::mojom::GeopositionResultPtr result) { … }
void FingerprintDataLoader::MaybeFillFingerprint() { … }
void FingerprintDataLoader::FillFingerprint() { … }
}
namespace internal {
void GetFingerprintInternal(
uint64_t obfuscated_gaia_id,
const gfx::Rect& window_bounds,
const gfx::Rect& content_bounds,
const display::ScreenInfo& screen_info,
const std::string& version,
const std::string& charset,
const std::string& accept_languages,
base::Time install_time,
const std::string& app_locale,
const std::string& user_agent,
base::TimeDelta timeout,
base::OnceCallback<void(std::unique_ptr<Fingerprint>)> callback) { … }
}
void GetFingerprint(
uint64_t obfuscated_gaia_id,
const gfx::Rect& window_bounds,
content::WebContents* web_contents,
const std::string& version,
const std::string& charset,
const std::string& accept_languages,
base::Time install_time,
const std::string& app_locale,
const std::string& user_agent,
base::OnceCallback<void(std::unique_ptr<Fingerprint>)> callback) { … }
}
}