Home | History | Annotate | Download | only in content_settings
      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 #include "chrome/browser/content_settings/content_settings_mock_provider.h"
      6 
      7 namespace content_settings {
      8 
      9 MockProvider::MockProvider()
     10     : read_only_(false) {}
     11 
     12 MockProvider::MockProvider(bool read_only)
     13     : read_only_(read_only) {
     14 }
     15 
     16 MockProvider::~MockProvider() {}
     17 
     18 RuleIterator* MockProvider::GetRuleIterator(
     19     ContentSettingsType content_type,
     20     const ResourceIdentifier& resource_identifier,
     21     bool incognito) const {
     22   return value_map_.GetRuleIterator(content_type, resource_identifier, NULL);
     23 }
     24 
     25 bool MockProvider::SetWebsiteSetting(
     26     const ContentSettingsPattern& requesting_url_pattern,
     27     const ContentSettingsPattern& embedding_url_pattern,
     28     ContentSettingsType content_type,
     29     const ResourceIdentifier& resource_identifier,
     30     base::Value* value) {
     31   if (read_only_)
     32     return false;
     33   value_map_.clear();
     34   value_map_.SetValue(requesting_url_pattern,
     35                       embedding_url_pattern,
     36                       content_type,
     37                       resource_identifier,
     38                       value);
     39   return true;
     40 }
     41 
     42 void MockProvider::ShutdownOnUIThread() {
     43   RemoveAllObservers();
     44 }
     45 
     46 }  // namespace content_settings
     47