File: content_settings_info.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; 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 (98 lines) | stat: -rw-r--r-- 3,784 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
// 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_CONTENT_SETTINGS_INFO_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_INFO_H_

#include <set>
#include <string>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "components/content_settings/core/common/content_settings.h"

namespace content_settings {

class WebsiteSettingsInfo;

class ContentSettingsInfo {
 public:
  enum IncognitoBehavior {
    // Content setting will be inherited from regular to incognito profiles
    // as usual. This should only be used for features that don't allow access
    // to user data e.g. popup blocker or features that are allowed by default.
    INHERIT_IN_INCOGNITO,

    // Content settings can be inherited if the setting is less permissive
    // than the initial default value of the content setting. Example: A setting
    // with an initial value of ASK will be inherited if it is set to BLOCK or
    // ASK but ALLOW will become ASK in incognito mode. This should be used for
    // all settings that allow access to user data, e.g. geolocation.
    INHERIT_IF_LESS_PERMISSIVE,

    // Content settings will not be inherited from regular to incognito
    // profiles. This should only be used in special cases, for settings that
    // are not controlled-by/exposed-to the user.
    DONT_INHERIT_IN_INCOGNITO
  };

  enum OriginRestriction {
    // This flag indicates content types that only allow exceptions to be set
    // on secure origins.
    EXCEPTIONS_ON_SECURE_ORIGINS_ONLY,
    // This flag indicates content types that allow exceptions to be set on
    // secure and insecure origins.
    EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS,
  };

  // This object does not take ownership of |website_settings_info|.
  ContentSettingsInfo(
      const WebsiteSettingsInfo* website_settings_info,
      const std::vector<std::string>& allowlisted_primary_schemes,
      const std::set<ContentSetting>& valid_settings,
      IncognitoBehavior incognito_behavior,
      OriginRestriction origin_restriction);

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

  ~ContentSettingsInfo();

  const WebsiteSettingsInfo* website_settings_info() const {
    return website_settings_info_;
  }
  const std::vector<std::string>& allowlisted_primary_schemes() const {
    return allowlisted_primary_schemes_;
  }

  void set_third_party_cookie_allowed_secondary_schemes(
      const std::vector<std::string>& allowed_schemes) {
    third_party_cookie_allowed_secondary_schemes_ = allowed_schemes;
  }
  const std::vector<std::string>& third_party_cookie_allowed_secondary_schemes()
      const {
    return third_party_cookie_allowed_secondary_schemes_;
  }

  // Gets the original default setting for a particular content type.
  ContentSetting GetInitialDefaultSetting() const;

  bool IsSettingValid(ContentSetting setting) const;
  bool IsDefaultSettingValid(ContentSetting setting) const;

  IncognitoBehavior incognito_behavior() const { return incognito_behavior_; }
  OriginRestriction origin_restriction() const { return origin_restriction_; }

 private:
  raw_ptr<const WebsiteSettingsInfo, DanglingUntriaged> website_settings_info_;
  const std::vector<std::string> allowlisted_primary_schemes_;
  std::vector<std::string> third_party_cookie_allowed_secondary_schemes_;
  const std::set<ContentSetting> valid_settings_;
  const IncognitoBehavior incognito_behavior_;
  const OriginRestriction origin_restriction_;
};

}  // namespace content_settings

#endif  // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_INFO_H_