diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 03:14:08 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 03:14:08 +0000 |
commit | 8e1d03adf5d70626f7d5edba62aad8a8f48526ba (patch) | |
tree | 4c2b3abcb2c8c68c2a51a7088ad5a5521d556630 /chrome/common | |
parent | 5f9d5bf8c5767e3c68e92a39a2c33ce4f62643a0 (diff) | |
download | chromium_src-8e1d03adf5d70626f7d5edba62aad8a8f48526ba.zip chromium_src-8e1d03adf5d70626f7d5edba62aad8a8f48526ba.tar.gz chromium_src-8e1d03adf5d70626f7d5edba62aad8a8f48526ba.tar.bz2 |
Merge 37603 - Rewrite the HostContentSettingsMap to address some issues:
* Interface not welldesigned for the actual uses
* Objects in URL request context must be refcounted since Profile is destroyed before the UI thread
BUG=33314
TEST=none
Review URL: http://codereview.chromium.org/555184
Also fix a number of problems in Jochen's merge of 37526.
TBR=pkasting@chromium.org
Review URL: http://codereview.chromium.org/555185
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@37604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/content_permission_types.h | 71 | ||||
-rw-r--r-- | chrome/common/content_settings.h | 32 | ||||
-rw-r--r-- | chrome/common/content_settings_types.h | 23 |
3 files changed, 55 insertions, 71 deletions
diff --git a/chrome/common/content_permission_types.h b/chrome/common/content_permission_types.h deleted file mode 100644 index 2b5acec..0000000 --- a/chrome/common/content_permission_types.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_CONTENT_PERMISSION_TYPES_H_ -#define CHROME_COMMON_CONTENT_PERMISSION_TYPES_H_ - -// Indicates different permission levels that can be assigned for a given -// resource. -enum ContentPermissionType { - CONTENT_PERMISSION_FIRST_TYPE = 0, - CONTENT_PERMISSION_TYPE_BLOCK = CONTENT_PERMISSION_FIRST_TYPE, - CONTENT_PERMISSION_TYPE_ALLOW, - CONTENT_PERMISSION_TYPE_ASK, - CONTENT_PERMISSION_TYPE_DEFAULT, - CONTENT_PERMISSION_NUM_TYPES -}; - -// A particular type of content to care about. We give the user various types -// of controls over each of these. -enum ContentSettingsType { - // "DEFAULT" is only used as an argument to the Content Settings Window - // opener; there it means "whatever was last shown". - CONTENT_SETTINGS_TYPE_DEFAULT = -1, - CONTENT_SETTINGS_FIRST_TYPE = 0, - CONTENT_SETTINGS_TYPE_COOKIES = CONTENT_SETTINGS_FIRST_TYPE, - CONTENT_SETTINGS_TYPE_IMAGES, - CONTENT_SETTINGS_TYPE_JAVASCRIPT, - CONTENT_SETTINGS_TYPE_PLUGINS, - CONTENT_SETTINGS_TYPE_POPUPS, - CONTENT_SETTINGS_NUM_TYPES -}; - -// Aggregates the permissions for the different content types. -struct ContentPermissions { - ContentPermissionType permissions[CONTENT_SETTINGS_NUM_TYPES]; - - ContentPermissions() { - for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) - permissions[i] = CONTENT_PERMISSION_TYPE_ALLOW; - } - - // Converts the struct into an integer used for storing in preferences and - // sending over IPC. - static int ToInteger(const ContentPermissions& permissions) { - int result = 0; - for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) - result = ((result << CONTENT_PERMISSION_NUM_TYPES) + - (1 << permissions.permissions[i])); - return result; - } - - // Converts an integer as stored in preferences or sent over IPC to - // ContentPermissions. - static ContentPermissions FromInteger(int settings) { - ContentPermissions result; - for (int i = CONTENT_SETTINGS_NUM_TYPES - 1; i >= 0; --i) { - int bitmask = (settings & ((1 << CONTENT_PERMISSION_NUM_TYPES) - 1)); - settings >>= CONTENT_PERMISSION_NUM_TYPES; - int value = 0; - while (bitmask != 1) { - value++; - bitmask >>= 1; - } - result.permissions[i] = static_cast<ContentPermissionType>(value); - } - return result; - } -}; - -#endif // CHROME_COMMON_CONTENT_PERMISSION_TYPES_H_ diff --git a/chrome/common/content_settings.h b/chrome/common/content_settings.h new file mode 100644 index 0000000..59d58c8 --- /dev/null +++ b/chrome/common/content_settings.h @@ -0,0 +1,32 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_CONTENT_SETTINGS_H_ +#define CHROME_COMMON_CONTENT_SETTINGS_H_ + +#include "chrome/common/content_settings_types.h" + +// Different settings that can be assigned for a particular content type. We +// give the user the ability to set these on a global and per-host basis. +enum ContentSetting { + CONTENT_SETTING_FIRST_SETTING = 0, + CONTENT_SETTING_DEFAULT = CONTENT_SETTING_FIRST_SETTING, + CONTENT_SETTING_ALLOW, + CONTENT_SETTING_BLOCK, + CONTENT_SETTING_ASK, + CONTENT_SETTING_NUM_SETTINGS +}; + +// Aggregates the permissions for the different content types. +struct ContentSettings { + ContentSettings() { + for (int i = CONTENT_SETTINGS_FIRST_TYPE; i < CONTENT_SETTINGS_NUM_TYPES; + ++i) + settings[i] = CONTENT_SETTING_DEFAULT; + } + + ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES]; +}; + +#endif // CHROME_COMMON_CONTENT_SETTINGS_H_ diff --git a/chrome/common/content_settings_types.h b/chrome/common/content_settings_types.h new file mode 100644 index 0000000..2026bac --- /dev/null +++ b/chrome/common/content_settings_types.h @@ -0,0 +1,23 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_CONTENT_SETTINGS_TYPES_H_ +#define CHROME_COMMON_CONTENT_SETTINGS_TYPES_H_ + +// A particular type of content to care about. We give the user various types +// of controls over each of these. +enum ContentSettingsType { + // "DEFAULT" is only used as an argument to the Content Settings Window + // opener; there it means "whatever was last shown". + CONTENT_SETTINGS_TYPE_DEFAULT = -1, + CONTENT_SETTINGS_FIRST_TYPE = 0, + CONTENT_SETTINGS_TYPE_COOKIES = CONTENT_SETTINGS_FIRST_TYPE, + CONTENT_SETTINGS_TYPE_IMAGES, + CONTENT_SETTINGS_TYPE_JAVASCRIPT, + CONTENT_SETTINGS_TYPE_PLUGINS, + CONTENT_SETTINGS_TYPE_POPUPS, + CONTENT_SETTINGS_NUM_TYPES +}; + +#endif // CHROME_COMMON_CONTENT_SETTINGS_TYPES_H_ |