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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/preferences/website_preference_bridge.h" 5 #include "chrome/browser/android/preferences/website_preference_bridge.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
15 #include "chrome/browser/browsing_data/cookies_tree_model.h" 15 #include "chrome/browser/browsing_data/cookies_tree_model.h"
16 #include "chrome/browser/browsing_data/local_data_container.h" 16 #include "chrome/browser/browsing_data/local_data_container.h"
17 #include "chrome/browser/content_settings/cookie_settings.h" 17 #include "chrome/browser/content_settings/cookie_settings.h"
18 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "components/content_settings/core/browser/host_content_settings_map.h" 21 #include "components/content_settings/core/browser/host_content_settings_map.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/storage_partition.h" 23 #include "content/public/browser/storage_partition.h"
23 #include "jni/WebsitePreferenceBridge_jni.h" 24 #include "jni/WebsitePreferenceBridge_jni.h"
24 #include "storage/browser/quota/quota_client.h" 25 #include "storage/browser/quota/quota_client.h"
25 #include "storage/browser/quota/quota_manager.h" 26 #include "storage/browser/quota/quota_manager.h"
26 27
27 using base::android::ConvertJavaStringToUTF8; 28 using base::android::ConvertJavaStringToUTF8;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 184 }
184 185
185 static void GetPushNotificationOrigins(JNIEnv* env, 186 static void GetPushNotificationOrigins(JNIEnv* env,
186 jclass clazz, 187 jclass clazz,
187 jobject list) { 188 jobject list) {
188 GetOrigins(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, list, false); 189 GetOrigins(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, list, false);
189 } 190 }
190 191
191 static jint GetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz, 192 static jint GetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz,
192 jstring origin, jstring embedder) { 193 jstring origin, jstring embedder) {
193 return GetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 194 return DesktopNotificationProfileUtil::GetContentSetting(
194 origin, embedder); 195 ProfileManager::GetActiveUserProfile(),
196 GURL(ConvertJavaStringToUTF8(env, origin)));
195 } 197 }
196 198
197 static void SetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz, 199 static void SetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz,
198 jstring origin, jstring embedder, jint value) { 200 jstring origin, jstring embedder, jint value) {
199 GURL embedder_url(ConvertJavaStringToUTF8(env, embedder)); 201 // TODO(peter): Web Notification permission behaves differently from all other
200 SetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 202 // permission types. See https://crbug.com/416894.
201 origin, ContentSettingsPattern::FromURLNoWildcard(embedder_url), value); 203 Profile* profile = ProfileManager::GetActiveUserProfile();
204 GURL url = GURL(ConvertJavaStringToUTF8(env, origin));
205
206 switch (value) {
207 case -1:
208 DesktopNotificationProfileUtil::ClearSetting(
209 profile, ContentSettingsPattern::FromURLNoWildcard(url));
210 break;
211 case 1:
212 DesktopNotificationProfileUtil::GrantPermission(profile, url);
213 break;
214 case 2:
215 DesktopNotificationProfileUtil::DenyPermission(profile, url);
216 break;
217 default:
218 NOTREACHED();
219 }
Finnur 2015/02/13 14:58:46 I was going to point out that this breaks the Site
202 } 220 }
203 221
204 static void GetVoiceAndVideoCaptureOrigins(JNIEnv* env, 222 static void GetVoiceAndVideoCaptureOrigins(JNIEnv* env,
205 jclass clazz, 223 jclass clazz,
206 jobject list, 224 jobject list,
207 jboolean managedOnly) { 225 jboolean managedOnly) {
208 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, list, managedOnly); 226 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, list, managedOnly);
209 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, list, managedOnly); 227 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, list, managedOnly);
210 } 228 }
211 229
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 GURL url(ConvertJavaStringToUTF8(env, jorigin)); 619 GURL url(ConvertJavaStringToUTF8(env, jorigin));
602 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( 620 scoped_refptr<SiteDataDeleteHelper> site_data_deleter(
603 new SiteDataDeleteHelper(profile, url)); 621 new SiteDataDeleteHelper(profile, url));
604 site_data_deleter->Run(); 622 site_data_deleter->Run();
605 } 623 }
606 624
607 // Register native methods 625 // Register native methods
608 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { 626 bool RegisterWebsitePreferenceBridge(JNIEnv* env) {
609 return RegisterNativesImpl(env); 627 return RegisterNativesImpl(env);
610 } 628 }
OLDNEW
« 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