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#pragma once
8
9#include "chrome/common/content_settings_types.h"
10
11// Different settings that can be assigned for a particular content type.  We
12// give the user the ability to set these on a global and per-host basis.
13enum ContentSetting {
14  CONTENT_SETTING_DEFAULT = 0,
15  CONTENT_SETTING_ALLOW,
16  CONTENT_SETTING_BLOCK,
17  CONTENT_SETTING_ASK,
18  CONTENT_SETTING_SESSION_ONLY,
19  CONTENT_SETTING_NUM_SETTINGS
20};
21
22// Range-checked conversion of an int to a ContentSetting, for use when reading
23// prefs off disk.
24ContentSetting IntToContentSetting(int content_setting);
25
26// Aggregates the permissions for the different content types.
27struct ContentSettings {
28  ContentSettings() {
29    for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
30      settings[i] = CONTENT_SETTING_DEFAULT;
31  }
32
33  explicit ContentSettings(ContentSetting default_setting) {
34    for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
35      settings[i] = default_setting;
36  }
37
38  ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES];
39};
40
41#endif  // CHROME_COMMON_CONTENT_SETTINGS_H_
42