content_settings.h revision 06741cbc25cd4227a9fba40dfd0273bfcc1a587a
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
3// found in the LICENSE file.
4
5#ifndef CHROME_COMMON_CONTENT_SETTINGS_H_
6#define CHROME_COMMON_CONTENT_SETTINGS_H_
7
8#include "chrome/common/content_settings_types.h"
9
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.
12enum ContentSetting {
13  CONTENT_SETTING_DEFAULT = 0,
14  CONTENT_SETTING_ALLOW,
15  CONTENT_SETTING_BLOCK,
16  CONTENT_SETTING_ASK,
17  CONTENT_SETTING_SESSION_ONLY,
18  CONTENT_SETTING_NUM_SETTINGS
19};
20
21// Range-checked conversion of an int to a ContentSetting, for use when reading
22// prefs off disk.
23ContentSetting IntToContentSetting(int content_setting);
24
25// Aggregates the permissions for the different content types.
26struct ContentSettings {
27  ContentSettings() {
28    for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
29      settings[i] = CONTENT_SETTING_DEFAULT;
30  }
31
32  explicit ContentSettings(ContentSetting default_setting) {
33    for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
34      settings[i] = default_setting;
35  }
36
37  ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES];
38};
39
40#endif  // CHROME_COMMON_CONTENT_SETTINGS_H_
41