Chromium Code Reviews| 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/content_settings_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); | 436 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); |
| 437 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this); | 437 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this); |
| 438 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this); | 438 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this); |
| 439 } | 439 } |
| 440 | 440 |
| 441 ContentSetting PrefProvider::GetContentSetting( | 441 ContentSetting PrefProvider::GetContentSetting( |
| 442 const GURL& primary_url, | 442 const GURL& primary_url, |
| 443 const GURL& secondary_url, | 443 const GURL& secondary_url, |
| 444 ContentSettingsType content_type, | 444 ContentSettingsType content_type, |
| 445 const ResourceIdentifier& resource_identifier) const { | 445 const ResourceIdentifier& resource_identifier) const { |
| 446 Value* value = GetContentSettingValue(primary_url, | |
|
Bernhard Bauer
2011/09/01 13:33:19
This leaks |value|.
markusheintz_
2011/09/01 14:32:49
Fixed here and in the PolicyProvider as well.
| |
| 447 secondary_url, | |
| 448 content_type, | |
| 449 resource_identifier); | |
| 450 return value ? ValueToContentSetting(value) : CONTENT_SETTING_DEFAULT; | |
| 451 } | |
| 452 | |
| 453 Value* PrefProvider::GetContentSettingValue( | |
| 454 const GURL& primary_url, | |
| 455 const GURL& secondary_url, | |
| 456 ContentSettingsType content_type, | |
| 457 const ResourceIdentifier& resource_identifier) const { | |
| 446 // For a |PrefProvider| used in a |HostContentSettingsMap| of a non incognito | 458 // For a |PrefProvider| used in a |HostContentSettingsMap| of a non incognito |
| 447 // profile, this will always return NULL. | 459 // profile, this will always return NULL. |
| 448 // TODO(markusheintz): I don't like this. I'd like to have an | 460 // TODO(markusheintz): I don't like this. I'd like to have an |
| 449 // IncognitoProviderWrapper that wrapps the pref provider for a host content | 461 // IncognitoProviderWrapper that wrapps the pref provider for a host content |
| 450 // settings map of an incognito profile. | 462 // settings map of an incognito profile. |
| 451 base::AutoLock auto_lock(lock_); | 463 base::AutoLock auto_lock(lock_); |
| 452 Value* incognito_value = incognito_value_map_.GetValue( | 464 Value* incognito_value = incognito_value_map_.GetValue( |
| 453 primary_url, | 465 primary_url, |
| 454 secondary_url, | 466 secondary_url, |
| 455 content_type, | 467 content_type, |
| 456 resource_identifier); | 468 resource_identifier); |
| 457 if (incognito_value) | 469 if (incognito_value) |
| 458 return ValueToContentSetting(incognito_value); | 470 return incognito_value->DeepCopy(); |
| 459 | 471 |
| 460 Value* value = value_map_.GetValue( | 472 Value* value = value_map_.GetValue( |
| 461 primary_url, | 473 primary_url, |
| 462 secondary_url, | 474 secondary_url, |
| 463 content_type, | 475 content_type, |
| 464 resource_identifier); | 476 resource_identifier); |
| 465 if (value) | 477 return value ? value->DeepCopy() : NULL; |
| 466 return ValueToContentSetting(value); | |
| 467 | |
| 468 return CONTENT_SETTING_DEFAULT; | |
| 469 } | 478 } |
| 470 | 479 |
| 471 void PrefProvider::GetAllContentSettingsRules( | 480 void PrefProvider::GetAllContentSettingsRules( |
| 472 ContentSettingsType content_type, | 481 ContentSettingsType content_type, |
| 473 const ResourceIdentifier& resource_identifier, | 482 const ResourceIdentifier& resource_identifier, |
| 474 Rules* content_setting_rules) const { | 483 Rules* content_setting_rules) const { |
| 475 DCHECK(content_setting_rules); | 484 DCHECK(content_setting_rules); |
| 476 content_setting_rules->clear(); | 485 content_setting_rules->clear(); |
| 477 | 486 |
| 478 const OriginIdentifierValueMap* map_to_return = | 487 const OriginIdentifierValueMap* map_to_return = |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 if (settings_dictionary->GetInteger( | 1373 if (settings_dictionary->GetInteger( |
| 1365 kTypeNames[CONTENT_SETTINGS_TYPE_GEOLOCATION], &setting_value)) { | 1374 kTypeNames[CONTENT_SETTINGS_TYPE_GEOLOCATION], &setting_value)) { |
| 1366 UpdateObsoleteGeolocationPref(pattern_pair.first, | 1375 UpdateObsoleteGeolocationPref(pattern_pair.first, |
| 1367 pattern_pair.second, | 1376 pattern_pair.second, |
| 1368 ContentSetting(setting_value)); | 1377 ContentSetting(setting_value)); |
| 1369 } | 1378 } |
| 1370 } | 1379 } |
| 1371 } | 1380 } |
| 1372 | 1381 |
| 1373 } // namespace content_settings | 1382 } // namespace content_settings |
| OLD | NEW |