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 | 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/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
| 20 #include "base/scoped_observer.h" | 20 #include "base/scoped_observer.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 24 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 25 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 25 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 26 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 26 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 29 #include "chrome/browser/history/web_history_service_factory.h" | |
| 29 #include "chrome/browser/net/prediction_options.h" | 30 #include "chrome/browser/net/prediction_options.h" |
| 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 31 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
| 33 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 32 #include "chrome/browser/translate/chrome_translate_client.h" | 34 #include "chrome/browser/translate/chrome_translate_client.h" |
| 33 #include "chrome/browser/ui/android/android_about_app_info.h" | 35 #include "chrome/browser/ui/android/android_about_app_info.h" |
| 34 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/grit/locale_settings.h" | 37 #include "chrome/grit/locale_settings.h" |
| 38 #include "components/browsing_data_ui/history_notice_utils.h" | |
| 36 #include "components/content_settings/core/browser/host_content_settings_map.h" | 39 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 37 #include "components/content_settings/core/common/content_settings.h" | 40 #include "components/content_settings/core/common/content_settings.h" |
| 38 #include "components/content_settings/core/common/content_settings_pattern.h" | 41 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 39 #include "components/content_settings/core/common/pref_names.h" | 42 #include "components/content_settings/core/common/pref_names.h" |
| 40 #include "components/metrics/metrics_pref_names.h" | 43 #include "components/metrics/metrics_pref_names.h" |
| 41 #include "components/password_manager/core/common/password_manager_pref_names.h" | 44 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 42 #include "components/prefs/pref_service.h" | 45 #include "components/prefs/pref_service.h" |
| 43 #include "components/signin/core/common/signin_pref_names.h" | 46 #include "components/signin/core/common/signin_pref_names.h" |
| 44 #include "components/strings/grit/components_locale_settings.h" | 47 #include "components/strings/grit/components_locale_settings.h" |
| 45 #include "components/translate/core/browser/translate_prefs.h" | 48 #include "components/translate/core/browser/translate_prefs.h" |
| (...skipping 554 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( | |
| 614 ScopedJavaGlobalRef<jobject>* listener, | |
| 615 bool show) { | |
| 616 JNIEnv* env = AttachCurrentThread(); | |
| 617 if (!show) | |
| 618 return; | |
| 619 Java_OtherFormsOfBrowsingHistoryListener_showNoticeAboutOtherFormsOfBrowsingHi story( | |
| 620 env, listener->obj()); | |
| 621 } | |
| 622 | |
| 623 static void EnableDialogAboutOtherFormsOfBrowsingHistory( | |
| 624 ScopedJavaGlobalRef<jobject>* listener, | |
| 625 bool enabled) { | |
| 626 JNIEnv* env = AttachCurrentThread(); | |
| 627 if (!enabled) | |
| 628 return; | |
| 629 Java_OtherFormsOfBrowsingHistoryListener_enableDialogAboutOtherFormsOfBrowsing History( | |
|
gone
2016/04/08 17:44:58
<random comment about how hilariously long JNI cal
msramek
2016/04/08 18:31:30
Yes, I have first searched for "file:.cc Java_.{74
| |
| 630 env, listener->obj()); | |
| 631 } | |
| 632 | |
| 633 static void RequestInfoAboutOtherFormsOfBrowsingHistory( | |
| 634 JNIEnv* env, | |
| 635 const JavaParamRef<jobject>& obj, | |
| 636 const JavaParamRef<jobject>& listener) { | |
| 637 // The permanent notice in the footer. | |
| 638 browsing_data_ui::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | |
| 639 ProfileSyncServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 640 WebHistoryServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 641 base::Bind(&ShowNoticeAboutOtherFormsOfBrowsingHistory, | |
| 642 base::Owned(new ScopedJavaGlobalRef<jobject>(env, listener)))); | |
| 643 | |
| 644 // The one-time notice in the dialog. | |
| 645 browsing_data_ui::ShouldPopupDialogAboutOtherFormsOfBrowsingHistory( | |
| 646 ProfileSyncServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 647 WebHistoryServiceFactory::GetForProfile(GetOriginalProfile()), | |
| 648 base::Bind(&EnableDialogAboutOtherFormsOfBrowsingHistory, | |
| 649 base::Owned(new ScopedJavaGlobalRef<jobject>(env, listener)))); | |
| 650 } | |
| 651 | |
| 610 static void SetAllowCookiesEnabled(JNIEnv* env, | 652 static void SetAllowCookiesEnabled(JNIEnv* env, |
| 611 const JavaParamRef<jobject>& obj, | 653 const JavaParamRef<jobject>& obj, |
| 612 jboolean allow) { | 654 jboolean allow) { |
| 613 HostContentSettingsMap* host_content_settings_map = | 655 HostContentSettingsMap* host_content_settings_map = |
| 614 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); | 656 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 615 host_content_settings_map->SetDefaultContentSetting( | 657 host_content_settings_map->SetDefaultContentSetting( |
| 616 CONTENT_SETTINGS_TYPE_COOKIES, | 658 CONTENT_SETTINGS_TYPE_COOKIES, |
| 617 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 659 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 618 } | 660 } |
| 619 | 661 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 | 1065 |
| 1024 return ConvertJavaStringToUTF8(android_permission); | 1066 return ConvertJavaStringToUTF8(android_permission); |
| 1025 } | 1067 } |
| 1026 | 1068 |
| 1027 static void SetSupervisedUserId(JNIEnv* env, | 1069 static void SetSupervisedUserId(JNIEnv* env, |
| 1028 const JavaParamRef<jobject>& obj, | 1070 const JavaParamRef<jobject>& obj, |
| 1029 const JavaParamRef<jstring>& pref) { | 1071 const JavaParamRef<jstring>& pref) { |
| 1030 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1072 GetPrefService()->SetString(prefs::kSupervisedUserId, |
| 1031 ConvertJavaStringToUTF8(env, pref)); | 1073 ConvertJavaStringToUTF8(env, pref)); |
| 1032 } | 1074 } |
| OLD | NEW |