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. 4 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_MOCK_PROVIDER_H_ 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_MOCK_PROVIDER_H_ 7 8 #include <vector> 9 10 #include "base/macros.h" 11 #include "components/content_settings/core/browser/content_settings_observable_provider.h" 12 #include "components/content_settings/core/browser/content_settings_origin_identifier_value_map.h" 13 #include "components/content_settings/core/common/content_settings_pattern.h" 14 #include "components/content_settings/core/common/content_settings_types.h" 15 16 namespace content_settings { 17 18 // The class MockProvider is a mock for a non default content settings provider. 19 class MockProvider : public ObservableProvider { 20 public: 21 MockProvider(); 22 explicit MockProvider(bool read_only); 23 ~MockProvider() override; 24 25 std::unique_ptr<RuleIterator> GetRuleIterator( 26 ContentSettingsType content_type, 27 bool incognito) const override; 28 29 bool SetWebsiteSetting( 30 const ContentSettingsPattern& requesting_url_pattern, 31 const ContentSettingsPattern& embedding_url_pattern, 32 ContentSettingsType content_type, 33 std::unique_ptr<base::Value>&& value, 34 const ContentSettingConstraints& constraint = {}) override; 35 ClearAllContentSettingsRules(ContentSettingsType content_type)36 void ClearAllContentSettingsRules(ContentSettingsType content_type) override { 37 } 38 39 void ShutdownOnUIThread() override; 40 set_read_only(bool read_only)41 void set_read_only(bool read_only) { read_only_ = read_only; } 42 read_only()43 bool read_only() const { return read_only_; } 44 45 private: 46 OriginIdentifierValueMap value_map_; 47 bool read_only_; 48 49 DISALLOW_COPY_AND_ASSIGN(MockProvider); 50 }; 51 52 } // namespace content_settings 53 54 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_MOCK_PROVIDER_H_ 55