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

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

Issue 2686463002: Add a source to the result of PermissionContextBase::GetPermissionStatus (Closed)
Patch Set: Created 3 years, 10 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 c00f3e7aa503570ad94c778a64b0b4923857aa9d..32a5cecb48ffcde6653a7f50ee97e957b03e3265 100644
--- a/chrome/browser/permissions/permission_context_base.cc
+++ b/chrome/browser/permissions/permission_context_base.cc
@@ -50,6 +50,12 @@ const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] =
const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] =
"blocked";
+PermissionResult::PermissionResult(ContentSetting cs,
+ PermissionStatusSource pss)
+ : content_setting(cs), source(pss) {}
+
+PermissionResult::~PermissionResult() {}
+
PermissionContextBase::PermissionContextBase(
Profile* profile,
const content::PermissionType permission_type,
@@ -111,17 +117,17 @@ void PermissionContextBase::RequestPermission(
// Synchronously check the content setting to see if the user has already made
// a decision, or if the origin is under embargo. If so, respect that
// decision.
- ContentSetting content_setting =
+ PermissionResult result =
GetPermissionStatus(requesting_origin, embedding_origin);
- if (content_setting == CONTENT_SETTING_ALLOW) {
+ if (result.content_setting == CONTENT_SETTING_ALLOW) {
HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage(
requesting_origin, embedding_origin, content_settings_type_);
}
- if (content_setting == CONTENT_SETTING_ALLOW ||
- content_setting == CONTENT_SETTING_BLOCK) {
+ if (result.content_setting == CONTENT_SETTING_ALLOW ||
+ result.content_setting == CONTENT_SETTING_BLOCK) {
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
- false /* persist */, content_setting);
+ false /* persist */, result.content_setting);
return;
}
@@ -164,16 +170,19 @@ void PermissionContextBase::ContinueRequestPermission(
user_gesture, callback);
}
-ContentSetting PermissionContextBase::GetPermissionStatus(
+PermissionResult PermissionContextBase::GetPermissionStatus(
const GURL& requesting_origin,
const GURL& embedding_origin) const {
// If the permission has been disabled through Finch, block all requests.
- if (IsPermissionKillSwitchOn())
- return CONTENT_SETTING_BLOCK;
+ if (IsPermissionKillSwitchOn()) {
+ return PermissionResult(CONTENT_SETTING_BLOCK,
+ PermissionStatusSource::KILL_SWITCH);
+ }
if (IsRestrictedToSecureOrigins() &&
!content::IsOriginSecure(requesting_origin)) {
- return CONTENT_SETTING_BLOCK;
+ return PermissionResult(CONTENT_SETTING_BLOCK,
+ PermissionStatusSource::INSECURE_ORIGIN);
}
ContentSetting content_setting =
@@ -181,9 +190,15 @@ ContentSetting PermissionContextBase::GetPermissionStatus(
if (content_setting == CONTENT_SETTING_ASK &&
PermissionDecisionAutoBlocker::GetForProfile(profile_)->IsUnderEmbargo(
permission_type_, requesting_origin)) {
- return CONTENT_SETTING_BLOCK;
+ // TODO(raymes): Return the appropriate reason here, determined by
+ // PermissionDecisionAutoBlocker.
+ return PermissionResult(CONTENT_SETTING_BLOCK,
+ PermissionStatusSource::UNSPECIFIED);
}
- return content_setting;
+
+ // TODO(raymes): Return the appropriate reason here, determined by
+ // GetPermissionStatusInternal.
+ return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED);
}
void PermissionContextBase::ResetPermission(

Powered by Google App Engine
This is Rietveld 408576698