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_policy_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 ContentSetting content_setting) { | 384 ContentSetting content_setting) { |
| 385 } | 385 } |
| 386 | 386 |
| 387 ContentSetting PolicyProvider::GetContentSetting( | 387 ContentSetting PolicyProvider::GetContentSetting( |
| 388 const GURL& primary_url, | 388 const GURL& primary_url, |
| 389 const GURL& secondary_url, | 389 const GURL& secondary_url, |
| 390 ContentSettingsType content_type, | 390 ContentSettingsType content_type, |
| 391 const ResourceIdentifier& resource_identifier) const { | 391 const ResourceIdentifier& resource_identifier) const { |
| 392 // Resource identifier are not supported by policies as long as the feature is | 392 // Resource identifier are not supported by policies as long as the feature is |
| 393 // behind a flag. So resource identifiers are simply ignored. | 393 // behind a flag. So resource identifiers are simply ignored. |
| 394 scoped_ptr<Value> value(GetContentSettingValue(primary_url, | |
| 395 secondary_url, | |
| 396 content_type, | |
| 397 resource_identifier)); | |
| 398 ContentSetting setting = | |
| 399 value.get() ? ValueToContentSetting(value.get()) | |
| 400 : CONTENT_SETTING_DEFAULT; | |
| 401 if (setting == CONTENT_SETTING_DEFAULT && default_provider_) | |
| 402 setting = default_provider_->ProvideDefaultSetting(content_type); | |
| 403 return setting; | |
| 404 } | |
| 405 | |
| 406 Value* PolicyProvider::GetContentSettingValue( | |
| 407 const GURL& primary_url, | |
| 408 const GURL& secondary_url, | |
| 409 ContentSettingsType content_type, | |
| 410 const ResourceIdentifier& resource_identifier) const { | |
| 411 // Resource identifier are not supported by policies as long as the feature is | |
| 412 // behind a flag. So resource identifiers are simply ignored. | |
| 394 Value* value = value_map_.GetValue(primary_url, | 413 Value* value = value_map_.GetValue(primary_url, |
| 395 secondary_url, | 414 secondary_url, |
| 396 content_type, | 415 content_type, |
| 397 resource_identifier); | 416 resource_identifier); |
| 398 ContentSetting setting = | 417 return value ? value->DeepCopy() : NULL; |
|
wtc
2011/09/01 18:21:09
I hope these DeepCopy() calls are not expensive.
markusheintz_
2011/09/02 15:22:21
Using a pointer may cause synchronization issues.
| |
| 399 value == NULL ? CONTENT_SETTING_DEFAULT : ValueToContentSetting(value); | |
| 400 if (setting == CONTENT_SETTING_DEFAULT && default_provider_) | |
| 401 setting = default_provider_->ProvideDefaultSetting(content_type); | |
| 402 return setting; | |
| 403 } | 418 } |
| 404 | 419 |
| 420 | |
|
wtc
2011/09/01 18:21:09
Nit: remove these two blank lines.
markusheintz_
2011/09/02 15:22:21
Done.
| |
| 421 | |
| 405 void PolicyProvider::GetAllContentSettingsRules( | 422 void PolicyProvider::GetAllContentSettingsRules( |
| 406 ContentSettingsType content_type, | 423 ContentSettingsType content_type, |
| 407 const ResourceIdentifier& resource_identifier, | 424 const ResourceIdentifier& resource_identifier, |
| 408 Rules* content_setting_rules) const { | 425 Rules* content_setting_rules) const { |
| 409 DCHECK_NE(RequiresResourceIdentifier(content_type), | 426 DCHECK_NE(RequiresResourceIdentifier(content_type), |
| 410 resource_identifier.empty()); | 427 resource_identifier.empty()); |
| 411 DCHECK(content_setting_rules); | 428 DCHECK(content_setting_rules); |
| 412 content_setting_rules->clear(); | 429 content_setting_rules->clear(); |
| 413 | 430 |
| 414 const OriginIdentifierValueMap* map_to_return = &value_map_; | 431 const OriginIdentifierValueMap* map_to_return = &value_map_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 ContentSettingsPattern(), | 484 ContentSettingsPattern(), |
| 468 CONTENT_SETTINGS_TYPE_DEFAULT, | 485 CONTENT_SETTINGS_TYPE_DEFAULT, |
| 469 std::string()); | 486 std::string()); |
| 470 } | 487 } |
| 471 } else { | 488 } else { |
| 472 NOTREACHED() << "Unexpected notification"; | 489 NOTREACHED() << "Unexpected notification"; |
| 473 } | 490 } |
| 474 } | 491 } |
| 475 | 492 |
| 476 } // namespace content_settings | 493 } // namespace content_settings |
| OLD | NEW |