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

Side by Side Diff: chrome/browser/android/preferences/website_preference_bridge.cc

Issue 952463002: Add UMA to track permission changes from the content settings menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | chrome/browser/content_settings/web_site_settings_uma_util.h » ('j') | 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 "base/strings/string_util.h"
14 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
16 #include "chrome/browser/browsing_data/cookies_tree_model.h" 15 #include "chrome/browser/browsing_data/cookies_tree_model.h"
17 #include "chrome/browser/browsing_data/local_data_container.h" 16 #include "chrome/browser/browsing_data/local_data_container.h"
18 #include "chrome/browser/content_settings/cookie_settings.h" 17 #include "chrome/browser/content_settings/cookie_settings.h"
18 #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
19 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 19 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/storage_partition.h" 24 #include "content/public/browser/storage_partition.h"
25 #include "jni/WebsitePreferenceBridge_jni.h" 25 #include "jni/WebsitePreferenceBridge_jni.h"
26 #include "storage/browser/quota/quota_client.h" 26 #include "storage/browser/quota/quota_client.h"
27 #include "storage/browser/quota/quota_manager.h" 27 #include "storage/browser/quota/quota_manager.h"
28 #include "url/url_constants.h" 28 #include "url/url_constants.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 case 2: setting = CONTENT_SETTING_BLOCK; break; 146 case 2: setting = CONTENT_SETTING_BLOCK; break;
147 default: 147 default:
148 NOTREACHED(); 148 NOTREACHED();
149 } 149 }
150 GetHostContentSettingsMap()->SetContentSetting( 150 GetHostContentSettingsMap()->SetContentSetting(
151 ContentSettingsPattern::FromURLNoWildcard(url), 151 ContentSettingsPattern::FromURLNoWildcard(url),
152 secondary_pattern, 152 secondary_pattern,
153 content_type, 153 content_type,
154 std::string(), 154 std::string(),
155 setting); 155 setting);
156 WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting);
156 } 157 }
157 158
158 static void GetGeolocationOrigins(JNIEnv* env, 159 static void GetGeolocationOrigins(JNIEnv* env,
159 jclass clazz, 160 jclass clazz,
160 jobject list, 161 jobject list,
161 jboolean managedOnly) { 162 jboolean managedOnly) {
162 GetOrigins(env, CONTENT_SETTINGS_TYPE_GEOLOCATION, list, managedOnly); 163 GetOrigins(env, CONTENT_SETTINGS_TYPE_GEOLOCATION, list, managedOnly);
163 } 164 }
164 165
165 static jint GetGeolocationSettingForOrigin(JNIEnv* env, jclass clazz, 166 static jint GetGeolocationSettingForOrigin(JNIEnv* env, jclass clazz,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ProfileManager::GetActiveUserProfile(), 224 ProfileManager::GetActiveUserProfile(),
224 GURL(ConvertJavaStringToUTF8(env, origin))); 225 GURL(ConvertJavaStringToUTF8(env, origin)));
225 } 226 }
226 227
227 static void SetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz, 228 static void SetPushNotificationSettingForOrigin(JNIEnv* env, jclass clazz,
228 jstring origin, jstring embedder, jint value) { 229 jstring origin, jstring embedder, jint value) {
229 // TODO(peter): Web Notification permission behaves differently from all other 230 // TODO(peter): Web Notification permission behaves differently from all other
230 // permission types. See https://crbug.com/416894. 231 // permission types. See https://crbug.com/416894.
231 Profile* profile = ProfileManager::GetActiveUserProfile(); 232 Profile* profile = ProfileManager::GetActiveUserProfile();
232 GURL url = GURL(ConvertJavaStringToUTF8(env, origin)); 233 GURL url = GURL(ConvertJavaStringToUTF8(env, origin));
233 234 ContentSetting setting = CONTENT_SETTING_DEFAULT;
234 switch (value) { 235 switch (value) {
235 case -1: 236 case -1:
236 DesktopNotificationProfileUtil::ClearSetting( 237 DesktopNotificationProfileUtil::ClearSetting(
237 profile, ContentSettingsPattern::FromURLNoWildcard(url)); 238 profile, ContentSettingsPattern::FromURLNoWildcard(url));
238 break; 239 break;
239 case 1: 240 case 1:
240 DesktopNotificationProfileUtil::GrantPermission(profile, url); 241 DesktopNotificationProfileUtil::GrantPermission(profile, url);
242 setting = CONTENT_SETTING_ALLOW;
241 break; 243 break;
242 case 2: 244 case 2:
243 DesktopNotificationProfileUtil::DenyPermission(profile, url); 245 DesktopNotificationProfileUtil::DenyPermission(profile, url);
246 setting = CONTENT_SETTING_BLOCK;
244 break; 247 break;
245 default: 248 default:
246 NOTREACHED(); 249 NOTREACHED();
247 } 250 }
251 WebSiteSettingsUmaUtil::LogPermissionChange(
252 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
248 } 253 }
249 254
250 static void GetVoiceAndVideoCaptureOrigins(JNIEnv* env, 255 static void GetVoiceAndVideoCaptureOrigins(JNIEnv* env,
251 jclass clazz, 256 jclass clazz,
252 jobject list, 257 jobject list,
253 jboolean managedOnly) { 258 jboolean managedOnly) {
254 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, list, managedOnly); 259 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, list, managedOnly);
255 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, list, managedOnly); 260 GetOrigins(env, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, list, managedOnly);
256 } 261 }
257 262
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return GetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_COOKIES, origin, 321 return GetSettingForOrigin(env, CONTENT_SETTINGS_TYPE_COOKIES, origin,
317 embedder); 322 embedder);
318 } 323 }
319 324
320 static void SetCookieSettingForOrigin(JNIEnv* env, jclass clazz, 325 static void SetCookieSettingForOrigin(JNIEnv* env, jclass clazz,
321 jstring origin, jstring embedder, jint value) { 326 jstring origin, jstring embedder, jint value) {
322 GURL url(ConvertJavaStringToUTF8(env, origin)); 327 GURL url(ConvertJavaStringToUTF8(env, origin));
323 ContentSettingsPattern primary_pattern( 328 ContentSettingsPattern primary_pattern(
324 ContentSettingsPattern::FromURLNoWildcard(url)); 329 ContentSettingsPattern::FromURLNoWildcard(url));
325 ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard()); 330 ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard());
331 ContentSetting setting = CONTENT_SETTING_DEFAULT;
326 if (value == -1) { 332 if (value == -1) {
327 GetCookieSettings()->ResetCookieSetting(primary_pattern, secondary_pattern); 333 GetCookieSettings()->ResetCookieSetting(primary_pattern, secondary_pattern);
328 } else { 334 } else {
335 setting = value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
329 GetCookieSettings()->SetCookieSetting(primary_pattern, secondary_pattern, 336 GetCookieSettings()->SetCookieSetting(primary_pattern, secondary_pattern,
330 value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); 337 setting);
331 } 338 }
339 WebSiteSettingsUmaUtil::LogPermissionChange(
340 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
332 } 341 }
333 342
334 namespace { 343 namespace {
335 344
336 class SiteDataDeleteHelper : 345 class SiteDataDeleteHelper :
337 public base::RefCountedThreadSafe<SiteDataDeleteHelper>, 346 public base::RefCountedThreadSafe<SiteDataDeleteHelper>,
338 public CookiesTreeModel::Observer { 347 public CookiesTreeModel::Observer {
339 public: 348 public:
340 SiteDataDeleteHelper(Profile* profile, const GURL& domain) 349 SiteDataDeleteHelper(Profile* profile, const GURL& domain)
341 : profile_(profile), domain_(domain), ending_batch_processing_(false) { 350 : profile_(profile), domain_(domain), ending_batch_processing_(false) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 GURL url(ConvertJavaStringToUTF8(env, jorigin)); 656 GURL url(ConvertJavaStringToUTF8(env, jorigin));
648 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( 657 scoped_refptr<SiteDataDeleteHelper> site_data_deleter(
649 new SiteDataDeleteHelper(profile, url)); 658 new SiteDataDeleteHelper(profile, url));
650 site_data_deleter->Run(); 659 site_data_deleter->Run();
651 } 660 }
652 661
653 // Register native methods 662 // Register native methods
654 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { 663 bool RegisterWebsitePreferenceBridge(JNIEnv* env) {
655 return RegisterNativesImpl(env); 664 return RegisterNativesImpl(env);
656 } 665 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/web_site_settings_uma_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698