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 package org.chromium.chrome.browser.preferences; | 5 package org.chromium.chrome.browser.preferences; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 android.Manifest.permission.ACCESS_FINE_LOCATION, | 43 android.Manifest.permission.ACCESS_FINE_LOCATION, |
44 android.Manifest.permission.ACCESS_COARSE_LOCATION}; | 44 android.Manifest.permission.ACCESS_COARSE_LOCATION}; |
45 /** The android permissions associated with requesting access to the camera.
*/ | 45 /** The android permissions associated with requesting access to the camera.
*/ |
46 private static final String[] CAMERA_PERMISSIONS = {android.Manifest.permiss
ion.CAMERA}; | 46 private static final String[] CAMERA_PERMISSIONS = {android.Manifest.permiss
ion.CAMERA}; |
47 /** The android permissions associated with requesting access to the microph
one. */ | 47 /** The android permissions associated with requesting access to the microph
one. */ |
48 private static final String[] MICROPHONE_PERMISSIONS = { | 48 private static final String[] MICROPHONE_PERMISSIONS = { |
49 android.Manifest.permission.RECORD_AUDIO}; | 49 android.Manifest.permission.RECORD_AUDIO}; |
50 /** Signifies there are no permissions associated. */ | 50 /** Signifies there are no permissions associated. */ |
51 private static final String[] EMPTY_PERMISSIONS = {}; | 51 private static final String[] EMPTY_PERMISSIONS = {}; |
52 | 52 |
53 // Object to notify when "clear browsing data" completes. | |
54 private OnClearBrowsingDataListener mClearBrowsingDataListener; | |
55 private static final String LOG_TAG = "PrefServiceBridge"; | 53 private static final String LOG_TAG = "PrefServiceBridge"; |
56 | 54 |
57 // Constants related to the Contextual Search preference. | 55 // Constants related to the Contextual Search preference. |
58 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; | 56 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; |
59 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; | 57 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; |
60 | 58 |
61 // The key to store whether the Location Permission was automatically added
for the search | 59 // The key to store whether the Location Permission was automatically added
for the search |
62 // engine set as default. | 60 // engine set as default. |
63 public static final String LOCATION_AUTO_ALLOWED = "search_engine_location_a
uto_allowed"; | 61 public static final String LOCATION_AUTO_ALLOWED = "search_engine_location_a
uto_allowed"; |
64 | 62 |
(...skipping 11 matching lines...) Expand all Loading... |
76 | 74 |
77 public String getApplicationVersion() { | 75 public String getApplicationVersion() { |
78 return mApplicationVersion; | 76 return mApplicationVersion; |
79 } | 77 } |
80 | 78 |
81 public String getOSVersion() { | 79 public String getOSVersion() { |
82 return mOSVersion; | 80 return mOSVersion; |
83 } | 81 } |
84 } | 82 } |
85 | 83 |
86 /** | |
87 * Interface for a class that is listening to clear browser data events. | |
88 */ | |
89 public interface OnClearBrowsingDataListener { | |
90 public abstract void onBrowsingDataCleared(); | |
91 } | |
92 | |
93 /** | |
94 * Interface for a class that is fetching important site information. | |
95 */ | |
96 public interface ImportantSitesCallback { | |
97 /** | |
98 * Called when the list of important registerable domains has been fetch
ed from cpp. | |
99 * See net/base/registry_controlled_domains/registry_controlled_domain.h
for more details on | |
100 * registrable domains and the current list of effective eTLDs. | |
101 * @param domains Important registerable domains. | |
102 * @param exampleOrigins Example origins for each domain. These can be u
sed to retrieve | |
103 * favicons. | |
104 * @param importantReasons Bitfield of reasons why this domain was selec
ted. Pass this back | |
105 * to clearBrowinsgData so we can record metrics
. | |
106 * @param dialogDisabled If the important dialog has been ignored too ma
ny times and should | |
107 * not be shown. | |
108 */ | |
109 @CalledByNative("ImportantSitesCallback") | |
110 void onImportantRegisterableDomainsReady(String[] domains, String[] exam
pleOrigins, | |
111 int[] importantReasons, boolean dialogDisabled); | |
112 } | |
113 | |
114 /** | |
115 * Interface to a class that receives callbacks instructing it to inform the
user about other | |
116 * forms of browsing history. | |
117 */ | |
118 public interface OtherFormsOfBrowsingHistoryListener { | |
119 /** | |
120 * Called by the web history service when it discovers that other forms
of browsing history | |
121 * exist. | |
122 */ | |
123 @CalledByNative("OtherFormsOfBrowsingHistoryListener") | |
124 public abstract void enableDialogAboutOtherFormsOfBrowsingHistory(); | |
125 | |
126 /** | |
127 * Called by the web history service when the conditions for showing the
dialog about | |
128 * other forms of browsing history are met. | |
129 */ | |
130 @CalledByNative("OtherFormsOfBrowsingHistoryListener") | |
131 public abstract void showNoticeAboutOtherFormsOfBrowsingHistory(); | |
132 } | |
133 | |
134 @CalledByNative | 84 @CalledByNative |
135 private static AboutVersionStrings createAboutVersionStrings(String applicat
ionVersion, | 85 private static AboutVersionStrings createAboutVersionStrings(String applicat
ionVersion, |
136 String osVersion) { | 86 String osVersion) { |
137 return new AboutVersionStrings(applicationVersion, osVersion); | 87 return new AboutVersionStrings(applicationVersion, osVersion); |
138 } | 88 } |
139 | 89 |
140 private PrefServiceBridge() { | 90 private PrefServiceBridge() { |
141 TemplateUrlService.getInstance().load(); | 91 TemplateUrlService.getInstance().load(); |
142 } | 92 } |
143 | 93 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 * Sets the time period for which browsing data will be deleted. | 657 * Sets the time period for which browsing data will be deleted. |
708 * @param clearBrowsingDataTab Indicates if this is a timeperiod on the defa
ult, basic or | 658 * @param clearBrowsingDataTab Indicates if this is a timeperiod on the defa
ult, basic or |
709 * advanced tab to apply the right preference. | 659 * advanced tab to apply the right preference. |
710 * @param timePeriod The selected browsing data deletion time period (from t
he shared enum | 660 * @param timePeriod The selected browsing data deletion time period (from t
he shared enum |
711 * {@link org.chromium.chrome.browser.browsing_data.TimePeriod}). | 661 * {@link org.chromium.chrome.browser.browsing_data.TimePeriod}). |
712 */ | 662 */ |
713 public void setBrowsingDataDeletionTimePeriod(int clearBrowsingDataTab, int
timePeriod) { | 663 public void setBrowsingDataDeletionTimePeriod(int clearBrowsingDataTab, int
timePeriod) { |
714 nativeSetBrowsingDataDeletionTimePeriod(clearBrowsingDataTab, timePeriod
); | 664 nativeSetBrowsingDataDeletionTimePeriod(clearBrowsingDataTab, timePeriod
); |
715 } | 665 } |
716 | 666 |
717 /** | |
718 * Clear the specified types of browsing data asynchronously. | |
719 * |listener| is an object to be notified when clearing completes. | |
720 * It can be null, but many operations (e.g. navigation) are | |
721 * ill-advised while browsing data is being cleared. | |
722 * @param listener A listener to call back when the clearing is finished. | |
723 * @param dataTypes An array of browsing data types to delete, represented a
s values from | |
724 * the shared enum {@link org.chromium.chrome.browser.browsing_data.Bro
wsingDataType}. | |
725 * @param timePeriod The time period for which to delete the data, represent
ed as a value from | |
726 * the shared enum {@link org.chromium.chrome.browser.browsing_data.Tim
ePeriod}. | |
727 */ | |
728 public void clearBrowsingData( | |
729 OnClearBrowsingDataListener listener, int[] dataTypes, int timePerio
d) { | |
730 clearBrowsingDataExcludingDomains(listener, dataTypes, timePeriod, new S
tring[0], | |
731 new int[0], new String[0], new int[0]); | |
732 } | |
733 | 667 |
734 /** | |
735 * Same as above, but now we can specify a list of domains to exclude from c
learing browsing | |
736 * data. | |
737 * Do not use this method unless caller knows what they're doing. Not all ba
ckends are supported | |
738 * yet, and more data than expected could be deleted. See crbug.com/113621. | |
739 * @param listener A listener to call back when the clearing is finished. | |
740 * @param dataTypes An array of browsing data types to delete, represented a
s values from | |
741 * the shared enum {@link org.chromium.chrome.browser.browsing_data.Bro
wsingDataType}. | |
742 * @param timePeriod The time period for which to delete the data, represent
ed as a value from | |
743 * the shared enum {@link org.chromium.chrome.browser.browsing_data.Tim
ePeriod}. | |
744 * @param blacklistDomains A list of registerable domains that we don't clea
r data for. | |
745 * @param blacklistedDomainReasons A list of the reason metadata for the bla
cklisted domains. | |
746 * @param ignoredDomains A list of ignored domains that the user chose to no
t blacklist. We use | |
747 * these to remove important site entries if the user
ignores them enough. | |
748 * @param ignoredDomainReasons A list of reason metadata for the ignored dom
ains. | |
749 */ | |
750 public void clearBrowsingDataExcludingDomains(OnClearBrowsingDataListener li
stener, | |
751 int[] dataTypes, int timePeriod, String[] blacklistDomains, | |
752 int[] blacklistedDomainReasons, String[] ignoredDomains, int[] ignor
edDomainReasons) { | |
753 assert mClearBrowsingDataListener == null; | |
754 mClearBrowsingDataListener = listener; | |
755 nativeClearBrowsingData(dataTypes, timePeriod, blacklistDomains, blackli
stedDomainReasons, | |
756 ignoredDomains, ignoredDomainReasons); | |
757 } | |
758 | 668 |
759 /** | 669 /** |
760 * @return The index of the tab last visited by the user in the CBD dialog. | 670 * @return The index of the tab last visited by the user in the CBD dialog. |
761 * Index 0 is for the basic tab, 1 is the advanced tab. | 671 * Index 0 is for the basic tab, 1 is the advanced tab. |
762 */ | 672 */ |
763 public int getLastSelectedClearBrowsingDataTab() { | 673 public int getLastSelectedClearBrowsingDataTab() { |
764 return nativeGetLastClearBrowsingDataTab(); | 674 return nativeGetLastClearBrowsingDataTab(); |
765 } | 675 } |
766 | 676 |
767 /** | 677 /** |
(...skipping 12 matching lines...) Expand all Loading... |
780 nativeMigrateBrowsingDataPreferences(); | 690 nativeMigrateBrowsingDataPreferences(); |
781 } | 691 } |
782 | 692 |
783 /** | 693 /** |
784 * @return Whether browser history can be deleted by the user. | 694 * @return Whether browser history can be deleted by the user. |
785 */ | 695 */ |
786 public boolean canDeleteBrowsingHistory() { | 696 public boolean canDeleteBrowsingHistory() { |
787 return nativeCanDeleteBrowsingHistory(); | 697 return nativeCanDeleteBrowsingHistory(); |
788 } | 698 } |
789 | 699 |
790 @CalledByNative | |
791 private void browsingDataCleared() { | |
792 if (mClearBrowsingDataListener != null) { | |
793 mClearBrowsingDataListener.onBrowsingDataCleared(); | |
794 mClearBrowsingDataListener = null; | |
795 } | |
796 } | |
797 | |
798 /** | |
799 * This fetches sites (registerable domains) that we consider important. Thi
s combines many | |
800 * pieces of information, including site engagement and permissions. The cal
lback is called | |
801 * with the list of important registerable domains. | |
802 * | |
803 * See net/base/registry_controlled_domains/registry_controlled_domain.h for
more details on | |
804 * registrable domains and the current list of effective eTLDs. | |
805 * @param callback The callback that will be used to set the list of importa
nt sites. | |
806 */ | |
807 public static void fetchImportantSites(ImportantSitesCallback callback) { | |
808 nativeFetchImportantSites(callback); | |
809 } | |
810 | |
811 /** | |
812 * @return The maximum number of important sites that will be returned from
the call above. | |
813 * This is a constant that won't change. | |
814 */ | |
815 public static int getMaxImportantSites() { | |
816 return nativeGetMaxImportantSites(); | |
817 } | |
818 | |
819 /** This lets us mark an origin as important for testing. */ | |
820 @VisibleForTesting | |
821 public static void markOriginAsImportantForTesting(String origin) { | |
822 nativeMarkOriginAsImportantForTesting(origin); | |
823 } | |
824 | |
825 /** | |
826 * Requests that the web history service finds out if we should inform the u
ser about the | |
827 * existence of other forms of browsing history. The response will be asynch
ronous, through | |
828 * {@link OtherFormsOfBrowsingHistoryListener}. | |
829 */ | |
830 public void requestInfoAboutOtherFormsOfBrowsingHistory( | |
831 OtherFormsOfBrowsingHistoryListener listener) { | |
832 nativeRequestInfoAboutOtherFormsOfBrowsingHistory(listener); | |
833 } | |
834 | |
835 public void setAllowCookiesEnabled(boolean allow) { | 700 public void setAllowCookiesEnabled(boolean allow) { |
836 nativeSetAllowCookiesEnabled(allow); | 701 nativeSetAllowCookiesEnabled(allow); |
837 } | 702 } |
838 | 703 |
839 public void setAutoplayEnabled(boolean allow) { | 704 public void setAutoplayEnabled(boolean allow) { |
840 nativeSetAutoplayEnabled(allow); | 705 nativeSetAutoplayEnabled(allow); |
841 } | 706 } |
842 | 707 |
843 public void setBlockThirdPartyCookiesEnabled(boolean enabled) { | 708 public void setBlockThirdPartyCookiesEnabled(boolean enabled) { |
844 nativeSetBlockThirdPartyCookiesEnabled(enabled); | 709 nativeSetBlockThirdPartyCookiesEnabled(enabled); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 private native void nativeSetTranslateEnabled(boolean enabled); | 1003 private native void nativeSetTranslateEnabled(boolean enabled); |
1139 private native void nativeResetTranslateDefaults(); | 1004 private native void nativeResetTranslateDefaults(); |
1140 private native void nativeMigrateJavascriptPreference(); | 1005 private native void nativeMigrateJavascriptPreference(); |
1141 private native boolean nativeGetBrowsingDataDeletionPreference( | 1006 private native boolean nativeGetBrowsingDataDeletionPreference( |
1142 int dataType, int clearBrowsingDataTab); | 1007 int dataType, int clearBrowsingDataTab); |
1143 private native void nativeSetBrowsingDataDeletionPreference( | 1008 private native void nativeSetBrowsingDataDeletionPreference( |
1144 int dataType, int clearBrowsingDataTab, boolean value); | 1009 int dataType, int clearBrowsingDataTab, boolean value); |
1145 private native int nativeGetBrowsingDataDeletionTimePeriod(int clearBrowsing
DataTab); | 1010 private native int nativeGetBrowsingDataDeletionTimePeriod(int clearBrowsing
DataTab); |
1146 private native void nativeSetBrowsingDataDeletionTimePeriod( | 1011 private native void nativeSetBrowsingDataDeletionTimePeriod( |
1147 int clearBrowsingDataTab, int timePeriod); | 1012 int clearBrowsingDataTab, int timePeriod); |
1148 private native void nativeClearBrowsingData(int[] dataTypes, int timePeriod, | |
1149 String[] blacklistDomains, int[] blacklistedDomainReasons, String[]
ignoredDomains, | |
1150 int[] ignoredDomainReasons); | |
1151 private native int nativeGetLastClearBrowsingDataTab(); | 1013 private native int nativeGetLastClearBrowsingDataTab(); |
1152 private native void nativeSetLastClearBrowsingDataTab(int lastTab); | 1014 private native void nativeSetLastClearBrowsingDataTab(int lastTab); |
1153 private native void nativeMigrateBrowsingDataPreferences(); | 1015 private native void nativeMigrateBrowsingDataPreferences(); |
1154 private native void nativeRequestInfoAboutOtherFormsOfBrowsingHistory( | |
1155 OtherFormsOfBrowsingHistoryListener listener); | |
1156 private native boolean nativeCanDeleteBrowsingHistory(); | 1016 private native boolean nativeCanDeleteBrowsingHistory(); |
1157 private static native void nativeFetchImportantSites(ImportantSitesCallback
callback); | |
1158 private static native int nativeGetMaxImportantSites(); | |
1159 private static native void nativeMarkOriginAsImportantForTesting(String orig
in); | |
1160 private native void nativeSetAutoplayEnabled(boolean allow); | 1017 private native void nativeSetAutoplayEnabled(boolean allow); |
1161 private native void nativeSetAllowCookiesEnabled(boolean allow); | 1018 private native void nativeSetAllowCookiesEnabled(boolean allow); |
1162 private native void nativeSetBackgroundSyncEnabled(boolean allow); | 1019 private native void nativeSetBackgroundSyncEnabled(boolean allow); |
1163 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); | 1020 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); |
1164 private native void nativeSetDoNotTrackEnabled(boolean enabled); | 1021 private native void nativeSetDoNotTrackEnabled(boolean enabled); |
1165 private native void nativeSetRememberPasswordsEnabled(boolean allow); | 1022 private native void nativeSetRememberPasswordsEnabled(boolean allow); |
1166 private native void nativeSetPasswordManagerAutoSigninEnabled(boolean enable
d); | 1023 private native void nativeSetPasswordManagerAutoSigninEnabled(boolean enable
d); |
1167 private native void nativeSetProtectedMediaIdentifierEnabled(boolean enabled
); | 1024 private native void nativeSetProtectedMediaIdentifierEnabled(boolean enabled
); |
1168 private native boolean nativeGetAllowLocationEnabled(); | 1025 private native boolean nativeGetAllowLocationEnabled(); |
1169 private native boolean nativeGetNotificationsEnabled(); | 1026 private native boolean nativeGetNotificationsEnabled(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); | 1062 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); |
1206 private native boolean nativeIsMetricsReportingEnabled(); | 1063 private native boolean nativeIsMetricsReportingEnabled(); |
1207 private native void nativeSetMetricsReportingEnabled(boolean enabled); | 1064 private native void nativeSetMetricsReportingEnabled(boolean enabled); |
1208 private native boolean nativeIsMetricsReportingManaged(); | 1065 private native boolean nativeIsMetricsReportingManaged(); |
1209 private native void nativeSetClickedUpdateMenuItem(boolean clicked); | 1066 private native void nativeSetClickedUpdateMenuItem(boolean clicked); |
1210 private native boolean nativeGetClickedUpdateMenuItem(); | 1067 private native boolean nativeGetClickedUpdateMenuItem(); |
1211 private native void nativeSetLatestVersionWhenClickedUpdateMenuItem(String v
ersion); | 1068 private native void nativeSetLatestVersionWhenClickedUpdateMenuItem(String v
ersion); |
1212 private native String nativeGetLatestVersionWhenClickedUpdateMenuItem(); | 1069 private native String nativeGetLatestVersionWhenClickedUpdateMenuItem(); |
1213 private native void nativeSetSupervisedUserId(String supervisedUserId); | 1070 private native void nativeSetSupervisedUserId(String supervisedUserId); |
1214 } | 1071 } |
OLD | NEW |