OLD | NEW |
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 | 5 |
6 #include "chrome/browser/content_settings/content_settings_base_provider.h" | 6 #include "chrome/browser/content_settings/content_settings_base_provider.h" |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Check for exact matches first. | 91 // Check for exact matches first. |
92 HostContentSettings::const_iterator i(host_content_settings_.find(host)); | 92 HostContentSettings::const_iterator i(host_content_settings_.find(host)); |
93 if (i != host_content_settings_.end() && | 93 if (i != host_content_settings_.end() && |
94 i->second.content_settings_for_resources.find(requested_setting) != | 94 i->second.content_settings_for_resources.find(requested_setting) != |
95 i->second.content_settings_for_resources.end()) { | 95 i->second.content_settings_for_resources.end()) { |
96 return i->second.content_settings_for_resources.find( | 96 return i->second.content_settings_for_resources.find( |
97 requested_setting)->second; | 97 requested_setting)->second; |
98 } | 98 } |
99 | 99 |
100 // If this map is not for an off-the-record profile, these searches will never | 100 // If this map is not for an incognito profile, these searches will never |
101 // match. The additional off-the-record exceptions always overwrite the | 101 // match. The additional incognito exceptions always overwrite the |
102 // regular ones. | 102 // regular ones. |
103 i = off_the_record_settings_.find(host); | 103 i = off_the_record_settings_.find(host); |
104 if (i != off_the_record_settings_.end() && | 104 if (i != off_the_record_settings_.end() && |
105 i->second.content_settings_for_resources.find(requested_setting) != | 105 i->second.content_settings_for_resources.find(requested_setting) != |
106 i->second.content_settings_for_resources.end()) { | 106 i->second.content_settings_for_resources.end()) { |
107 return i->second.content_settings_for_resources.find( | 107 return i->second.content_settings_for_resources.find( |
108 requested_setting)->second; | 108 requested_setting)->second; |
109 } | 109 } |
110 | 110 |
111 // Match patterns starting with the most concrete pattern match. | 111 // Match patterns starting with the most concrete pattern match. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 const std::string host(net::GetHostOrSpecFromURL(url)); | 182 const std::string host(net::GetHostOrSpecFromURL(url)); |
183 ContentSettings output; | 183 ContentSettings output; |
184 for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) | 184 for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) |
185 output.settings[j] = CONTENT_SETTING_DEFAULT; | 185 output.settings[j] = CONTENT_SETTING_DEFAULT; |
186 | 186 |
187 // Check for exact matches first. | 187 // Check for exact matches first. |
188 HostContentSettings::const_iterator i(host_content_settings_.find(host)); | 188 HostContentSettings::const_iterator i(host_content_settings_.find(host)); |
189 if (i != host_content_settings_.end()) | 189 if (i != host_content_settings_.end()) |
190 output = i->second.content_settings; | 190 output = i->second.content_settings; |
191 | 191 |
192 // If this map is not for an off-the-record profile, these searches will never | 192 // If this map is not for an incognito profile, these searches will never |
193 // match. The additional off-the-record exceptions always overwrite the | 193 // match. The additional incognito exceptions always overwrite the |
194 // regular ones. | 194 // regular ones. |
195 i = off_the_record_settings_.find(host); | 195 i = off_the_record_settings_.find(host); |
196 if (i != off_the_record_settings_.end()) { | 196 if (i != off_the_record_settings_.end()) { |
197 for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) | 197 for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) |
198 if (i->second.content_settings.settings[j] != CONTENT_SETTING_DEFAULT) | 198 if (i->second.content_settings.settings[j] != CONTENT_SETTING_DEFAULT) |
199 output.settings[j] = i->second.content_settings.settings[j]; | 199 output.settings[j] = i->second.content_settings.settings[j]; |
200 } | 200 } |
201 | 201 |
202 // Match patterns starting with the most concrete pattern match. | 202 // Match patterns starting with the most concrete pattern match. |
203 for (std::string key = | 203 for (std::string key = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 if (setting == CONTENT_SETTING_ASK && | 246 if (setting == CONTENT_SETTING_ASK && |
247 content_type == CONTENT_SETTINGS_TYPE_PLUGINS && | 247 content_type == CONTENT_SETTINGS_TYPE_PLUGINS && |
248 !CommandLine::ForCurrentProcess()->HasSwitch( | 248 !CommandLine::ForCurrentProcess()->HasSwitch( |
249 switches::kEnableClickToPlay)) { | 249 switches::kEnableClickToPlay)) { |
250 return CONTENT_SETTING_BLOCK; | 250 return CONTENT_SETTING_BLOCK; |
251 } | 251 } |
252 return setting; | 252 return setting; |
253 } | 253 } |
254 | 254 |
255 } // namespace content_settings | 255 } // namespace content_settings |
OLD | NEW |