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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/android/callback_android.h" | 11 #include "base/android/callback_android.h" |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h
" |
21 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 22 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
22 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
23 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 24 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
24 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 25 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
25 #include "chrome/browser/browsing_data/local_data_container.h" | 26 #include "chrome/browser/browsing_data/local_data_container.h" |
26 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 27 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
27 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
28 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 29 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
29 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 30 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
30 #include "chrome/browser/engagement/important_sites_util.h" | 31 #include "chrome/browser/engagement/important_sites_util.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 } | 735 } |
735 | 736 |
736 static void ClearBannerData(JNIEnv* env, | 737 static void ClearBannerData(JNIEnv* env, |
737 const JavaParamRef<jclass>& clazz, | 738 const JavaParamRef<jclass>& clazz, |
738 const JavaParamRef<jstring>& jorigin) { | 739 const JavaParamRef<jstring>& jorigin) { |
739 GetHostContentSettingsMap(false)->SetWebsiteSettingDefaultScope( | 740 GetHostContentSettingsMap(false)->SetWebsiteSettingDefaultScope( |
740 GURL(ConvertJavaStringToUTF8(env, jorigin)), GURL(), | 741 GURL(ConvertJavaStringToUTF8(env, jorigin)), GURL(), |
741 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr); | 742 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr); |
742 } | 743 } |
743 | 744 |
| 745 static jboolean ShouldUseDSEGeolocationSetting( |
| 746 JNIEnv* env, |
| 747 const JavaParamRef<jclass>& clazz, |
| 748 const JavaParamRef<jstring>& jorigin, |
| 749 jboolean is_incognito) { |
| 750 SearchGeolocationService* search_helper = |
| 751 SearchGeolocationService::Factory::GetForBrowserContext( |
| 752 GetActiveUserProfile(is_incognito)); |
| 753 return search_helper && |
| 754 search_helper->UseDSEGeolocationSetting( |
| 755 url::Origin(GURL(ConvertJavaStringToUTF8(env, jorigin)))); |
| 756 } |
| 757 |
| 758 static jboolean GetDSEGeolocationSetting(JNIEnv* env, |
| 759 const JavaParamRef<jclass>& clazz) { |
| 760 SearchGeolocationService* search_helper = |
| 761 SearchGeolocationService::Factory::GetForBrowserContext( |
| 762 GetActiveUserProfile(false /* is_incognito */)); |
| 763 return search_helper->GetDSEGeolocationSetting(); |
| 764 } |
| 765 |
| 766 static void SetDSEGeolocationSetting(JNIEnv* env, |
| 767 const JavaParamRef<jclass>& clazz, |
| 768 jboolean setting) { |
| 769 SearchGeolocationService* search_helper = |
| 770 SearchGeolocationService::Factory::GetForBrowserContext( |
| 771 GetActiveUserProfile(false /* is_incognito */)); |
| 772 return search_helper->SetDSEGeolocationSetting(setting); |
| 773 } |
| 774 |
744 // Register native methods | 775 // Register native methods |
745 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { | 776 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { |
746 return RegisterNativesImpl(env); | 777 return RegisterNativesImpl(env); |
747 } | 778 } |
OLD | NEW |