Chromium Code Reviews| Index: chrome/browser/content_settings/content_settings_provider.h | 
| diff --git a/chrome/browser/content_settings/content_settings_provider.h b/chrome/browser/content_settings/content_settings_provider.h | 
| index 621c5222888982b7b6a3aa91c62d26498a0be622..98d458fbdf16cc2247abcbfa900a6b69c6044b0f 100644 | 
| --- a/chrome/browser/content_settings/content_settings_provider.h | 
| +++ b/chrome/browser/content_settings/content_settings_provider.h | 
| @@ -8,9 +8,12 @@ | 
| #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 
| #pragma once | 
| +#include <map> | 
| #include <string> | 
| +#include <utility> | 
| #include <vector> | 
| +#include "base/synchronization/lock.h" | 
| #include "chrome/browser/content_settings/content_settings_pattern.h" | 
| #include "chrome/common/content_settings.h" | 
| @@ -119,6 +122,113 @@ class ProviderInterface { | 
| virtual void ResetToDefaults() = 0; | 
| }; | 
| +typedef std::pair<ContentSettingsType, std::string> | 
| + ContentSettingsTypeResourceIdentifierPair; | 
| +typedef std::map<ContentSettingsTypeResourceIdentifierPair, ContentSetting> | 
| + ResourceContentSettings; | 
| + | 
| +struct ExtendedContentSettings { | 
| + ContentSettings content_settings; | 
| + ResourceContentSettings content_settings_for_resources; | 
| +}; | 
| + | 
| +// Map for ContentSettings. | 
| +typedef std::map<std::string, ExtendedContentSettings> HostContentSettings; | 
| + | 
| +// BaseProvider is the abstract base class for all PolicyProvider classes. | 
| 
 
Bernhard Bauer
2011/02/14 16:58:36
Nit: and also for PrefProviders?
 
markusheintz_
2011/02/14 18:25:28
Done.
 
 | 
| +class BaseProvider : public ProviderInterface { | 
| 
 
Bernhard Bauer
2011/02/14 16:58:36
With this class and ProviderUtil below, this file
 
markusheintz_
2011/02/14 18:25:28
You are right this file grew into a real beast now
 
 | 
| + public: | 
| + explicit BaseProvider(bool is_otr) | 
| + : is_off_the_record_(is_otr) { | 
| + } | 
| + virtual ~BaseProvider() {} | 
| + | 
| + // Initializes the Provider. | 
| + virtual void Init() = 0; | 
| + | 
| + // ProviderInterface Implementation | 
| + virtual bool ContentSettingsTypeIsManaged( | 
| + ContentSettingsType content_type) = 0; | 
| + | 
| + virtual ContentSetting GetContentSetting( | 
| + const GURL& requesting_url, | 
| + const GURL& embedding_url, | 
| + ContentSettingsType content_type, | 
| + const ResourceIdentifier& resource_identifier) const; | 
| + | 
| + virtual void SetContentSetting( | 
| + const ContentSettingsPattern& requesting_pattern, | 
| + const ContentSettingsPattern& embedding_pattern, | 
| + ContentSettingsType content_type, | 
| + const ResourceIdentifier& resource_identifier, | 
| + ContentSetting content_setting) = 0; | 
| + | 
| + virtual void GetAllContentSettingsRules( | 
| + ContentSettingsType content_type, | 
| + const ResourceIdentifier& resource_identifier, | 
| + Rules* content_setting_rules) const; | 
| + | 
| + virtual void ClearAllContentSettingsRules( | 
| + ContentSettingsType content_type) = 0; | 
| + | 
| + virtual void ResetToDefaults() = 0; | 
| + | 
| + protected: | 
| + // Returns true if the |content_type| requires a resource identifier. | 
| + bool RequiresResourceIdentifier( | 
| + ContentSettingsType content_type) const; | 
| + | 
| + // Returns true if the passed |settings| object contains only | 
| + // CONTENT_SETTING_DEFAULT values. | 
| + bool AllDefault(const ExtendedContentSettings& settings) const; | 
| + | 
| + // TODO(markusheintz): LEGACY method. Will be removed in a futur re-factoring | 
| 
 
Bernhard Bauer
2011/02/14 16:58:36
Nit: "future"
 
markusheintz_
2011/02/14 18:25:28
Done.
 
 | 
| + // step. | 
| + ContentSettings GetNonDefaultContentSettings(const GURL& url) const; | 
| + | 
| + // Accessors | 
| + HostContentSettings* host_content_settings() { | 
| + return &host_content_settings_; | 
| + } | 
| + | 
| + HostContentSettings* off_the_record_settings() { | 
| + return &off_the_record_settings_; | 
| + } | 
| + | 
| + base::Lock& lock() const { | 
| + return lock_; | 
| + } | 
| + | 
| + bool is_off_the_record() const { | 
| + return is_off_the_record_; | 
| + } | 
| + | 
| + private: | 
| + // Copies of the pref data, so that we can read it on threads other than the | 
| + // UI thread. | 
| + HostContentSettings host_content_settings_; | 
| + | 
| + // Whether this settings map is for an OTR session. | 
| + bool is_off_the_record_; | 
| + | 
| + // Differences to the preference-stored host content settings for | 
| + // off-the-record settings. | 
| + HostContentSettings off_the_record_settings_; | 
| + | 
| + // Used around accesses to the content_settings_ object to guarantee | 
| + // thread safety. | 
| + mutable base::Lock lock_; | 
| +}; | 
| + | 
| +// ProviderUtil provides utility methods for content-settings-providers. | 
| +class ProviderUtil { | 
| + public: | 
| + // Maps CONTENT_SETTING_ASK for the CONTENT_SETTINGS_TYPE_PLUGINS to | 
| + // CONTENT_SETTING_BLOCK if click-to-play is not enabled. | 
| + static ContentSetting ClickToPlayFixup(ContentSettingsType content_type, | 
| + ContentSetting setting); | 
| +}; | 
| + | 
| } // namespace content_settings | 
| #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |