Index: chrome/browser/permissions/chooser_context_base.cc |
diff --git a/chrome/browser/permissions/chooser_context_base.cc b/chrome/browser/permissions/chooser_context_base.cc |
index 22f043efe2e238bf7cba6854b1959bf9e9151359..ac9ea921bc6056d733d192aa133f129f948ca4b0 100644 |
--- a/chrome/browser/permissions/chooser_context_base.cc |
+++ b/chrome/browser/permissions/chooser_context_base.cc |
@@ -16,17 +16,32 @@ const char kObjectListKey[] = "chosen-objects"; |
ChooserContextBase::ChooserContextBase( |
Profile* profile, |
+ const ContentSettingsType guard_content_settings_type, |
const ContentSettingsType data_content_settings_type) |
: host_content_settings_map_( |
HostContentSettingsMapFactory::GetForProfile(profile)), |
+ guard_content_settings_type_(guard_content_settings_type), |
data_content_settings_type_(data_content_settings_type) { |
DCHECK(host_content_settings_map_); |
} |
ChooserContextBase::~ChooserContextBase() {} |
+bool ChooserContextBase::CanRequestObjectPermission( |
+ const GURL& requesting_origin, |
+ const GURL& embedding_origin) { |
+ ContentSetting content_setting = |
+ host_content_settings_map_->GetContentSetting( |
+ requesting_origin, embedding_origin, guard_content_settings_type_, |
+ std::string()); |
+ return content_setting == CONTENT_SETTING_ALLOW; |
+} |
+ |
ObjectList ChooserContextBase::GetGrantedObjects(const GURL& requesting_origin, |
const GURL& embedding_origin) { |
+ if (!CanRequestObjectPermission(requesting_origin, embedding_origin)) |
+ return ObjectList(); |
+ |
scoped_ptr<base::DictionaryValue> setting = |
GetWebsiteSetting(requesting_origin, embedding_origin); |
scoped_ptr<base::Value> objects; |
@@ -57,7 +72,9 @@ void ChooserContextBase::GrantObjectPermission( |
const GURL& requesting_origin, |
const GURL& embedding_origin, |
scoped_ptr<base::DictionaryValue> object) { |
- DCHECK(object && IsValidObject(*object)); |
+ DCHECK(object); |
+ DCHECK(IsValidObject(*object)); |
+ DCHECK(CanRequestObjectPermission(requesting_origin, embedding_origin)); |
scoped_ptr<base::DictionaryValue> setting = |
GetWebsiteSetting(requesting_origin, embedding_origin); |
base::ListValue* object_list; |