OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 void HostContentSettingsMap::SetDefaultContentSetting( | 255 void HostContentSettingsMap::SetDefaultContentSetting( |
256 ContentSettingsType content_type, | 256 ContentSettingsType content_type, |
257 ContentSetting setting) { | 257 ContentSetting setting) { |
258 DCHECK(IsSettingAllowedForType(prefs_, setting, content_type)); | 258 DCHECK(IsSettingAllowedForType(prefs_, setting, content_type)); |
259 | 259 |
260 base::Value* value = NULL; | 260 base::Value* value = NULL; |
261 if (setting != CONTENT_SETTING_DEFAULT) | 261 if (setting != CONTENT_SETTING_DEFAULT) |
262 value = base::Value::CreateIntegerValue(setting); | 262 value = new base::FundamentalValue(setting); |
263 SetWebsiteSetting( | 263 SetWebsiteSetting( |
264 ContentSettingsPattern::Wildcard(), | 264 ContentSettingsPattern::Wildcard(), |
265 ContentSettingsPattern::Wildcard(), | 265 ContentSettingsPattern::Wildcard(), |
266 content_type, | 266 content_type, |
267 std::string(), | 267 std::string(), |
268 value); | 268 value); |
269 } | 269 } |
270 | 270 |
271 void HostContentSettingsMap::SetWebsiteSetting( | 271 void HostContentSettingsMap::SetWebsiteSetting( |
272 const ContentSettingsPattern& primary_pattern, | 272 const ContentSettingsPattern& primary_pattern, |
(...skipping 29 matching lines...) Expand all Loading... |
302 DCHECK(!ContentTypeHasCompoundValue(content_type)); | 302 DCHECK(!ContentTypeHasCompoundValue(content_type)); |
303 | 303 |
304 if (setting == CONTENT_SETTING_ALLOW && | 304 if (setting == CONTENT_SETTING_ALLOW && |
305 (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 305 (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
306 content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)) { | 306 content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)) { |
307 UpdateLastUsageByPattern(primary_pattern, secondary_pattern, content_type); | 307 UpdateLastUsageByPattern(primary_pattern, secondary_pattern, content_type); |
308 } | 308 } |
309 | 309 |
310 base::Value* value = NULL; | 310 base::Value* value = NULL; |
311 if (setting != CONTENT_SETTING_DEFAULT) | 311 if (setting != CONTENT_SETTING_DEFAULT) |
312 value = base::Value::CreateIntegerValue(setting); | 312 value = new base::FundamentalValue(setting); |
313 SetWebsiteSetting(primary_pattern, | 313 SetWebsiteSetting(primary_pattern, |
314 secondary_pattern, | 314 secondary_pattern, |
315 content_type, | 315 content_type, |
316 resource_identifier, | 316 resource_identifier, |
317 value); | 317 value); |
318 } | 318 } |
319 | 319 |
320 ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage( | 320 ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage( |
321 const GURL& primary_url, | 321 const GURL& primary_url, |
322 const GURL& secondary_url, | 322 const GURL& secondary_url, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 &exceptions, | 556 &exceptions, |
557 false); | 557 false); |
558 for (ContentSettingsForOneType::iterator it = exceptions.begin(); | 558 for (ContentSettingsForOneType::iterator it = exceptions.begin(); |
559 it != exceptions.end(); ++it) { | 559 it != exceptions.end(); ++it) { |
560 if (it->setting != CONTENT_SETTING_ALLOW) | 560 if (it->setting != CONTENT_SETTING_ALLOW) |
561 continue; | 561 continue; |
562 SetWebsiteSetting(it->primary_pattern, | 562 SetWebsiteSetting(it->primary_pattern, |
563 it->secondary_pattern, | 563 it->secondary_pattern, |
564 CONTENT_SETTINGS_TYPE_COOKIES, | 564 CONTENT_SETTINGS_TYPE_COOKIES, |
565 std::string(), | 565 std::string(), |
566 base::Value::CreateIntegerValue( | 566 new base::FundamentalValue(CONTENT_SETTING_SESSION_ONLY)); |
567 CONTENT_SETTING_SESSION_ONLY)); | |
568 } | 567 } |
569 | 568 |
570 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); | 569 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); |
571 } | 570 } |
572 | 571 |
573 void HostContentSettingsMap::AddSettingsForOneType( | 572 void HostContentSettingsMap::AddSettingsForOneType( |
574 const content_settings::ProviderInterface* provider, | 573 const content_settings::ProviderInterface* provider, |
575 ProviderType provider_type, | 574 ProviderType provider_type, |
576 ContentSettingsType content_type, | 575 ContentSettingsType content_type, |
577 const std::string& resource_identifier, | 576 const std::string& resource_identifier, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 DCHECK(SupportsResourceIdentifier(content_type) || | 657 DCHECK(SupportsResourceIdentifier(content_type) || |
659 resource_identifier.empty()); | 658 resource_identifier.empty()); |
660 | 659 |
661 // Check if the scheme of the requesting url is whitelisted. | 660 // Check if the scheme of the requesting url is whitelisted. |
662 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { | 661 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { |
663 if (info) { | 662 if (info) { |
664 info->source = content_settings::SETTING_SOURCE_WHITELIST; | 663 info->source = content_settings::SETTING_SOURCE_WHITELIST; |
665 info->primary_pattern = ContentSettingsPattern::Wildcard(); | 664 info->primary_pattern = ContentSettingsPattern::Wildcard(); |
666 info->secondary_pattern = ContentSettingsPattern::Wildcard(); | 665 info->secondary_pattern = ContentSettingsPattern::Wildcard(); |
667 } | 666 } |
668 return base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW); | 667 return new base::FundamentalValue(CONTENT_SETTING_ALLOW); |
669 } | 668 } |
670 | 669 |
671 ContentSettingsPattern* primary_pattern = NULL; | 670 ContentSettingsPattern* primary_pattern = NULL; |
672 ContentSettingsPattern* secondary_pattern = NULL; | 671 ContentSettingsPattern* secondary_pattern = NULL; |
673 if (info) { | 672 if (info) { |
674 primary_pattern = &info->primary_pattern; | 673 primary_pattern = &info->primary_pattern; |
675 secondary_pattern = &info->secondary_pattern; | 674 secondary_pattern = &info->secondary_pattern; |
676 } | 675 } |
677 | 676 |
678 // The list of |content_settings_providers_| is ordered according to their | 677 // The list of |content_settings_providers_| is ordered according to their |
(...skipping 30 matching lines...) Expand all Loading... |
709 } | 708 } |
710 | 709 |
711 NOTREACHED(); | 710 NOTREACHED(); |
712 return DEFAULT_PROVIDER; | 711 return DEFAULT_PROVIDER; |
713 } | 712 } |
714 | 713 |
715 content_settings::PrefProvider* HostContentSettingsMap::GetPrefProvider() { | 714 content_settings::PrefProvider* HostContentSettingsMap::GetPrefProvider() { |
716 return static_cast<content_settings::PrefProvider*>( | 715 return static_cast<content_settings::PrefProvider*>( |
717 content_settings_providers_[PREF_PROVIDER]); | 716 content_settings_providers_[PREF_PROVIDER]); |
718 } | 717 } |
OLD | NEW |