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

Unified Diff: chrome/browser/android/preferences/website_preference_bridge.cc

Issue 921803002: Enable Notification permissions to be toggled in Site Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/preferences/website_preference_bridge.cc
diff --git a/chrome/browser/android/preferences/website_preference_bridge.cc b/chrome/browser/android/preferences/website_preference_bridge.cc
index d21bf9ddf2ee2c587b376588a6be7dde8ab82462..793d7d2e448b29ea7298a15614707dbc684c1443 100644
--- a/chrome/browser/android/preferences/website_preference_bridge.cc
+++ b/chrome/browser/android/preferences/website_preference_bridge.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/browser/browsing_data/local_data_container.h"
#include "chrome/browser/content_settings/cookie_settings.h"
+#include "chrome/browser/notifications/desktop_notification_profile_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
@@ -190,15 +191,32 @@ static void GetPushNotificationOrigins(JNIEnv* env,
static jint GetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz,
jstring origin, jstring embedder) {
- return GetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- origin, embedder);
+ return DesktopNotificationProfileUtil::GetContentSetting(
+ ProfileManager::GetActiveUserProfile(),
+ GURL(ConvertJavaStringToUTF8(env, origin)));
}
static void SetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz,
jstring origin, jstring embedder, jint value) {
- GURL embedder_url(ConvertJavaStringToUTF8(env, embedder));
- SetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- origin, ContentSettingsPattern::FromURLNoWildcard(embedder_url), value);
+ // TODO(peter): Web Notification permission behaves differently from all other
+ // permission types. See https://crbug.com/416894.
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ GURL url = GURL(ConvertJavaStringToUTF8(env, origin));
+
+ switch (value) {
+ case -1:
+ DesktopNotificationProfileUtil::ClearSetting(
+ profile, ContentSettingsPattern::FromURLNoWildcard(url));
+ break;
+ case 1:
+ DesktopNotificationProfileUtil::GrantPermission(profile, url);
+ break;
+ case 2:
+ DesktopNotificationProfileUtil::DenyPermission(profile, url);
+ break;
+ default:
+ NOTREACHED();
+ }
Finnur 2015/02/13 14:58:46 I was going to point out that this breaks the Site
}
static void GetVoiceAndVideoCaptureOrigins(JNIEnv* env,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698