File: referring_app_info.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (80 lines) | stat: -rw-r--r-- 3,016 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SAFE_BROWSING_CORE_BROWSER_REFERRING_APP_INFO_H_
#define COMPONENTS_SAFE_BROWSING_CORE_BROWSER_REFERRING_APP_INFO_H_

#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "url/gurl.h"

namespace safe_browsing {
namespace internal {

// Describes the result of an attempt to obtain the data to fill in
// ReferringAppInfo.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(GetReferringAppInfoResult)
enum class GetReferringAppInfoResult {
  // Lookup not attempted (e.g. because no WebContents was found).
  kNotAttempted = 0,
  // There was no referring app found, and no referring WebAPK found.
  kReferringAppNotFoundWebapkNotFound = 1,
  // There was no referring app, but a referring WebAPK was found.
  kReferringAppNotFoundWebapkFound = 2,
  // A referring app was found. No referring WebAPK was found.
  kReferringAppFoundWebapkNotFound = 3,
  // Both a referring app, and a referring WebAPK were found.
  kReferringAppFoundWebapkFound = 4,

  kMaxValue = kReferringAppFoundWebapkFound,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/sb_client/enums.xml:SafeBrowsingAndroidGetReferringAppInfoResult)

// This struct contains data needed to compute the ReferringAppInfo proto and
// other fields related to the referring app. For Android app referrers, these
// fields are obtained in SafeBrowsingReferringAppBridge.java which passes an
// analog of this struct over jni.
struct ReferringAppInfo {
  ReferringAppInfo();
  ~ReferringAppInfo();

  ReferringAppInfo(const ReferringAppInfo&);
  ReferringAppInfo(ReferringAppInfo&&);
  ReferringAppInfo& operator=(const ReferringAppInfo&);
  ReferringAppInfo& operator=(ReferringAppInfo&&);

  bool has_referring_app() const { return !referring_app_name.empty(); }

  bool has_referring_webapk() const {
    return referring_webapk_start_url.is_valid();
  }

  safe_browsing::ReferringAppInfo::ReferringAppSource referring_app_source =
      safe_browsing::ReferringAppInfo::REFERRING_APP_SOURCE_UNSPECIFIED;

  std::string referring_app_name;
  GURL target_url;

  // These fields are populated if the referring app is a WebAPK. They
  // are used to compute the SafeBrowsingWebAppKey in ReferringAppInfo.
  GURL referring_webapk_start_url;
  GURL referring_webapk_manifest_id;
};

// Gets a value of the GetReferringAppInfoResult enum that describes the values
// present in `info`.
GetReferringAppInfoResult ReferringAppInfoToResult(
    const ReferringAppInfo& info);

}  // namespace internal

// Constructs a ReferringAppInfo proto composed of the data in an
// internal::ReferringAppInfo.
ReferringAppInfo GetReferringAppInfoProto(
    const internal::ReferringAppInfo& info);

}  // namespace safe_browsing

#endif  // COMPONENTS_SAFE_BROWSING_CORE_BROWSER_REFERRING_APP_INFO_H_