| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/pref_service_bridge.h" | 5 #include "chrome/browser/android/preferences/pref_service_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/android/build_info.h" | 13 #include "base/android/build_info.h" |
| 14 #include "base/android/jni_android.h" | 14 #include "base/android/jni_android.h" |
| 15 #include "base/android/jni_array.h" | 15 #include "base/android/jni_array.h" |
| 16 #include "base/android/jni_string.h" | 16 #include "base/android/jni_string.h" |
| 17 #include "base/android/jni_weak_ref.h" | 17 #include "base/android/jni_weak_ref.h" |
| 18 #include "base/feature_list.h" |
| 18 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 19 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
| 20 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/scoped_observer.h" | 22 #include "base/scoped_observer.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/values.h" | 24 #include "base/values.h" |
| 24 #include "chrome/browser/android/preferences/important_sites_util.h" | 25 #include "chrome/browser/android/preferences/important_sites_util.h" |
| 25 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 27 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 27 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 28 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 29 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 30 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 31 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 31 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 32 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
| 32 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 33 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 33 #include "chrome/browser/history/web_history_service_factory.h" | 34 #include "chrome/browser/history/web_history_service_factory.h" |
| 34 #include "chrome/browser/net/prediction_options.h" | 35 #include "chrome/browser/net/prediction_options.h" |
| 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 36 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
| 37 #include "chrome/browser/sync/profile_sync_service_factory.h" | 38 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 38 #include "chrome/browser/translate/chrome_translate_client.h" | 39 #include "chrome/browser/translate/chrome_translate_client.h" |
| 39 #include "chrome/browser/ui/android/android_about_app_info.h" | 40 #include "chrome/browser/ui/android/android_about_app_info.h" |
| 41 #include "chrome/common/chrome_features.h" |
| 40 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 41 #include "chrome/grit/locale_settings.h" | 43 #include "chrome/grit/locale_settings.h" |
| 42 #include "components/browsing_data_ui/history_notice_utils.h" | 44 #include "components/browsing_data_ui/history_notice_utils.h" |
| 43 #include "components/content_settings/core/browser/host_content_settings_map.h" | 45 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 44 #include "components/content_settings/core/common/content_settings.h" | 46 #include "components/content_settings/core/common/content_settings.h" |
| 45 #include "components/content_settings/core/common/content_settings_pattern.h" | 47 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 46 #include "components/content_settings/core/common/pref_names.h" | 48 #include "components/content_settings/core/common/pref_names.h" |
| 47 #include "components/metrics/metrics_pref_names.h" | 49 #include "components/metrics/metrics_pref_names.h" |
| 48 #include "components/password_manager/core/common/password_manager_pref_names.h" | 50 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 49 #include "components/prefs/pref_service.h" | 51 #include "components/prefs/pref_service.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 prefs::kIncognitoModeAvailability); | 442 prefs::kIncognitoModeAvailability); |
| 441 } | 443 } |
| 442 | 444 |
| 443 static jboolean GetFullscreenManaged(JNIEnv* env, | 445 static jboolean GetFullscreenManaged(JNIEnv* env, |
| 444 const JavaParamRef<jobject>& obj) { | 446 const JavaParamRef<jobject>& obj) { |
| 445 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); | 447 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 446 } | 448 } |
| 447 | 449 |
| 448 static jboolean GetFullscreenAllowed(JNIEnv* env, | 450 static jboolean GetFullscreenAllowed(JNIEnv* env, |
| 449 const JavaParamRef<jobject>& obj) { | 451 const JavaParamRef<jobject>& obj) { |
| 452 // In the simplified fullscreen case, fullscreen is always allowed. |
| 453 // TODO(mgiuca): Remove this pref once all data associated with it is deleted |
| 454 // (https://crbug.com/591896). |
| 455 if (base::FeatureList::IsEnabled(features::kSimplifiedFullscreenUI)) |
| 456 return true; |
| 457 |
| 450 HostContentSettingsMap* content_settings = | 458 HostContentSettingsMap* content_settings = |
| 451 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); | 459 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 452 return content_settings->GetDefaultContentSetting( | 460 return content_settings->GetDefaultContentSetting( |
| 453 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; | 461 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; |
| 454 } | 462 } |
| 455 | 463 |
| 456 static jboolean GetMetricsReportingEnabled(JNIEnv* env, | 464 static jboolean GetMetricsReportingEnabled(JNIEnv* env, |
| 457 const JavaParamRef<jobject>& obj) { | 465 const JavaParamRef<jobject>& obj) { |
| 458 PrefService* local_state = g_browser_process->local_state(); | 466 PrefService* local_state = g_browser_process->local_state(); |
| 459 return local_state->GetBoolean(metrics::prefs::kMetricsReportingEnabled); | 467 return local_state->GetBoolean(metrics::prefs::kMetricsReportingEnabled); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 | 1140 |
| 1133 return ConvertJavaStringToUTF8(android_permission); | 1141 return ConvertJavaStringToUTF8(android_permission); |
| 1134 } | 1142 } |
| 1135 | 1143 |
| 1136 static void SetSupervisedUserId(JNIEnv* env, | 1144 static void SetSupervisedUserId(JNIEnv* env, |
| 1137 const JavaParamRef<jobject>& obj, | 1145 const JavaParamRef<jobject>& obj, |
| 1138 const JavaParamRef<jstring>& pref) { | 1146 const JavaParamRef<jstring>& pref) { |
| 1139 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1147 GetPrefService()->SetString(prefs::kSupervisedUserId, |
| 1140 ConvertJavaStringToUTF8(env, pref)); | 1148 ConvertJavaStringToUTF8(env, pref)); |
| 1141 } | 1149 } |
| OLD | NEW |