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 #include "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
6 | 6 |
7 #include <algorithm> | |
7 #include <list> | 8 #include <list> |
8 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/content_settings/content_settings_details.h" | 13 #include "chrome/browser/content_settings/content_settings_details.h" |
13 #include "chrome/browser/content_settings/content_settings_extension_provider.h" | 14 #include "chrome/browser/content_settings/content_settings_extension_provider.h" |
14 #include "chrome/browser/content_settings/content_settings_observable_provider.h " | 15 #include "chrome/browser/content_settings/content_settings_observable_provider.h " |
15 #include "chrome/browser/content_settings/content_settings_policy_provider.h" | 16 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
16 #include "chrome/browser/content_settings/content_settings_pref_provider.h" | 17 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 // TODO(markusheintz): Only the rules that are applied should be added. | 378 // TODO(markusheintz): Only the rules that are applied should be added. |
378 for (std::map<StringPair, PatternSettingSourceTuple>::iterator i( | 379 for (std::map<StringPair, PatternSettingSourceTuple>::iterator i( |
379 settings_map.begin()); | 380 settings_map.begin()); |
380 i != settings_map.end(); | 381 i != settings_map.end(); |
381 ++i) { | 382 ++i) { |
382 settings->push_back(i->second); | 383 settings->push_back(i->second); |
383 } | 384 } |
384 } | 385 } |
385 } | 386 } |
386 | 387 |
388 void HostContentSettingsMap::GetConcatenatedSettingsForOneType( | |
389 ContentSettingsType content_type, | |
390 const std::string& resource_identifier, | |
391 ContentSettingRules* rules) const { | |
392 DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type), | |
393 resource_identifier.empty()); | |
394 DCHECK(rules); | |
395 | |
396 rules->clear(); | |
397 for (size_t i = 0; i < content_settings_providers_.size(); ++i) { | |
398 // Get rules from the content settings provider. | |
399 Rules rules_for_provider; | |
400 content_settings_providers_[i]->GetAllContentSettingsRules( | |
401 content_type, resource_identifier, &rules_for_provider); | |
402 | |
403 // The rules are returned in arbitrary order. Sort them according to the | |
404 // ContentSettingPattern precedence relation. | |
Bernhard Bauer
2011/09/13 17:38:11
Uhhh… is this going to work? The precedence relati
marja
2011/09/15 12:02:00
Hmm, what would go wrong? Sorting should be ok eve
Bernhard Bauer
2011/09/15 12:52:19
Hm, I guess the most important property is transit
marja
2011/09/15 16:00:03
markusheintz had some diabolic-soul-merchandise go
| |
405 std::sort(rules_for_provider.begin(), rules_for_provider.end()); | |
406 | |
407 for (Rules::const_iterator i = rules_for_provider.begin(); | |
408 i != rules_for_provider.end(); ++i) { | |
409 rules->push_back(ContentSettingPatternTuple(i->primary_pattern, | |
410 i->secondary_pattern, | |
411 i->content_setting)); | |
412 } | |
413 } | |
414 rules->push_back(ContentSettingPatternTuple( | |
415 ContentSettingsPattern::Wildcard(), | |
416 ContentSettingsPattern::Wildcard(), | |
417 GetDefaultContentSetting(content_type))); | |
418 } | |
419 | |
387 void HostContentSettingsMap::SetDefaultContentSetting( | 420 void HostContentSettingsMap::SetDefaultContentSetting( |
388 ContentSettingsType content_type, | 421 ContentSettingsType content_type, |
389 ContentSetting setting) { | 422 ContentSetting setting) { |
390 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); | 423 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
391 DCHECK(IsSettingAllowedForType(setting, content_type)); | 424 DCHECK(IsSettingAllowedForType(setting, content_type)); |
392 for (DefaultProviderIterator provider = | 425 for (DefaultProviderIterator provider = |
393 default_content_settings_providers_.begin(); | 426 default_content_settings_providers_.begin(); |
394 provider != default_content_settings_providers_.end(); ++provider) { | 427 provider != default_content_settings_providers_.end(); ++provider) { |
395 (*provider)->UpdateDefaultSetting(content_type, setting); | 428 (*provider)->UpdateDefaultSetting(content_type, setting); |
396 } | 429 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 624 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
592 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? | 625 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? |
593 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); | 626 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); |
594 } | 627 } |
595 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { | 628 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { |
596 SetBlockThirdPartyCookies(cookie_behavior == | 629 SetBlockThirdPartyCookies(cookie_behavior == |
597 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); | 630 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); |
598 } | 631 } |
599 } | 632 } |
600 } | 633 } |
OLD | NEW |