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

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 660293002: Refactor extension code for notification permission handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index c1434fdfeda72886772211d343c8dbaac977ee4c..df940d5cd6a7cb8c0a533e7a3ad3110c5c1a0b7d 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/content_settings/core/common/permission_request_id.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_notification_delegate.h"
@@ -42,6 +43,7 @@
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/info_map.h"
+#include "extensions/browser/suggest_permission_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
@@ -138,14 +140,45 @@ DesktopNotificationService::~DesktopNotificationService() {
void DesktopNotificationService::RequestNotificationPermission(
content::WebContents* web_contents,
const PermissionRequestID& request_id,
- const GURL& requesting_frame,
+ const GURL& requesting_origin,
bool user_gesture,
const NotificationPermissionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+#if defined(ENABLE_EXTENSIONS)
+ extensions::InfoMap* extension_info_map =
+ extensions::ExtensionSystem::Get(profile_)->info_map();
+ const extensions::Extension* extension = NULL;
+ if (extension_info_map) {
+ extensions::ExtensionSet extensions;
+ extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
+ requesting_origin,
+ request_id.render_process_id(),
+ extensions::APIPermission::kNotifications,
+ &extensions);
+ for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
+ iter != extensions.end(); ++iter) {
+ if (IsNotifierEnabled(NotifierId(
+ NotifierId::APPLICATION, (*iter)->id()))) {
+ extension = iter->get();
+ break;
+ }
+ }
+ }
+ if (IsExtensionWithPermissionOrSuggestInConsole(
+ extensions::APIPermission::kNotifications,
+ extension,
+ web_contents->GetRenderViewHost())) {
+ callback.Run(blink::WebNotificationPermissionAllowed);
+ return;
+ }
+#endif
+
+
Peter Beverloo 2014/10/17 15:29:31 nit: double white line
Miguel Garcia 2014/10/17 16:21:41 Done.
RequestPermission(
web_contents,
request_id,
- requesting_frame,
+ requesting_origin,
user_gesture,
base::Bind(&DesktopNotificationService::OnNotificationPermissionRequested,
weak_factory_.GetWeakPtr(),
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698