1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_MOCK_PROVIDER_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_MOCK_PROVIDER_H_
10 #include "base/basictypes.h"
11 #include "chrome/browser/content_settings/content_settings_observable_provider.h"
12 #include "chrome/browser/content_settings/content_settings_origin_identifier_value_map.h"
13 #include "chrome/common/content_settings_pattern.h"
14 #include "chrome/common/content_settings_types.h"
16 namespace content_settings
{
18 // The class MockProvider is a mock for a non default content settings provider.
19 class MockProvider
: public ObservableProvider
{
22 explicit MockProvider(bool read_only
);
23 virtual ~MockProvider();
25 virtual RuleIterator
* GetRuleIterator(
26 ContentSettingsType content_type
,
27 const ResourceIdentifier
& resource_identifier
,
28 bool incognito
) const OVERRIDE
;
30 // The MockProvider is only able to store one content setting. So every time
31 // this method is called the previously set content settings is overwritten.
32 virtual bool SetWebsiteSetting(
33 const ContentSettingsPattern
& requesting_url_pattern
,
34 const ContentSettingsPattern
& embedding_url_pattern
,
35 ContentSettingsType content_type
,
36 const ResourceIdentifier
& resource_identifier
,
37 base::Value
* value
) OVERRIDE
;
39 virtual void ClearAllContentSettingsRules(
40 ContentSettingsType content_type
) OVERRIDE
{}
42 virtual void ShutdownOnUIThread() OVERRIDE
;
44 void set_read_only(bool read_only
) {
45 read_only_
= read_only
;
48 bool read_only() const {
53 OriginIdentifierValueMap value_map_
;
56 DISALLOW_COPY_AND_ASSIGN(MockProvider
);
59 } // namespace content_settings
61 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_MOCK_PROVIDER_H_