#ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_
#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_
#include <vector>
#include "base/basictypes.h"
#include "base/prefs/pref_change_registrar.h"
#include "base/synchronization/lock.h"
#include "chrome/browser/content_settings/content_settings_observable_provider.h"
#include "chrome/browser/content_settings/content_settings_origin_identifier_value_map.h"
#include "chrome/browser/content_settings/content_settings_utils.h"
class PrefService;
namespace base {
class DictionaryValue;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace content_settings {
class PrefProvider : public ObservableProvider {
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
PrefProvider(PrefService* prefs, bool incognito);
virtual ~PrefProvider();
virtual RuleIterator* GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
bool incognito) const OVERRIDE;
virtual bool SetWebsiteSetting(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
base::Value* value) OVERRIDE;
virtual void ClearAllContentSettingsRules(
ContentSettingsType content_type) OVERRIDE;
virtual void ShutdownOnUIThread() OVERRIDE;
private:
friend class DeadlockCheckerThread;
void ReadContentSettingsFromPref(bool overwrite);
void OnContentSettingsPatternPairsChanged();
void UpdatePref(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
const base::Value* value);
void MigrateObsoleteMediaContentSetting();
static void CanonicalizeContentSettingsExceptions(
base::DictionaryValue* all_settings_dictionary);
void AssertLockNotHeld() const;
PrefService* prefs_;
bool is_incognito_;
PrefChangeRegistrar pref_change_registrar_;
bool updating_preferences_;
OriginIdentifierValueMap value_map_;
OriginIdentifierValueMap incognito_value_map_;
mutable base::Lock lock_;
DISALLOW_COPY_AND_ASSIGN(PrefProvider);
};
}
#endif