| 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/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_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/web_site_settings_uma_util.h" | 19 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
| 19 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 20 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "components/content_settings/core/browser/cookie_settings.h" | 23 #include "components/content_settings/core/browser/cookie_settings.h" |
| 23 #include "components/content_settings/core/browser/host_content_settings_map.h" | 24 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
| 26 #include "jni/WebsitePreferenceBridge_jni.h" | 27 #include "jni/WebsitePreferenceBridge_jni.h" |
| 27 #include "storage/browser/quota/quota_client.h" | 28 #include "storage/browser/quota/quota_client.h" |
| 28 #include "storage/browser/quota/quota_manager.h" | 29 #include "storage/browser/quota/quota_manager.h" |
| 29 #include "url/url_constants.h" | 30 #include "url/url_constants.h" |
| 30 | 31 |
| 31 using base::android::ConvertJavaStringToUTF8; | 32 using base::android::ConvertJavaStringToUTF8; |
| 32 using base::android::ConvertUTF8ToJavaString; | 33 using base::android::ConvertUTF8ToJavaString; |
| 33 using base::android::JavaRef; | 34 using base::android::JavaRef; |
| 34 using base::android::ScopedJavaGlobalRef; | 35 using base::android::ScopedJavaGlobalRef; |
| 35 using base::android::ScopedJavaLocalRef; | 36 using base::android::ScopedJavaLocalRef; |
| 36 using content::BrowserThread; | 37 using content::BrowserThread; |
| 37 | 38 |
| 38 static Profile* GetActiveUserProfile(bool is_incognito) { | 39 static Profile* GetActiveUserProfile(bool is_incognito) { |
| 39 Profile* profile = ProfileManager::GetActiveUserProfile(); | 40 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 40 if (is_incognito) | 41 if (is_incognito) |
| 41 profile = profile->GetOffTheRecordProfile(); | 42 profile = profile->GetOffTheRecordProfile(); |
| 42 return profile; | 43 return profile; |
| 43 } | 44 } |
| 44 | 45 |
| 45 static HostContentSettingsMap* GetHostContentSettingsMap(bool is_incognito) { | 46 static HostContentSettingsMap* GetHostContentSettingsMap(bool is_incognito) { |
| 46 return GetActiveUserProfile(is_incognito)->GetHostContentSettingsMap(); | 47 return HostContentSettingsMapFactory::GetForProfile( |
| 48 GetActiveUserProfile(is_incognito)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 static void GetOrigins(JNIEnv* env, | 51 static void GetOrigins(JNIEnv* env, |
| 50 ContentSettingsType content_type, | 52 ContentSettingsType content_type, |
| 51 jobject list, | 53 jobject list, |
| 52 jboolean managedOnly) { | 54 jboolean managedOnly) { |
| 53 ContentSettingsForOneType all_settings; | 55 ContentSettingsForOneType all_settings; |
| 54 HostContentSettingsMap* content_settings_map = | 56 HostContentSettingsMap* content_settings_map = |
| 55 GetHostContentSettingsMap(false); | 57 GetHostContentSettingsMap(false); |
| 56 content_settings_map->GetSettingsForOneType( | 58 content_settings_map->GetSettingsForOneType( |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 GURL url(ConvertJavaStringToUTF8(env, jorigin)); | 804 GURL url(ConvertJavaStringToUTF8(env, jorigin)); |
| 803 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( | 805 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( |
| 804 new SiteDataDeleteHelper(profile, url)); | 806 new SiteDataDeleteHelper(profile, url)); |
| 805 site_data_deleter->Run(); | 807 site_data_deleter->Run(); |
| 806 } | 808 } |
| 807 | 809 |
| 808 // Register native methods | 810 // Register native methods |
| 809 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 811 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
| 810 return RegisterNativesImpl(env); | 812 return RegisterNativesImpl(env); |
| 811 } | 813 } |
| OLD | NEW |