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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 const JavaParamRef<jobject>& obj, | 555 const JavaParamRef<jobject>& obj, |
557 jint data_type) { | 556 jint data_type) { |
558 DCHECK_GE(data_type, 0); | 557 DCHECK_GE(data_type, 0); |
559 DCHECK_LT(data_type, browsing_data::NUM_TYPES); | 558 DCHECK_LT(data_type, browsing_data::NUM_TYPES); |
560 | 559 |
561 // If there is no corresponding preference for this |data_type|, pretend | 560 // If there is no corresponding preference for this |data_type|, pretend |
562 // that it's set to false. | 561 // that it's set to false. |
563 // TODO(msramek): Consider defining native-side preferences for all Java UI | 562 // TODO(msramek): Consider defining native-side preferences for all Java UI |
564 // data types for consistency. | 563 // data types for consistency. |
565 std::string pref; | 564 std::string pref; |
566 if (!GetDeletionPreferenceFromDataType( | 565 if (!browsing_data::GetDeletionPreferenceFromDataType( |
567 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { | 566 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { |
568 return false; | 567 return false; |
569 } | 568 } |
570 | 569 |
571 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref); | 570 return GetOriginalProfile()->GetPrefs()->GetBoolean(pref); |
572 } | 571 } |
573 | 572 |
574 static void SetBrowsingDataDeletionPreference( | 573 static void SetBrowsingDataDeletionPreference( |
575 JNIEnv* env, | 574 JNIEnv* env, |
576 const JavaParamRef<jobject>& obj, | 575 const JavaParamRef<jobject>& obj, |
577 jint data_type, | 576 jint data_type, |
578 jboolean value) { | 577 jboolean value) { |
579 DCHECK_GE(data_type, 0); | 578 DCHECK_GE(data_type, 0); |
580 DCHECK_LT(data_type, browsing_data::NUM_TYPES); | 579 DCHECK_LT(data_type, browsing_data::NUM_TYPES); |
581 | 580 |
582 std::string pref; | 581 std::string pref; |
583 if (!GetDeletionPreferenceFromDataType( | 582 if (!browsing_data::GetDeletionPreferenceFromDataType( |
584 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { | 583 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { |
585 return; | 584 return; |
586 } | 585 } |
587 | 586 |
588 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value); | 587 GetOriginalProfile()->GetPrefs()->SetBoolean(pref, value); |
589 } | 588 } |
590 | 589 |
591 static jint GetBrowsingDataDeletionTimePeriod( | 590 static jint GetBrowsingDataDeletionTimePeriod( |
592 JNIEnv* env, | 591 JNIEnv* env, |
593 const JavaParamRef<jobject>& obj) { | 592 const JavaParamRef<jobject>& obj) { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1195 |
1197 return ConvertJavaStringToUTF8(android_permission); | 1196 return ConvertJavaStringToUTF8(android_permission); |
1198 } | 1197 } |
1199 | 1198 |
1200 static void SetSupervisedUserId(JNIEnv* env, | 1199 static void SetSupervisedUserId(JNIEnv* env, |
1201 const JavaParamRef<jobject>& obj, | 1200 const JavaParamRef<jobject>& obj, |
1202 const JavaParamRef<jstring>& pref) { | 1201 const JavaParamRef<jstring>& pref) { |
1203 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1202 GetPrefService()->SetString(prefs::kSupervisedUserId, |
1204 ConvertJavaStringToUTF8(env, pref)); | 1203 ConvertJavaStringToUTF8(env, pref)); |
1205 } | 1204 } |
OLD | NEW |