OLD | NEW |
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/macros.h" | 12 #include "base/macros.h" |
13 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_quota_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_factory.h" | 17 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
20 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 20 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
21 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 21 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 22 #include "chrome/browser/permissions/permission_util.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/storage/storage_info_fetcher.h" | 25 #include "chrome/browser/storage/storage_info_fetcher.h" |
25 #include "components/content_settings/core/browser/cookie_settings.h" | 26 #include "components/content_settings/core/browser/cookie_settings.h" |
26 #include "components/content_settings/core/browser/host_content_settings_map.h" | 27 #include "components/content_settings/core/browser/host_content_settings_map.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/storage_partition.h" | 29 #include "content/public/browser/storage_partition.h" |
29 #include "jni/WebsitePreferenceBridge_jni.h" | 30 #include "jni/WebsitePreferenceBridge_jni.h" |
30 #include "storage/browser/quota/quota_manager.h" | 31 #include "storage/browser/quota/quota_manager.h" |
31 #include "storage/common/quota/quota_status_code.h" | 32 #include "storage/common/quota/quota_status_code.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 void SetSettingForOrigin(JNIEnv* env, | 132 void SetSettingForOrigin(JNIEnv* env, |
132 ContentSettingsType content_type, | 133 ContentSettingsType content_type, |
133 jstring origin, | 134 jstring origin, |
134 jstring embedder, | 135 jstring embedder, |
135 ContentSetting setting, | 136 ContentSetting setting, |
136 jboolean is_incognito) { | 137 jboolean is_incognito) { |
137 GURL origin_url(ConvertJavaStringToUTF8(env, origin)); | 138 GURL origin_url(ConvertJavaStringToUTF8(env, origin)); |
138 GURL embedder_url = | 139 GURL embedder_url = |
139 embedder ? GURL(ConvertJavaStringToUTF8(env, embedder)) : GURL(); | 140 embedder ? GURL(ConvertJavaStringToUTF8(env, embedder)) : GURL(); |
140 GetHostContentSettingsMap(is_incognito) | 141 PermissionUtil::SetContentSettingAndRecordRevocation( |
141 ->SetContentSettingDefaultScope(origin_url, embedder_url, content_type, | 142 GetActiveUserProfile(is_incognito), origin_url, embedder_url, |
142 std::string(), setting); | 143 content_type, std::string(), setting); |
143 WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting); | 144 WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting); |
144 } | 145 } |
145 | 146 |
146 } // anonymous namespace | 147 } // anonymous namespace |
147 | 148 |
148 static void GetFullscreenOrigins(JNIEnv* env, | 149 static void GetFullscreenOrigins(JNIEnv* env, |
149 const JavaParamRef<jclass>& clazz, | 150 const JavaParamRef<jclass>& clazz, |
150 const JavaParamRef<jobject>& list, | 151 const JavaParamRef<jobject>& list, |
151 jboolean managedOnly) { | 152 jboolean managedOnly) { |
152 GetOrigins(env, CONTENT_SETTINGS_TYPE_FULLSCREEN, | 153 GetOrigins(env, CONTENT_SETTINGS_TYPE_FULLSCREEN, |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 751 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
751 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( | 752 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( |
752 new SiteDataDeleteHelper(profile, url)); | 753 new SiteDataDeleteHelper(profile, url)); |
753 site_data_deleter->Run(); | 754 site_data_deleter->Run(); |
754 } | 755 } |
755 | 756 |
756 // Register native methods | 757 // Register native methods |
757 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 758 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
758 return RegisterNativesImpl(env); | 759 return RegisterNativesImpl(env); |
759 } | 760 } |
OLD | NEW |