1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PERMISSIONS_PERMISSION_USAGE_SESSION_H_
6 #define COMPONENTS_PERMISSIONS_PERMISSION_USAGE_SESSION_H_
8 #include "base/time/time.h"
9 #include "components/content_settings/core/common/content_settings_types.h"
10 #include "url/origin.h"
12 namespace permissions {
14 // Stores information about a permission usage session, which is a continuous
15 // time interval during which some permission was used by some site. For
16 // instance, a usage session could be a time interval during which a site
17 // accessed the camera. {type, origin, usage_start} forms the primary of a
19 struct PermissionUsageSession {
20 // The `origin` accessing the capability. Must not be opaque.
23 ContentSettingsType type;
25 // The time interval in which the capability was accessed, such that
26 // `usage_start` <= `usage_end`, and neither is null.
27 base::Time usage_start;
30 // Specifies if the permission usage started with the browsing context having
31 // transient user activation.
32 bool had_user_activation;
34 // Specifies if the permission usage started in the foreground.
37 // Specifies if the requesting frame had focus at the time the permission.
41 bool operator==(const PermissionUsageSession& other) const;
42 bool operator!=(const PermissionUsageSession& other) const;
44 // Checks if the session satisfies the following constraints:
45 // 1) `origin` is not opaque;
46 // 2) `usage_start` and `usage_end` are not null;
47 // 3) `usage_start` <= `usage_end`.
51 } // namespace permissions
53 #endif // COMPONENTS_PERMISSIONS_PERMISSION_USAGE_SESSION_H_