Chromium Code Reviews| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_array.h" | 13 #include "base/android/jni_array.h" |
| 14 #include "base/android/jni_string.h" | 14 #include "base/android/jni_string.h" |
| 15 #include "base/android/jni_weak_ref.h" | 15 #include "base/android/jni_weak_ref.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/scoped_observer.h" | 19 #include "base/scoped_observer.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 23 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 24 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 25 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 25 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 26 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 26 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 27 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 27 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 28 #include "chrome/browser/history/web_history_service_factory.h" | |
| 28 #include "chrome/browser/net/prediction_options.h" | 29 #include "chrome/browser/net/prediction_options.h" |
| 29 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 31 #include "chrome/browser/translate/chrome_translate_client.h" | 33 #include "chrome/browser/translate/chrome_translate_client.h" |
| 32 #include "chrome/browser/ui/android/android_about_app_info.h" | 34 #include "chrome/browser/ui/android/android_about_app_info.h" |
| 33 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 34 #include "chrome/grit/locale_settings.h" | 36 #include "chrome/grit/locale_settings.h" |
| 37 #include "components/browsing_data_ui/history_notice_utils.h" | |
| 35 #include "components/content_settings/core/browser/host_content_settings_map.h" | 38 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 36 #include "components/content_settings/core/common/content_settings.h" | 39 #include "components/content_settings/core/common/content_settings.h" |
| 37 #include "components/content_settings/core/common/content_settings_pattern.h" | 40 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 38 #include "components/content_settings/core/common/pref_names.h" | 41 #include "components/content_settings/core/common/pref_names.h" |
| 39 #include "components/metrics/metrics_pref_names.h" | 42 #include "components/metrics/metrics_pref_names.h" |
| 40 #include "components/password_manager/core/common/password_manager_pref_names.h" | 43 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 41 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
| 42 #include "components/signin/core/common/signin_pref_names.h" | 45 #include "components/signin/core/common/signin_pref_names.h" |
| 43 #include "components/strings/grit/components_locale_settings.h" | 46 #include "components/strings/grit/components_locale_settings.h" |
| 44 #include "components/translate/core/browser/translate_prefs.h" | 47 #include "components/translate/core/browser/translate_prefs.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 BrowsingDataRemover::Period( | 603 BrowsingDataRemover::Period( |
| 601 static_cast<BrowsingDataRemover::TimePeriod>(time_period)), | 604 static_cast<BrowsingDataRemover::TimePeriod>(time_period)), |
| 602 remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); | 605 remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); |
| 603 } | 606 } |
| 604 | 607 |
| 605 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, | 608 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, |
| 606 const JavaParamRef<jobject>& obj) { | 609 const JavaParamRef<jobject>& obj) { |
| 607 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 610 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
| 608 } | 611 } |
| 609 | 612 |
| 613 static void showNoticeAboutOtherFormsOfBrowsingHistory( | |
|
gone
2016/04/07 22:27:55
nit: You're in C++ land:
ShowNoticeAboutOtherForm
msramek
2016/04/08 16:03:18
Done.
| |
| 614 JavaObjectWeakGlobalRef* weak_chrome_native_preferences, | |
| 615 bool show) { | |
| 616 JNIEnv* env = AttachCurrentThread(); | |
| 617 if (weak_chrome_native_preferences->get(env).is_null()) | |
| 618 return; | |
| 619 | |
| 620 Java_PrefServiceBridge_showNoticeAboutOtherFormsOfBrowsingHistory( | |
| 621 env, weak_chrome_native_preferences->get(env).obj(), show); | |
| 622 } | |
| 623 | |
| 624 static void enableDialogAboutOtherFormsOfBrowsingHistory( | |
| 625 JavaObjectWeakGlobalRef* weak_chrome_native_preferences, | |
| 626 bool enabled) { | |
| 627 JNIEnv* env = AttachCurrentThread(); | |
| 628 if (weak_chrome_native_preferences->get(env).is_null()) | |
| 629 return; | |
| 630 | |
| 631 Java_PrefServiceBridge_enableDialogAboutOtherFormsOfBrowsingHistory( | |
| 632 env, weak_chrome_native_preferences->get(env).obj(), enabled); | |
| 633 } | |
| 634 | |
| 635 static void RequestInfoAboutOtherFormsOfBrowsingHistory( | |
| 636 JNIEnv* env, | |
| 637 const JavaParamRef<jobject>& obj) { | |
| 638 // The permanent notice in the footer. | |
| 639 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | |
| 640 ProfileSyncServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 641 WebHistoryServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 642 base::Bind(&showNoticeAboutOtherFormsOfBrowsingHistory, | |
| 643 base::Owned(new JavaObjectWeakGlobalRef(env, obj)))); | |
| 644 | |
| 645 // The one-time notice in the dialog. | |
| 646 browsing_data_ui::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory( | |
| 647 ProfileSyncServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 648 WebHistoryServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 649 base::Bind(&enableDialogAboutOtherFormsOfBrowsingHistory, | |
| 650 base::Owned(new JavaObjectWeakGlobalRef(env, obj)))); | |
| 651 } | |
| 652 | |
| 610 static void SetAllowCookiesEnabled(JNIEnv* env, | 653 static void SetAllowCookiesEnabled(JNIEnv* env, |
| 611 const JavaParamRef<jobject>& obj, | 654 const JavaParamRef<jobject>& obj, |
| 612 jboolean allow) { | 655 jboolean allow) { |
| 613 HostContentSettingsMap* host_content_settings_map = | 656 HostContentSettingsMap* host_content_settings_map = |
| 614 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); | 657 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 615 host_content_settings_map->SetDefaultContentSetting( | 658 host_content_settings_map->SetDefaultContentSetting( |
| 616 CONTENT_SETTINGS_TYPE_COOKIES, | 659 CONTENT_SETTINGS_TYPE_COOKIES, |
| 617 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 660 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 618 } | 661 } |
| 619 | 662 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 | 1066 |
| 1024 return ConvertJavaStringToUTF8(android_permission); | 1067 return ConvertJavaStringToUTF8(android_permission); |
| 1025 } | 1068 } |
| 1026 | 1069 |
| 1027 static void SetSupervisedUserId(JNIEnv* env, | 1070 static void SetSupervisedUserId(JNIEnv* env, |
| 1028 const JavaParamRef<jobject>& obj, | 1071 const JavaParamRef<jobject>& obj, |
| 1029 const JavaParamRef<jstring>& pref) { | 1072 const JavaParamRef<jstring>& pref) { |
| 1030 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1073 GetPrefService()->SetString(prefs::kSupervisedUserId, |
| 1031 ConvertJavaStringToUTF8(env, pref)); | 1074 ConvertJavaStringToUTF8(env, pref)); |
| 1032 } | 1075 } |
| OLD | NEW |