summaryrefslogtreecommitdiff
path: root/chromium/extensions/common/identifiability_metrics.h
blob: 591e6e1de745dd06ad0fad28d37d4c0f5b6ee524 (plain)
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
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_COMMON_IDENTIFIABILITY_METRICS_H_
#define EXTENSIONS_COMMON_IDENTIFIABILITY_METRICS_H_

#include "extensions/common/extension_id.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_surface.h"

class GURL;

namespace extensions {

// Encodes |type| and |extension_id| as an identifiability surface.
blink::IdentifiableSurface SurfaceForExtension(
    blink::IdentifiableSurface::Type type,
    const ExtensionId& extension_id);

// Used for histograms. Do not reorder.
enum class ExtensionResourceAccessResult : int {
  kSuccess,
  kCancel,   // Only logged on navigation when the navigation is cancelled and
             // the document stays in place.
  kFailure,  // resource load failed or navigation to some sort of error page.
};

// Records results of attempts to access an extension resource at the url
// |gurl|. Done as part of a study to see if this is being used as a
// fingerprinting method.
void RecordExtensionResourceAccessResult(ukm::SourceIdObj ukm_source_id,
                                         const GURL& gurl,
                                         ExtensionResourceAccessResult result);

// Records that the extension |extension_id| has injected a content script into
// page identified by |ukm_source_id|.
void RecordContentScriptInjection(ukm::SourceIdObj ukm_source_id,
                                  const ExtensionId& extension_id);

// Records that the extension |extension_id| has blocked a network request on
// page identified by |ukm_source_id|.
void RecordNetworkRequestBlocked(ukm::SourceIdObj ukm_source_id,
                                 const ExtensionId& extension_id);

}  // namespace extensions

#endif  // EXTENSIONS_COMMON_IDENTIFIABILITY_METRICS_H_