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

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

Issue 1207363002: Simplify permission-related code for Web Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/notifications/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index b6ee5a42fe63bae00a8eeac3c00a5b05fa1332c2..389fe69afacd4654e1dab7c6658af1729f3c0187 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_object_proxy.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
-#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
@@ -50,8 +49,7 @@ void DesktopNotificationService::RegisterProfilePrefs(
}
DesktopNotificationService::DesktopNotificationService(Profile* profile)
- : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS),
- profile_(profile)
+ : profile_(profile)
#if defined(ENABLE_EXTENSIONS)
,
extension_registry_observer_(this)
@@ -87,55 +85,6 @@ DesktopNotificationService::DesktopNotificationService(Profile* profile)
DesktopNotificationService::~DesktopNotificationService() {
}
-void DesktopNotificationService::RequestNotificationPermission(
- content::WebContents* web_contents,
- const PermissionRequestID& request_id,
- const GURL& requesting_origin,
- bool user_gesture,
- const BrowserPermissionCallback& result_callback) {
- DCHECK_CURRENTLY_ON(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->GetMainFrame())) {
- result_callback.Run(CONTENT_SETTING_ALLOW);
- return;
- }
-#endif
-
- // Track whether the requesting and embedding origins are different when
- // permission to display Web Notifications is being requested.
- UMA_HISTOGRAM_BOOLEAN("Notifications.DifferentRequestingEmbeddingOrigins",
- requesting_origin.GetOrigin() !=
- web_contents->GetLastCommittedURL().GetOrigin());
-
- RequestPermission(web_contents,
- request_id,
- requesting_origin,
- user_gesture,
- result_callback);
-}
-
bool DesktopNotificationService::IsNotifierEnabled(
const NotifierId& notifier_id) const {
switch (notifier_id.type) {
@@ -232,30 +181,6 @@ void DesktopNotificationService::OnExtensionUninstalled(
}
#endif
-// Unlike other permission types, granting a notification for a given origin
-// will not take into account the |embedder_origin|, it will only be based
-// on the requesting iframe origin.
-// TODO(mukai) Consider why notifications behave differently than
-// other permissions. crbug.com/416894
-void DesktopNotificationService::UpdateContentSetting(
- const GURL& requesting_origin,
- const GURL& embedder_origin,
- ContentSetting content_setting) {
- DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
- content_setting == CONTENT_SETTING_BLOCK);
-
- if (content_setting == CONTENT_SETTING_ALLOW) {
- DesktopNotificationProfileUtil::GrantPermission(
- profile_, requesting_origin);
- } else {
- DesktopNotificationProfileUtil::DenyPermission(profile_, requesting_origin);
- }
-}
-
-bool DesktopNotificationService::IsRestrictedToSecureOrigins() const {
- return false;
-}
-
void DesktopNotificationService::FirePermissionLevelChangedEvent(
const NotifierId& notifier_id, bool enabled) {
#if defined(ENABLE_EXTENSIONS)

Powered by Google App Engine
This is Rietveld 408576698