OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_CONTENT_SETTINGS_H_ | 5 #ifndef CHROME_COMMON_CONTENT_SETTINGS_H_ |
6 #define CHROME_COMMON_CONTENT_SETTINGS_H_ | 6 #define CHROME_COMMON_CONTENT_SETTINGS_H_ |
7 | 7 |
8 #include "chrome/common/content_settings_types.h" | 8 #include "chrome/common/content_settings_types.h" |
9 | 9 |
10 // Different settings that can be assigned for a particular content type. We | 10 // Different settings that can be assigned for a particular content type. We |
11 // give the user the ability to set these on a global and per-host basis. | 11 // give the user the ability to set these on a global and per-host basis. |
12 enum ContentSetting { | 12 enum ContentSetting { |
13 CONTENT_SETTING_DEFAULT = 0, | 13 CONTENT_SETTING_DEFAULT = 0, |
14 CONTENT_SETTING_ALLOW, | 14 CONTENT_SETTING_ALLOW, |
15 CONTENT_SETTING_BLOCK, | 15 CONTENT_SETTING_BLOCK, |
16 CONTENT_SETTING_ASK, | 16 CONTENT_SETTING_ASK, |
17 CONTENT_SETTING_NUM_SETTINGS | 17 CONTENT_SETTING_NUM_SETTINGS |
18 }; | 18 }; |
19 | 19 |
| 20 // Range-checked conversion of an int to a ContentSetting, for use when reading |
| 21 // prefs off disk. |
| 22 ContentSetting IntToContentSetting(int content_setting); |
| 23 |
20 // Aggregates the permissions for the different content types. | 24 // Aggregates the permissions for the different content types. |
21 struct ContentSettings { | 25 struct ContentSettings { |
22 ContentSettings() { | 26 ContentSettings() { |
23 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) | 27 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) |
24 settings[i] = CONTENT_SETTING_DEFAULT; | 28 settings[i] = CONTENT_SETTING_DEFAULT; |
25 } | 29 } |
26 | 30 |
27 explicit ContentSettings(ContentSetting default_setting) { | 31 explicit ContentSettings(ContentSetting default_setting) { |
28 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) | 32 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) |
29 settings[i] = default_setting; | 33 settings[i] = default_setting; |
30 } | 34 } |
31 | 35 |
32 ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES]; | 36 ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES]; |
33 }; | 37 }; |
34 | 38 |
35 #endif // CHROME_COMMON_CONTENT_SETTINGS_H_ | 39 #endif // CHROME_COMMON_CONTENT_SETTINGS_H_ |
OLD | NEW |