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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void HostContentSettingsMap::SetDefaultContentSetting( | 250 void HostContentSettingsMap::SetDefaultContentSetting( |
251 ContentSettingsType content_type, | 251 ContentSettingsType content_type, |
252 ContentSetting setting) { | 252 ContentSetting setting) { |
253 DCHECK(IsSettingAllowedForType(prefs_, setting, content_type)); | 253 DCHECK(IsSettingAllowedForType(prefs_, setting, content_type)); |
254 | 254 |
255 base::Value* value = NULL; | 255 base::Value* value = NULL; |
256 if (setting != CONTENT_SETTING_DEFAULT) | 256 if (setting != CONTENT_SETTING_DEFAULT) |
257 value = Value::CreateIntegerValue(setting); | 257 value = base::Value::CreateIntegerValue(setting); |
258 SetWebsiteSetting( | 258 SetWebsiteSetting( |
259 ContentSettingsPattern::Wildcard(), | 259 ContentSettingsPattern::Wildcard(), |
260 ContentSettingsPattern::Wildcard(), | 260 ContentSettingsPattern::Wildcard(), |
261 content_type, | 261 content_type, |
262 std::string(), | 262 std::string(), |
263 value); | 263 value); |
264 } | 264 } |
265 | 265 |
266 void HostContentSettingsMap::SetWebsiteSetting( | 266 void HostContentSettingsMap::SetWebsiteSetting( |
267 const ContentSettingsPattern& primary_pattern, | 267 const ContentSettingsPattern& primary_pattern, |
(...skipping 22 matching lines...) Expand all Loading... |
290 | 290 |
291 void HostContentSettingsMap::SetContentSetting( | 291 void HostContentSettingsMap::SetContentSetting( |
292 const ContentSettingsPattern& primary_pattern, | 292 const ContentSettingsPattern& primary_pattern, |
293 const ContentSettingsPattern& secondary_pattern, | 293 const ContentSettingsPattern& secondary_pattern, |
294 ContentSettingsType content_type, | 294 ContentSettingsType content_type, |
295 const std::string& resource_identifier, | 295 const std::string& resource_identifier, |
296 ContentSetting setting) { | 296 ContentSetting setting) { |
297 DCHECK(!ContentTypeHasCompoundValue(content_type)); | 297 DCHECK(!ContentTypeHasCompoundValue(content_type)); |
298 base::Value* value = NULL; | 298 base::Value* value = NULL; |
299 if (setting != CONTENT_SETTING_DEFAULT) | 299 if (setting != CONTENT_SETTING_DEFAULT) |
300 value = Value::CreateIntegerValue(setting); | 300 value = base::Value::CreateIntegerValue(setting); |
301 SetWebsiteSetting(primary_pattern, | 301 SetWebsiteSetting(primary_pattern, |
302 secondary_pattern, | 302 secondary_pattern, |
303 content_type, | 303 content_type, |
304 resource_identifier, | 304 resource_identifier, |
305 value); | 305 value); |
306 } | 306 } |
307 | 307 |
308 void HostContentSettingsMap::AddExceptionForURL( | 308 void HostContentSettingsMap::AddExceptionForURL( |
309 const GURL& primary_url, | 309 const GURL& primary_url, |
310 const GURL& secondary_url, | 310 const GURL& secondary_url, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 &exceptions, | 469 &exceptions, |
470 false); | 470 false); |
471 for (ContentSettingsForOneType::iterator it = exceptions.begin(); | 471 for (ContentSettingsForOneType::iterator it = exceptions.begin(); |
472 it != exceptions.end(); ++it) { | 472 it != exceptions.end(); ++it) { |
473 if (it->setting != CONTENT_SETTING_ALLOW) | 473 if (it->setting != CONTENT_SETTING_ALLOW) |
474 continue; | 474 continue; |
475 SetWebsiteSetting(it->primary_pattern, | 475 SetWebsiteSetting(it->primary_pattern, |
476 it->secondary_pattern, | 476 it->secondary_pattern, |
477 CONTENT_SETTINGS_TYPE_COOKIES, | 477 CONTENT_SETTINGS_TYPE_COOKIES, |
478 std::string(), | 478 std::string(), |
479 Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY)); | 479 base::Value::CreateIntegerValue( |
| 480 CONTENT_SETTING_SESSION_ONLY)); |
480 } | 481 } |
481 | 482 |
482 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); | 483 prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); |
483 } | 484 } |
484 | 485 |
485 void HostContentSettingsMap::AddSettingsForOneType( | 486 void HostContentSettingsMap::AddSettingsForOneType( |
486 const content_settings::ProviderInterface* provider, | 487 const content_settings::ProviderInterface* provider, |
487 ProviderType provider_type, | 488 ProviderType provider_type, |
488 ContentSettingsType content_type, | 489 ContentSettingsType content_type, |
489 const std::string& resource_identifier, | 490 const std::string& resource_identifier, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 DCHECK(SupportsResourceIdentifier(content_type) || | 566 DCHECK(SupportsResourceIdentifier(content_type) || |
566 resource_identifier.empty()); | 567 resource_identifier.empty()); |
567 | 568 |
568 // Check if the scheme of the requesting url is whitelisted. | 569 // Check if the scheme of the requesting url is whitelisted. |
569 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { | 570 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { |
570 if (info) { | 571 if (info) { |
571 info->source = content_settings::SETTING_SOURCE_WHITELIST; | 572 info->source = content_settings::SETTING_SOURCE_WHITELIST; |
572 info->primary_pattern = ContentSettingsPattern::Wildcard(); | 573 info->primary_pattern = ContentSettingsPattern::Wildcard(); |
573 info->secondary_pattern = ContentSettingsPattern::Wildcard(); | 574 info->secondary_pattern = ContentSettingsPattern::Wildcard(); |
574 } | 575 } |
575 return Value::CreateIntegerValue(CONTENT_SETTING_ALLOW); | 576 return base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW); |
576 } | 577 } |
577 | 578 |
578 ContentSettingsPattern* primary_pattern = NULL; | 579 ContentSettingsPattern* primary_pattern = NULL; |
579 ContentSettingsPattern* secondary_pattern = NULL; | 580 ContentSettingsPattern* secondary_pattern = NULL; |
580 if (info) { | 581 if (info) { |
581 primary_pattern = &info->primary_pattern; | 582 primary_pattern = &info->primary_pattern; |
582 secondary_pattern = &info->secondary_pattern; | 583 secondary_pattern = &info->secondary_pattern; |
583 } | 584 } |
584 | 585 |
585 // The list of |content_settings_providers_| is ordered according to their | 586 // The list of |content_settings_providers_| is ordered according to their |
(...skipping 25 matching lines...) Expand all Loading... |
611 HostContentSettingsMap::GetProviderTypeFromSource( | 612 HostContentSettingsMap::GetProviderTypeFromSource( |
612 const std::string& source) { | 613 const std::string& source) { |
613 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { | 614 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { |
614 if (source == kProviderNames[i]) | 615 if (source == kProviderNames[i]) |
615 return static_cast<ProviderType>(i); | 616 return static_cast<ProviderType>(i); |
616 } | 617 } |
617 | 618 |
618 NOTREACHED(); | 619 NOTREACHED(); |
619 return DEFAULT_PROVIDER; | 620 return DEFAULT_PROVIDER; |
620 } | 621 } |
OLD | NEW |