Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / content_settings / core / common / content_settings.h
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_H_
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "components/content_settings/core/common/content_settings_pattern.h"
12
13 // Different settings that can be assigned for a particular content type.  We
14 // give the user the ability to set these on a global and per-origin basis.
15 // A Java counterpart will be generated for this enum.
16 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser
17 enum ContentSetting {
18   CONTENT_SETTING_DEFAULT = 0,
19   CONTENT_SETTING_ALLOW,
20   CONTENT_SETTING_BLOCK,
21   CONTENT_SETTING_ASK,
22   CONTENT_SETTING_SESSION_ONLY,
23   CONTENT_SETTING_NUM_SETTINGS
24 };
25
26 // Range-checked conversion of an int to a ContentSetting, for use when reading
27 // prefs off disk.
28 ContentSetting IntToContentSetting(int content_setting);
29
30 struct ContentSettingPatternSource {
31   ContentSettingPatternSource(const ContentSettingsPattern& primary_pattern,
32                               const ContentSettingsPattern& secondary_patttern,
33                               ContentSetting setting,
34                               const std::string& source,
35                               bool incognito);
36   ContentSettingPatternSource();
37   ContentSettingsPattern primary_pattern;
38   ContentSettingsPattern secondary_pattern;
39   ContentSetting setting;
40   std::string source;
41   bool incognito;
42 };
43
44 typedef std::vector<ContentSettingPatternSource> ContentSettingsForOneType;
45
46 struct RendererContentSettingRules {
47   RendererContentSettingRules();
48   ~RendererContentSettingRules();
49   ContentSettingsForOneType image_rules;
50   ContentSettingsForOneType script_rules;
51 };
52
53 namespace content_settings {
54
55 // Enum containing the various source for content settings. Settings can be
56 // set by policy, extension or the user. Certain (internal) schemes are
57 // whilelisted. For whilelisted schemes the source is
58 // |SETTING_SOURCE_WHITELIST|.
59 enum SettingSource {
60   SETTING_SOURCE_NONE,
61   SETTING_SOURCE_POLICY,
62   SETTING_SOURCE_EXTENSION,
63   SETTING_SOURCE_USER,
64   SETTING_SOURCE_WHITELIST,
65 };
66
67 // |SettingInfo| provides meta data for content setting values. |source|
68 // contains the source of a value. |primary_pattern| and |secondary_pattern|
69 // contains the patterns of the appling rule.
70 struct SettingInfo {
71   SettingSource source;
72   ContentSettingsPattern primary_pattern;
73   ContentSettingsPattern secondary_pattern;
74 };
75
76 }  // namespace content_settings
77
78 #endif  // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_H_