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

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

Issue 2945243002: Permissions: Allow PermissionManager to return more PermissionStatusSources.
Patch Set: Cleanup. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/permissions/permission_context_base.cc
diff --git a/chrome/browser/permissions/permission_context_base.cc b/chrome/browser/permissions/permission_context_base.cc
index 3f263c4ca169d9d0f5dac2f99414c3ff97bc1f63..9edebc75166ecf3ddc0def2d5f7cd4927a8795d5 100644
--- a/chrome/browser/permissions/permission_context_base.cc
+++ b/chrome/browser/permissions/permission_context_base.cc
@@ -135,6 +135,11 @@ void PermissionContextBase::RequestPermission(
if (result.content_setting == CONTENT_SETTING_ALLOW ||
result.content_setting == CONTENT_SETTING_BLOCK) {
switch (result.source) {
+ case PermissionStatusSource::SAFE_BROWSING_BLACKLIST:
+ LogPermissionBlockedMessage(web_contents,
+ kPermissionBlockedBlacklistMessage,
+ content_settings_type_);
+ break;
case PermissionStatusSource::KILL_SWITCH:
// Block the request and log to the developer console.
LogPermissionBlockedMessage(web_contents,
@@ -152,12 +157,10 @@ void PermissionContextBase::RequestPermission(
kPermissionBlockedRepeatedIgnoresMessage,
content_settings_type_);
break;
- case PermissionStatusSource::SAFE_BROWSING_BLACKLIST:
- LogPermissionBlockedMessage(web_contents,
- kPermissionBlockedBlacklistMessage,
- content_settings_type_);
- break;
case PermissionStatusSource::UNSPECIFIED:
+ case PermissionStatusSource::INSECURE_ORIGIN:
+ case PermissionStatusSource::ENTERPRISE_POLICY:
+ case PermissionStatusSource::EXTENSION:
break;
}
@@ -232,7 +235,7 @@ PermissionResult PermissionContextBase::GetPermissionStatus(
if (IsRestrictedToSecureOrigins()) {
if (!content::IsOriginSecure(requesting_origin)) {
return PermissionResult(CONTENT_SETTING_BLOCK,
- PermissionStatusSource::UNSPECIFIED);
+ PermissionStatusSource::INSECURE_ORIGIN);
}
// TODO(raymes): We should check the entire chain of embedders here whenever
@@ -243,7 +246,7 @@ PermissionResult PermissionContextBase::GetPermissionStatus(
if (!requesting_origin.SchemeIs(extensions::kExtensionScheme) &&
!content::IsOriginSecure(embedding_origin)) {
return PermissionResult(CONTENT_SETTING_BLOCK,
- PermissionStatusSource::UNSPECIFIED);
+ PermissionStatusSource::INSECURE_ORIGIN);
}
}
@@ -255,18 +258,15 @@ PermissionResult PermissionContextBase::GetPermissionStatus(
PermissionStatusSource::UNSPECIFIED);
}
- ContentSetting content_setting = GetPermissionStatusInternal(
+ PermissionResult result = GetPermissionStatusInternal(
render_frame_host, requesting_origin, embedding_origin);
- if (content_setting == CONTENT_SETTING_ASK) {
- PermissionResult result =
- PermissionDecisionAutoBlocker::GetForProfile(profile_)
- ->GetEmbargoResult(requesting_origin, content_settings_type_);
+ if (result.content_setting == CONTENT_SETTING_ASK) {
+ result = PermissionDecisionAutoBlocker::GetForProfile(profile_)
+ ->GetEmbargoResult(requesting_origin, content_settings_type_);
DCHECK(result.content_setting == CONTENT_SETTING_ASK ||
result.content_setting == CONTENT_SETTING_BLOCK);
- return result;
}
-
- return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED);
+ return result;
}
PermissionResult PermissionContextBase::UpdatePermissionStatusWithDeviceStatus(
@@ -313,13 +313,23 @@ bool PermissionContextBase::IsPermissionKillSwitchOn() const {
return param == kPermissionsKillSwitchBlockedValue;
}
-ContentSetting PermissionContextBase::GetPermissionStatusInternal(
+PermissionResult PermissionContextBase::GetPermissionStatusInternal(
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const GURL& embedding_origin) const {
- return HostContentSettingsMapFactory::GetForProfile(profile_)
- ->GetContentSetting(requesting_origin, embedding_origin,
- content_settings_storage_type(), std::string());
+ content_settings::SettingInfo info;
+ std::unique_ptr<base::Value> value =
+ HostContentSettingsMapFactory::GetForProfile(profile_)->GetWebsiteSetting(
+ requesting_origin, embedding_origin, content_settings_storage_type(),
+ std::string(), &info);
+ ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
+ DCHECK(value.get());
+ DCHECK_EQ(base::Value::Type::INTEGER, value->GetType());
+ content_setting = content_settings::ValueToContentSetting(value.get());
+ return PermissionResult(
+ content_setting,
+ PermissionUtil::ConvertSettingSourceToPermissionStatusSource(
+ info.source));
}
void PermissionContextBase::DecidePermission(
« no previous file with comments | « chrome/browser/permissions/permission_context_base.h ('k') | chrome/browser/permissions/permission_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698