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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 819463002: Implement RevokePermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix todo comments Created 5 years, 11 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/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index b6e6de5ecbbf505c069ddec6b2190416543aff33..68ec9e0040d15a85df8a27d7e10e6906e71db5cd 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -620,6 +620,36 @@ ContentSettingToPermissionStatus(ContentSetting setting) {
return content::PERMISSION_STATUS_DENIED;
}
+PermissionContextBase* GetPermissionContext(Profile* profile,
+ content::PermissionType permission) {
+ switch (permission) {
+ case content::PERMISSION_MIDI_SYSEX:
+ return MidiPermissionContextFactory::GetForProfile(profile);
+ case content::PERMISSION_NOTIFICATIONS:
+#if defined(ENABLE_NOTIFICATIONS)
+ return DesktopNotificationServiceFactory::GetForProfile(profile);
+#else
+ NOTIMPLEMENTED();
+#endif
+ case content::PERMISSION_GEOLOCATION:
+ return GeolocationPermissionContextFactory::GetForProfile(profile);
+ case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER:
+#if defined(OS_ANDROID)
+ return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
+ profile);
+#else
+ NOTIMPLEMENTED();
+ break;
+#endif
+ case content::PERMISSION_PUSH_MESSAGING:
+ return gcm::PushMessagingPermissionContextFactory::GetForProfile(profile);
+ case content::PERMISSION_NUM:
+ NOTREACHED() << "Invalid RequestPermission for " << permission;
+ break;
+ }
+ return nullptr;
+}
+
} // namespace
namespace chrome {
@@ -1946,45 +1976,30 @@ content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus(
const GURL& embedding_origin) {
DCHECK(browser_context);
Profile* profile = Profile::FromBrowserContext(browser_context);
+ PermissionContextBase* context = GetPermissionContext(profile, permission);
- PermissionContextBase* context = nullptr;
- switch (permission) {
- case content::PERMISSION_MIDI_SYSEX:
- context = MidiPermissionContextFactory::GetForProfile(profile);
- break;
- case content::PERMISSION_NOTIFICATIONS:
-#if defined(ENABLE_NOTIFICATIONS)
- context = DesktopNotificationServiceFactory::GetForProfile(profile);
-#else
- NOTIMPLEMENTED();
-#endif
- break;
- case content::PERMISSION_GEOLOCATION:
- context = GeolocationPermissionContextFactory::GetForProfile(profile);
- break;
- case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER:
-#if defined(OS_ANDROID)
- context = ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
- profile);
-#else
- NOTIMPLEMENTED();
-#endif
- break;
- case content::PERMISSION_PUSH_MESSAGING:
- context = gcm::PushMessagingPermissionContextFactory::GetForProfile(
- profile);
- break;
- case content::PERMISSION_NUM:
- NOTREACHED() << "Invalid RequestPermission for " << permission;
- break;
- }
+ if (!context)
+ return content::PERMISSION_STATUS_ASK;
+
+ return ContentSettingToPermissionStatus(
+ context->GetPermissionStatus(requesting_origin.GetOrigin(),
+ embedding_origin.GetOrigin()));
+}
+
+void ChromeContentBrowserClient::ResetPermission(
+ content::PermissionType permission,
+ content::BrowserContext* browser_context,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) {
+ DCHECK(browser_context);
+ Profile* profile = Profile::FromBrowserContext(browser_context);
+ PermissionContextBase* context = GetPermissionContext(profile, permission);
- ContentSetting result = context
- ? context->GetPermissionStatus(requesting_origin.GetOrigin(),
- embedding_origin.GetOrigin())
- : CONTENT_SETTING_DEFAULT;
+ if (!context)
+ return;
- return ContentSettingToPermissionStatus(result);
+ context->ResetPermission(requesting_origin.GetOrigin(),
+ embedding_origin.GetOrigin());
}
void ChromeContentBrowserClient::CancelPermissionRequest(
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/content_settings/permission_context_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698