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

Unified Diff: chrome/browser/permissions/chooser_context_base.cc

Issue 1427433017: Add a "guard" content settings type for chooser permissions. Base URL: https://chromium.googlesource.com/chromium/src.git@permission_store
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/permissions/chooser_context_base.h ('k') | chrome/browser/usb/usb_chooser_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/browser/permissions/chooser_context_base.h ('k') | chrome/browser/usb/usb_chooser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698