File: affiliation_service.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (104 lines) | stat: -rw-r--r-- 4,906 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2020 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_AFFILIATIONS_CORE_BROWSER_AFFILIATION_SERVICE_H_
#define COMPONENTS_AFFILIATIONS_CORE_BROWSER_AFFILIATION_SERVICE_H_

#include <vector>

#include "base/functional/callback_forward.h"
#include "components/affiliations/core/browser/affiliation_source.h"
#include "components/affiliations/core/browser/affiliation_utils.h"
#include "components/keyed_service/core/keyed_service.h"

class GURL;

namespace affiliations {

// A service that can be used to query the list of facets that are affiliated
// with a given facet, i.e., facets that belong to the same logical application.
// See affiliation_utils.h for details of what this means.
class AffiliationService : public KeyedService {
 public:
  using ResultCallback =
      base::OnceCallback<void(const AffiliatedFacets& /* results */,
                              bool /* success */)>;

  using GroupsCallback =
      base::OnceCallback<void(const std::vector<GroupedFacets>&)>;

  // Prefetches change password URLs for sites requested. Receives a callback to
  // run when the prefetch finishes.
  virtual void PrefetchChangePasswordURL(const GURL& urls,
                                         base::OnceClosure callback) = 0;

  // Returns a URL with change password form for a site requested.
  virtual GURL GetChangePasswordURL(const GURL& url) const = 0;

  // Looks up facets affiliated with the facet identified by |facet_uri| and
  // branding information in the local cache if it's fresh. Invokes
  // |result_callback| with the results, it is guaranteed that the results will
  // contain one facet with URI equal to |facet_uri| when |result_callback| is
  // invoked with success set to true.
  virtual void GetAffiliationsAndBranding(
      const FacetURI& facet_uri,
      ResultCallback result_callback) = 0;

  // Prefetches affiliation information for the facet identified by
  // |facet_uri|, and keeps the information fresh by periodic re-fetches (as
  // needed) until the clock strikes |keep_fresh_until| (exclusive), until a
  // matching call to CancelPrefetch(), or until Chrome is shut down,
  // whichever is sooner. It is a supported use-case to pass
  // base::Time::Max() as |keep_fresh_until|.
  //
  // Canceling can be useful when a password is deleted, so that resources
  // are no longer wasted on repeatedly refreshing affiliation information.
  // Note that canceling will not blow away data already stored in the cache
  // unless it becomes stale.
  virtual void Prefetch(const FacetURI& facet_uri,
                        const base::Time& keep_fresh_until) = 0;

  // Cancels the corresponding prefetch command, i.e., the one issued for
  // the same |facet_uri| and with the same |keep_fresh_until|.
  virtual void CancelPrefetch(const FacetURI& facet_uri,
                              const base::Time& keep_fresh_until) = 0;

  // Compares |facet_uris| with a actively prefetching list of facets. For any
  // facet which is present in the |facet_uris| but missing from the list a new
  // prefetch is scheduled. For any facet which is present in the list but
  // missing in |facet_uris| the corresponding prefetch command is canceled. It
  // also deletes cache which is no longer needed.
  virtual void KeepPrefetchForFacets(std::vector<FacetURI> facet_uris) = 0;

  // Wipes results from cache which don't correspond to the any facet from
  // |facet_uris|.
  virtual void TrimUnusedCache(std::vector<FacetURI> facet_uris) = 0;

  // Retrieves stored grouping info for |facet_uris|. If there is no cache for
  // requested facet, the facet will be added to it's own group. This
  // information can be used to group passwords together.
  virtual void GetGroupingInfo(std::vector<FacetURI> facet_uris,
                               GroupsCallback callback) = 0;

  // Retrieves psl extension list. This list includes domain which shouldn't be
  // considered as PSL match.
  virtual void GetPSLExtensions(
      base::OnceCallback<void(std::vector<std::string>)> callback) const = 0;

  // This method will fetch the latest affiliation and branding information for
  // |facets| even if local cache is still fresh. |callback| is invoked on
  // completion.
  virtual void UpdateAffiliationsAndBranding(
      const std::vector<FacetURI>& facets,
      base::OnceClosure callback) = 0;

  // Registers an affiliation source. Affiliation sources are used for
  // prefetching of affiliation data soon after start-up. They are owned by
  // the prefetcher, and observed for changes in their underlying data model to
  // keep an updated cache of affiliations.
  virtual void RegisterSource(std::unique_ptr<AffiliationSource> source) = 0;
};

}  // namespace affiliations
#endif  // COMPONENTS_AFFILIATIONS_CORE_BROWSER_AFFILIATION_SERVICE_H_