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/feature_list.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
21 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
22 #include "base/scoped_observer.h" | 22 #include "base/scoped_observer.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/values.h" | 24 #include "base/values.h" |
25 #include "chrome/browser/android/preferences/important_sites_util.h" | 25 #include "chrome/browser/android/preferences/important_sites_util.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | |
28 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 27 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
29 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 28 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
30 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 29 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
31 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
32 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 31 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
33 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 32 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
34 #include "chrome/browser/history/web_history_service_factory.h" | 33 #include "chrome/browser/history/web_history_service_factory.h" |
35 #include "chrome/browser/net/prediction_options.h" | 34 #include "chrome/browser/net/prediction_options.h" |
36 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 const JavaParamRef<jobject>& obj, | 548 const JavaParamRef<jobject>& obj, |
550 jint data_type) { | 549 jint data_type) { |
551 DCHECK_GE(data_type, 0); | 550 DCHECK_GE(data_type, 0); |
552 DCHECK_LT(data_type, browsing_data::NUM_TYPES); | 551 DCHECK_LT(data_type, browsing_data::NUM_TYPES); |
553 | 552 |
554 // If there is no corresponding preference for this |data_type|, pretend | 553 // If there is no corresponding preference for this |data_type|, pretend |
555 // that it's set to false. | 554 // that it's set to false. |
556 // TODO(msramek): Consider defining native-side preferences for all Java UI | 555 // TODO(msramek): Consider defining native-side preferences for all Java UI |
557 // data types for consistency. | 556 // data types for consistency. |
558 std::string pref; | 557 std::string pref; |
559 if (!GetDeletionPreferenceFromDataType( | 558 if (!browsing_data::GetDeletionPreferenceFromDataType( |
560 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { | 559 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { |
561 return false; | 560 return false; |
562 } | 561 } |
563 | 562 |
564 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref); | 563 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref); |
565 } | 564 } |
566 | 565 |
567 static void SetBrowsingDataDeletionPreference( | 566 static void SetBrowsingDataDeletionPreference( |
568 JNIEnv* env, | 567 JNIEnv* env, |
569 const JavaParamRef<jobject>& obj, | 568 const JavaParamRef<jobject>& obj, |
570 jint data_type, | 569 jint data_type, |
571 jboolean value) { | 570 jboolean value) { |
572 DCHECK_GE(data_type, 0); | 571 DCHECK_GE(data_type, 0); |
573 DCHECK_LT(data_type, browsing_data::NUM_TYPES); | 572 DCHECK_LT(data_type, browsing_data::NUM_TYPES); |
574 | 573 |
575 std::string pref; | 574 std::string pref; |
576 if (!GetDeletionPreferenceFromDataType( | 575 if (!browsing_data::GetDeletionPreferenceFromDataType( |
577 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { | 576 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { |
578 return; | 577 return; |
579 } | 578 } |
580 | 579 |
581 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value); | 580 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value); |
582 } | 581 } |
583 | 582 |
584 static jint GetBrowsingDataDeletionTimePeriod( | 583 static jint GetBrowsingDataDeletionTimePeriod( |
585 JNIEnv* env, | 584 JNIEnv* env, |
586 const JavaParamRef<jobject>& obj) { | 585 const JavaParamRef<jobject>& obj) { |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1166 |
1168 return ConvertJavaStringToUTF8(android_permission); | 1167 return ConvertJavaStringToUTF8(android_permission); |
1169 } | 1168 } |
1170 | 1169 |
1171 static void SetSupervisedUserId(JNIEnv* env, | 1170 static void SetSupervisedUserId(JNIEnv* env, |
1172 const JavaParamRef<jobject>& obj, | 1171 const JavaParamRef<jobject>& obj, |
1173 const JavaParamRef<jstring>& pref) { | 1172 const JavaParamRef<jstring>& pref) { |
1174 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1173 GetPrefService()->SetString(prefs::kSupervisedUserId, |
1175 ConvertJavaStringToUTF8(env, pref)); | 1174 ConvertJavaStringToUTF8(env, pref)); |
1176 } | 1175 } |
OLD | NEW |