File: website_settings_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 (143 lines) | stat: -rw-r--r-- 5,276 bytes parent folder | download | duplicates (4)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2015 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_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_INFO_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_INFO_H_

#include <stdint.h>

#include <memory>
#include <string>

#include "base/values.h"
#include "components/content_settings/core/common/content_settings_types.h"

namespace content_settings {

// This class stores the properties related to a website setting.
class WebsiteSettingsInfo {
 public:
  enum SyncStatus {
    // The setting will be synced.
    SYNCABLE,
    // The setting is stored locally.
    UNSYNCABLE
  };

  enum LossyStatus {
    // This marks the setting as "lossy". There is no strict time guarantee on
    // when a lossy setting will be persisted to permanent storage when it is
    // modified.
    LOSSY,
    // Changes to the setting will be persisted immediately.
    NOT_LOSSY
  };

  enum ScopingType {
    // Settings scoped to the origin of the requesting frame that can have
    // exceptions for specific top-level frame origin.
    // Use only after strongly considering if this is the right choice;
    // presenting settings that are scoped on two origins is difficult to get
    // right and often result in surprising UX.
    REQUESTING_ORIGIN_WITH_TOP_ORIGIN_EXCEPTIONS_SCOPE,

    // Settings scoped to the schemeful site of the requesting frame and the
    // top-level frame.
    // Use only after strongly considering if this is the right choice;
    // presenting settings that are scoped on two schemeful sites is difficult
    // to get right and often result in surprising UX.
    REQUESTING_AND_TOP_SCHEMEFUL_SITE_SCOPE,

    // Settings scoped to the origin of the requesting frame and the
    // schemeful site of the top-level frame.
    // Use only after strongly considering if this is the right choice;
    // presenting settings that are scoped on two schemeful sites is difficult
    // to get right and often result in surprising UX.
    REQUESTING_ORIGIN_AND_TOP_SCHEMEFUL_SITE_SCOPE,

    // Setting scoped to the origin of the requesting frame only.
    REQUESTING_ORIGIN_ONLY_SCOPE,

    // Setting scoped to the origin of the top-level frame only.
    TOP_ORIGIN_ONLY_SCOPE,

    // Setting scoped to a single origin. This does not fit into a
    // requesting/top-level origin paradigm and instead simply refers to
    // settings stored on a per-origin basis without defining which origin that
    // is. Use only when |REQUESTING_ORIGIN_ONLY_SCOPE| and
    // |TOP_ORIGIN_ONLY_SCOPE| don't apply.
    //
    // Use this comment section to keep track of cases where a better option
    // than GENERIC_SINGLE_ORIGIN_SCOPE should exist but it's not one of the
    // choices above. If the use cases are sufficient, consider adding new
    // scoping types to account for them:
    // * MEDIA_ENGAGEMENT is always scoped to the origin of the frame that a
    // video is played in. A `FRAME_ORIGIN_ONLY` scope could be considered.
    GENERIC_SINGLE_ORIGIN_SCOPE,

    // Settings scoped to the schemeful site of the requesting frame only.
    // Similar to `REQUESTING_ORIGIN_ONLY_SCOPE` but is site-scoped, not
    // origin-scoped.
    REQUESTING_SCHEMEFUL_SITE_ONLY_SCOPE,
  };

  enum IncognitoBehavior {
    // Settings will be inherited from regular to incognito profiles as usual.
    INHERIT_IN_INCOGNITO,

    // Settings will not be inherited from regular to incognito profiles.
    DONT_INHERIT_IN_INCOGNITO,
  };

  WebsiteSettingsInfo(ContentSettingsType type,
                      const std::string& name,
                      base::Value initial_default_value,
                      SyncStatus sync_status,
                      LossyStatus lossy_status,
                      ScopingType scoping_type,
                      IncognitoBehavior incognito_behavior);

  WebsiteSettingsInfo(const WebsiteSettingsInfo&) = delete;
  WebsiteSettingsInfo& operator=(const WebsiteSettingsInfo&) = delete;

  ~WebsiteSettingsInfo();

  ContentSettingsType type() const { return type_; }
  const std::string& name() const { return name_; }

  const std::string& pref_name() const { return pref_name_; }
  const std::string& partitioned_pref_name() const {
    return partitioned_pref_name_;
  }
  const std::string& default_value_pref_name() const {
    return default_value_pref_name_;
  }
  const base::Value& initial_default_value() const {
    return initial_default_value_;
  }

  uint32_t GetPrefRegistrationFlags() const;

  bool SupportsSecondaryPattern() const;

  ScopingType scoping_type() const { return scoping_type_; }
  IncognitoBehavior incognito_behavior() const { return incognito_behavior_; }

 private:
  const ContentSettingsType type_;
  const std::string name_;

  const std::string pref_name_;
  const std::string partitioned_pref_name_;
  const std::string default_value_pref_name_;
  const base::Value initial_default_value_;
  const SyncStatus sync_status_;
  const LossyStatus lossy_status_;
  const ScopingType scoping_type_;
  const IncognitoBehavior incognito_behavior_;
};

}  // namespace content_settings

#endif  // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_INFO_H_