Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider.cc

Issue 7831004: Add a method to the content_settings::ProviderInterface to return the content settings Value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
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
405 void PolicyProvider::GetAllContentSettingsRules( 420 void PolicyProvider::GetAllContentSettingsRules(
406 ContentSettingsType content_type, 421 ContentSettingsType content_type,
407 const ResourceIdentifier& resource_identifier, 422 const ResourceIdentifier& resource_identifier,
408 Rules* content_setting_rules) const { 423 Rules* content_setting_rules) const {
409 DCHECK_NE(RequiresResourceIdentifier(content_type), 424 DCHECK_NE(RequiresResourceIdentifier(content_type),
410 resource_identifier.empty()); 425 resource_identifier.empty());
411 DCHECK(content_setting_rules); 426 DCHECK(content_setting_rules);
412 content_setting_rules->clear(); 427 content_setting_rules->clear();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 ContentSettingsPattern(), 482 ContentSettingsPattern(),
468 CONTENT_SETTINGS_TYPE_DEFAULT, 483 CONTENT_SETTINGS_TYPE_DEFAULT,
469 std::string()); 484 std::string());
470 } 485 }
471 } else { 486 } else {
472 NOTREACHED() << "Unexpected notification"; 487 NOTREACHED() << "Unexpected notification";
473 } 488 }
474 } 489 }
475 490
476 } // namespace content_settings 491 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698