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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 750633003: Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 a872ec6c9b027869d158c6dc1934f05be88253a9..5e4408578ca05e87f35a07ba6ee1459315cabd39 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1971,6 +1971,55 @@ void ChromeContentBrowserClient::RequestPermission(
}
}
+void ChromeContentBrowserClient::HasPermission(
+ content::PermissionType permission,
+ content::WebContents* web_contents,
+ const GURL& requesting_frame,
+ const base::Callback<void(bool)>& result_callback) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+
+ 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:
+#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)
+ result_callback.Run(false);
+
+ ContentSetting result = context->GetPermissionStatus(
+ requesting_frame.GetOrigin(),
+ web_contents->GetLastCommittedURL().GetOrigin());
+ result_callback.Run(result == CONTENT_SETTING_ALLOW);
+}
+
void ChromeContentBrowserClient::CancelPermissionRequest(
content::PermissionType permission,
content::WebContents* web_contents,

Powered by Google App Engine
This is Rietveld 408576698