Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: chrome/browser/content_settings/content_settings_mock_provider.cc

Issue 7831004: Add a method to the content_settings::ProviderInterface to return the content settings Value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/content_settings/content_settings_mock_provider.h" 5 #include "chrome/browser/content_settings/content_settings_mock_provider.h"
6 6
7 namespace content_settings { 7 namespace content_settings {
8 8
9 MockDefaultProvider::MockDefaultProvider( 9 MockDefaultProvider::MockDefaultProvider(
10 ContentSettingsType content_type, 10 ContentSettingsType content_type,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 : requesting_url_pattern_(requesting_url_pattern), 58 : requesting_url_pattern_(requesting_url_pattern),
59 embedding_url_pattern_(embedding_url_pattern), 59 embedding_url_pattern_(embedding_url_pattern),
60 content_type_(content_type), 60 content_type_(content_type),
61 resource_identifier_(resource_identifier), 61 resource_identifier_(resource_identifier),
62 setting_(setting), 62 setting_(setting),
63 read_only_(read_only) {} 63 read_only_(read_only) {}
64 64
65 MockProvider::~MockProvider() {} 65 MockProvider::~MockProvider() {}
66 66
67 ContentSetting MockProvider::GetContentSetting( 67 ContentSetting MockProvider::GetContentSetting(
68 const GURL& requesting_url, 68 const GURL& primary_url,
69 const GURL& embedding_url, 69 const GURL& secondary_url,
70 ContentSettingsType content_type, 70 ContentSettingsType content_type,
71 const ResourceIdentifier& resource_identifier) const { 71 const ResourceIdentifier& resource_identifier) const {
72 if (requesting_url_pattern_.Matches(requesting_url) && 72 if (requesting_url_pattern_.Matches(primary_url) &&
73 content_type_ == content_type && 73 content_type_ == content_type &&
74 resource_identifier_ == resource_identifier) { 74 resource_identifier_ == resource_identifier) {
75 return setting_; 75 return setting_;
76 } 76 }
77 return CONTENT_SETTING_DEFAULT; 77 return CONTENT_SETTING_DEFAULT;
78 } 78 }
79 79
80 Value* MockProvider::GetContentSettingValue(
81 const GURL& primary_url,
82 const GURL& secondary_url,
83 ContentSettingsType content_type,
84 const ResourceIdentifier& resource_identifier) const {
85 ContentSetting setting = GetContentSetting(
86 primary_url,
87 secondary_url,
88 content_type,
89 resource_identifier);
90 if (setting == CONTENT_SETTING_DEFAULT)
91 return NULL;
92 return Value::CreateIntegerValue(setting);
93 }
94
80 void MockProvider::SetContentSetting( 95 void MockProvider::SetContentSetting(
81 const ContentSettingsPattern& requesting_url_pattern, 96 const ContentSettingsPattern& requesting_url_pattern,
82 const ContentSettingsPattern& embedding_url_pattern, 97 const ContentSettingsPattern& embedding_url_pattern,
83 ContentSettingsType content_type, 98 ContentSettingsType content_type,
84 const ResourceIdentifier& resource_identifier, 99 const ResourceIdentifier& resource_identifier,
85 ContentSetting content_setting) { 100 ContentSetting content_setting) {
86 if (read_only_) 101 if (read_only_)
87 return; 102 return;
88 requesting_url_pattern_ = ContentSettingsPattern(requesting_url_pattern); 103 requesting_url_pattern_ = ContentSettingsPattern(requesting_url_pattern);
89 embedding_url_pattern_ = ContentSettingsPattern(embedding_url_pattern); 104 embedding_url_pattern_ = ContentSettingsPattern(embedding_url_pattern);
90 content_type_ = content_type; 105 content_type_ = content_type;
91 resource_identifier_ = resource_identifier; 106 resource_identifier_ = resource_identifier;
92 setting_ = content_setting; 107 setting_ = content_setting;
93 } 108 }
94 109
95 } // namespace content_settings 110 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698