mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189336 - (Part 3) Move from a list of disallowed things to a list of restrictable features. r=ally
This commit is contained in:
parent
8a0bc1306c
commit
67ae683af3
@ -83,7 +83,7 @@ public class AccountsHelper implements NativeEventListener {
|
||||
|
||||
@Override
|
||||
public void handleMessage(String event, NativeJSObject message, final EventCallback callback) {
|
||||
if (!Restrictions.isAllowed(mContext, Restrictable.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||
if (!Restrictions.isAllowed(mContext, Restrictable.MODIFY_ACCOUNTS)) {
|
||||
// We register for messages in all contexts; we drop, with a log and an error to JavaScript,
|
||||
// when the profile is restricted. It's better to return errors than silently ignore messages.
|
||||
Log.e(LOGTAG, "Profile is not allowed to modify accounts! Ignoring event: " + event);
|
||||
|
@ -1793,7 +1793,7 @@ public class BrowserApp extends GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
if (AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED && Restrictions.isAllowed(this, Restrictable.DISALLOW_LOCATION_SERVICE)) {
|
||||
if (AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED && Restrictions.isAllowed(this, Restrictable.LOCATION_SERVICE)) {
|
||||
// Start (this acts as ping if started already) the stumbler lib; if the stumbler has queued data it will upload it.
|
||||
// Stumbler operates on its own thread, and startup impact is further minimized by delaying work (such as upload) a few seconds.
|
||||
// Avoid any potential startup CPU/thread contention by delaying the pref broadcast.
|
||||
@ -3084,11 +3084,11 @@ public class BrowserApp extends GeckoApp
|
||||
}
|
||||
|
||||
// Disable share menuitem for about:, chrome:, file:, and resource: URIs
|
||||
final boolean shareVisible = Restrictions.isAllowed(this, Restrictable.DISALLOW_SHARE);
|
||||
final boolean shareVisible = Restrictions.isAllowed(this, Restrictable.SHARE);
|
||||
share.setVisible(shareVisible);
|
||||
final boolean shareEnabled = StringUtils.isShareableUrl(url) && shareVisible;
|
||||
share.setEnabled(shareEnabled);
|
||||
MenuUtils.safeSetEnabled(aMenu, R.id.downloads, Restrictions.isAllowed(this, Restrictable.DISALLOW_DOWNLOADS));
|
||||
MenuUtils.safeSetEnabled(aMenu, R.id.downloads, Restrictions.isAllowed(this, Restrictable.DOWNLOAD));
|
||||
|
||||
// NOTE: Use MenuUtils.safeSetEnabled because some actions might
|
||||
// be on the BrowserToolbar context menu.
|
||||
@ -3151,7 +3151,7 @@ public class BrowserApp extends GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
final boolean privateTabVisible = Restrictions.isAllowed(this, Restrictable.DISALLOW_PRIVATE_BROWSING);
|
||||
final boolean privateTabVisible = Restrictions.isAllowed(this, Restrictable.PRIVATE_BROWSING);
|
||||
MenuUtils.safeSetVisible(aMenu, R.id.new_private_tab, privateTabVisible);
|
||||
|
||||
// Disable PDF generation (save and print) for about:home and xul pages.
|
||||
@ -3173,11 +3173,11 @@ public class BrowserApp extends GeckoApp
|
||||
enterGuestMode.setVisible(true);
|
||||
}
|
||||
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_GUEST_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.GUEST_BROWSING)) {
|
||||
MenuUtils.safeSetVisible(aMenu, R.id.new_guest_session, false);
|
||||
}
|
||||
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_INSTALL_EXTENSION)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.INSTALL_EXTENSION)) {
|
||||
MenuUtils.safeSetVisible(aMenu, R.id.addons, false);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class Restrictions {
|
||||
|
||||
final Context context = GeckoAppShell.getApplicationContext();
|
||||
|
||||
if (Restrictable.DISALLOW_BROWSE_FILES == restrictable) {
|
||||
if (Restrictable.BROWSE == restrictable) {
|
||||
return canLoadUrl(context, url);
|
||||
} else {
|
||||
return isAllowed(context, restrictable);
|
||||
|
@ -224,7 +224,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, view, menuInfo);
|
||||
|
||||
if (!Restrictions.isAllowed(getActivity(), Restrictable.DISALLOW_CLEAR_HISTORY)) {
|
||||
if (!Restrictions.isAllowed(getActivity(), Restrictable.CLEAR_HISTORY)) {
|
||||
menu.findItem(R.id.home_remove).setVisible(false);
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
|
||||
private void updateUiFromCursor(Cursor c) {
|
||||
if (c != null && c.getCount() > 0) {
|
||||
if (Restrictions.isAllowed(getActivity(), Restrictable.DISALLOW_CLEAR_HISTORY)) {
|
||||
if (Restrictions.isAllowed(getActivity(), Restrictable.CLEAR_HISTORY)) {
|
||||
mClearHistoryButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return;
|
||||
@ -322,7 +322,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
emptyHint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (!Restrictions.isAllowed(getActivity(), Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(getActivity(), Restrictable.PRIVATE_BROWSING)) {
|
||||
emptyHint.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class HomeConfigPrefsBackend implements HomeConfigBackend {
|
||||
panelConfigs.add(createBuiltinPanelConfig(mContext, PanelType.HISTORY));
|
||||
|
||||
// We disable Synced Tabs for guest mode / restricted profiles.
|
||||
if (Restrictions.isAllowed(mContext, Restrictable.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||
if (Restrictions.isAllowed(mContext, Restrictable.MODIFY_ACCOUNTS)) {
|
||||
panelConfigs.add(createBuiltinPanelConfig(mContext, PanelType.REMOTE_TABS));
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public abstract class HomeFragment extends Fragment {
|
||||
menu.findItem(R.id.home_share).setVisible(false);
|
||||
}
|
||||
|
||||
if (!Restrictions.isAllowed(view.getContext(), Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(view.getContext(), Restrictable.PRIVATE_BROWSING)) {
|
||||
menu.findItem(R.id.home_open_private_tab).setVisible(false);
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ public class TopSitesPanel extends HomeFragment {
|
||||
// can handle this.
|
||||
super.onCreateContextMenu(menu, view, menuInfo);
|
||||
|
||||
if (!Restrictions.isAllowed(view.getContext(), Restrictable.DISALLOW_CLEAR_HISTORY)) {
|
||||
if (!Restrictions.isAllowed(view.getContext(), Restrictable.CLEAR_HISTORY)) {
|
||||
menu.findItem(R.id.home_remove).setVisible(false);
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ public class TopSitesPanel extends HomeFragment {
|
||||
// Hide unused menu items.
|
||||
menu.findItem(R.id.home_edit_bookmark).setVisible(false);
|
||||
|
||||
menu.findItem(R.id.home_remove).setVisible(Restrictions.isAllowed(context, Restrictable.DISALLOW_CLEAR_HISTORY));
|
||||
menu.findItem(R.id.home_remove).setVisible(Restrictions.isAllowed(context, Restrictable.CLEAR_HISTORY));
|
||||
|
||||
TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo;
|
||||
menu.setHeaderTitle(info.getDisplayTitle());
|
||||
@ -381,7 +381,7 @@ public class TopSitesPanel extends HomeFragment {
|
||||
menu.findItem(R.id.home_share).setVisible(false);
|
||||
}
|
||||
|
||||
if (!Restrictions.isAllowed(context, Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(context, Restrictable.PRIVATE_BROWSING)) {
|
||||
menu.findItem(R.id.home_open_private_tab).setVisible(false);
|
||||
}
|
||||
|
||||
|
@ -713,17 +713,17 @@ just addresses the organization to follow, e.g. "This site is run by " -->
|
||||
code. -->
|
||||
<!ENTITY devtools_auth_scan_header "Scanning for the QR code displayed on your other device">
|
||||
|
||||
<!-- Restrictions -->
|
||||
<!-- Localization note: These are restrictions the device owner (e.g. parent) can enable for
|
||||
<!-- Restrictable features -->
|
||||
<!-- Localization note: These are features the device owner (e.g. parent) can enable or disable for
|
||||
a restricted profile (e.g. child). Used inside the Android settings UI. -->
|
||||
<!ENTITY restriction_disallow_addons_title2 "Disable add-on installation">
|
||||
<!ENTITY restriction_disallow_private_browsing_title2 "Disable Private Browsing">
|
||||
<!ENTITY restriction_disallow_location_services_title2 "Disable Location Services">
|
||||
<!ENTITY restriction_disallow_clear_history_title2 "Disable \'Clear browsing history\'">
|
||||
<!ENTITY restriction_disallow_master_password_title2 "Disable master password">
|
||||
<!ENTITY restriction_disallow_guest_browsing_title2 "Disable Guest Browsing">
|
||||
<!ENTITY restriction_disallow_advanced_settings_title "Disable Advanced Settings">
|
||||
<!ENTITY restriction_disallow_camera_microphone_title "Block camera and microphone">
|
||||
<!ENTITY restrictable_feature_addons_installation "Add-ons">
|
||||
<!ENTITY restrictable_feature_private_browsing "Private Browsing">
|
||||
<!ENTITY restrictable_feature_location_services "Location Services">
|
||||
<!ENTITY restrictable_feature_clear_history "Clear History">
|
||||
<!ENTITY restrictable_feature_guest_browsing "Guest browsing">
|
||||
<!ENTITY restrictable_feature_master_password "Master password">
|
||||
<!ENTITY restrictable_feature_advanced_settings "Advanced Settings">
|
||||
<!ENTITY restrictable_feature_camera_microphone "Camera & Microphone">
|
||||
|
||||
<!-- Default Bookmarks titles-->
|
||||
<!-- LOCALIZATION NOTE (bookmarks_about_browser): link title for about:fennec -->
|
||||
|
@ -28,7 +28,7 @@ class AndroidImportPreference extends MultiPrefMultiChoicePreference {
|
||||
public static class Handler implements GeckoPreferences.PrefHandler {
|
||||
public boolean setupPref(Context context, Preference pref) {
|
||||
// Feature disabled on devices running Android M+ (Bug 1183559)
|
||||
return Versions.preM && Restrictions.isAllowed(context, Restrictable.DISALLOW_IMPORT_SETTINGS);
|
||||
return Versions.preM && Restrictions.isAllowed(context, Restrictable.IMPORT_SETTINGS);
|
||||
}
|
||||
|
||||
public void onChange(Context context, Preference pref, Object newValue) { }
|
||||
|
@ -463,7 +463,7 @@ OnSharedPreferenceChangeListener
|
||||
while (iterator.hasNext()) {
|
||||
Header header = iterator.next();
|
||||
|
||||
if (header.id == R.id.pref_header_advanced && !Restrictions.isAllowed(this, Restrictable.DISALLOW_ADVANCED_SETTINGS)) {
|
||||
if (header.id == R.id.pref_header_advanced && !Restrictions.isAllowed(this, Restrictable.ADVANCED_SETTINGS)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@ -678,7 +678,7 @@ OnSharedPreferenceChangeListener
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_SCREEN_ADVANCED.equals(key) &&
|
||||
!Restrictions.isAllowed(this, Restrictable.DISALLOW_ADVANCED_SETTINGS)) {
|
||||
!Restrictions.isAllowed(this, Restrictable.ADVANCED_SETTINGS)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -694,7 +694,7 @@ OnSharedPreferenceChangeListener
|
||||
}
|
||||
} else if (PREFS_OPEN_URLS_IN_PRIVATE.equals(key)) {
|
||||
// Remove UI for opening external links in private browsing on non-Nightly builds.
|
||||
if (!AppConstants.NIGHTLY_BUILD || !Restrictions.isAllowed(this, Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!AppConstants.NIGHTLY_BUILD || !Restrictions.isAllowed(this, Restrictable.PRIVATE_BROWSING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -734,19 +734,19 @@ OnSharedPreferenceChangeListener
|
||||
}
|
||||
} else if (PREFS_GEO_REPORTING.equals(key) ||
|
||||
PREFS_GEO_LEARN_MORE.equals(key)) {
|
||||
if (!AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED || !Restrictions.isAllowed(this, Restrictable.DISALLOW_LOCATION_SERVICE)) {
|
||||
if (!AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED || !Restrictions.isAllowed(this, Restrictable.LOCATION_SERVICE)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_DEVTOOLS_REMOTE_USB_ENABLED.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_REMOTE_DEBUGGING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.REMOTE_DEBUGGING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_DEVTOOLS_REMOTE_WIFI_ENABLED.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_REMOTE_DEBUGGING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.REMOTE_DEBUGGING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -759,7 +759,7 @@ OnSharedPreferenceChangeListener
|
||||
}
|
||||
} else if (PREFS_DEVTOOLS_REMOTE_LINK.equals(key)) {
|
||||
// Remove the "Learn more" link if remote debugging is disabled
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_REMOTE_DEBUGGING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.REMOTE_DEBUGGING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -776,7 +776,7 @@ OnSharedPreferenceChangeListener
|
||||
continue;
|
||||
} else if (PREFS_SYNC.equals(key)) {
|
||||
// Don't show sync prefs while in guest mode.
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.MODIFY_ACCOUNTS)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -819,19 +819,19 @@ OnSharedPreferenceChangeListener
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_TRACKING_PROTECTION_PRIVATE_BROWSING.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.PRIVATE_BROWSING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_TRACKING_PROTECTION_LEARN_MORE.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.PRIVATE_BROWSING)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_MP_ENABLED.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_MASTER_PASSWORD)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.MASTER_PASSWORD)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
@ -843,7 +843,7 @@ OnSharedPreferenceChangeListener
|
||||
continue;
|
||||
}
|
||||
} else if (PREFS_CLEAR_PRIVATE_DATA.equals(key) || PREFS_CLEAR_PRIVATE_DATA_EXIT.equals(key)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.DISALLOW_CLEAR_HISTORY)) {
|
||||
if (!Restrictions.isAllowed(this, Restrictable.CLEAR_HISTORY)) {
|
||||
preferences.removePreference(pref);
|
||||
i--;
|
||||
continue;
|
||||
|
@ -14,18 +14,18 @@ import java.util.List;
|
||||
* RestrictionConfiguration implementation for guest profiles.
|
||||
*/
|
||||
public class GuestProfileConfiguration implements RestrictionConfiguration {
|
||||
static List<Restrictable> DEFAULT_RESTRICTIONS = Arrays.asList(
|
||||
Restrictable.DISALLOW_DOWNLOADS,
|
||||
Restrictable.DISALLOW_INSTALL_EXTENSION,
|
||||
Restrictable.DISALLOW_INSTALL_APPS,
|
||||
Restrictable.DISALLOW_BROWSE_FILES,
|
||||
Restrictable.DISALLOW_SHARE,
|
||||
Restrictable.DISALLOW_BOOKMARK,
|
||||
Restrictable.DISALLOW_ADD_CONTACTS,
|
||||
Restrictable.DISALLOW_SET_IMAGE,
|
||||
Restrictable.DISALLOW_MODIFY_ACCOUNTS,
|
||||
Restrictable.DISALLOW_REMOTE_DEBUGGING,
|
||||
Restrictable.DISALLOW_IMPORT_SETTINGS
|
||||
static List<Restrictable> DISABLED_FEATURES = Arrays.asList(
|
||||
Restrictable.DOWNLOAD,
|
||||
Restrictable.INSTALL_EXTENSION,
|
||||
Restrictable.INSTALL_APPS,
|
||||
Restrictable.BROWSE,
|
||||
Restrictable.SHARE,
|
||||
Restrictable.BOOKMARK,
|
||||
Restrictable.ADD_CONTACT,
|
||||
Restrictable.SET_IMAGE,
|
||||
Restrictable.MODIFY_ACCOUNTS,
|
||||
Restrictable.REMOTE_DEBUGGING,
|
||||
Restrictable.IMPORT_SETTINGS
|
||||
);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ -44,7 +44,7 @@ public class GuestProfileConfiguration implements RestrictionConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(Restrictable restrictable) {
|
||||
return !DEFAULT_RESTRICTIONS.contains(restrictable);
|
||||
return !DISABLED_FEATURES.contains(restrictable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,43 +16,43 @@ import android.support.annotation.StringRes;
|
||||
* These constants should be in sync with the ones from toolkit/components/parentalcontrols/nsIParentalControlsService.idl
|
||||
*/
|
||||
public enum Restrictable {
|
||||
DISALLOW_DOWNLOADS(1, "no_download_files", 0),
|
||||
DOWNLOAD(1, "downloads", 0),
|
||||
|
||||
DISALLOW_INSTALL_EXTENSION(2, "no_install_extensions", R.string.restriction_disallow_addons_title),
|
||||
INSTALL_EXTENSION(2, "no_install_extensions", R.string.restrictable_feature_addons_installation),
|
||||
|
||||
// UserManager.DISALLOW_INSTALL_APPS
|
||||
DISALLOW_INSTALL_APPS(3, "no_install_apps", 0),
|
||||
INSTALL_APPS(3, "no_install_apps", 0),
|
||||
|
||||
DISALLOW_BROWSE_FILES(4, "no_browse_files", 0),
|
||||
BROWSE(4, "browse", 0),
|
||||
|
||||
DISALLOW_SHARE(5, "no_share", 0),
|
||||
SHARE(5, "share", 0),
|
||||
|
||||
DISALLOW_BOOKMARK(6, "no_bookmark", 0),
|
||||
BOOKMARK(6, "bookmark", 0),
|
||||
|
||||
DISALLOW_ADD_CONTACTS(7, "no_add_contacts", 0),
|
||||
ADD_CONTACT(7, "add_contact", 0),
|
||||
|
||||
DISALLOW_SET_IMAGE(8, "no_set_image", 0),
|
||||
SET_IMAGE(8, "set_image", 0),
|
||||
|
||||
// UserManager.DISALLOW_MODIFY_ACCOUNTS
|
||||
DISALLOW_MODIFY_ACCOUNTS(9, "no_modify_accounts", 0),
|
||||
MODIFY_ACCOUNTS(9, "no_modify_accounts", 0),
|
||||
|
||||
DISALLOW_REMOTE_DEBUGGING(10, "no_remote_debugging", 0),
|
||||
REMOTE_DEBUGGING(10, "remote_debugging", 0),
|
||||
|
||||
DISALLOW_IMPORT_SETTINGS(11, "no_import_settings", 0),
|
||||
IMPORT_SETTINGS(11, "import_settings", 0),
|
||||
|
||||
DISALLOW_PRIVATE_BROWSING(12, "no_private_browsing", R.string.restriction_disallow_private_browsing_title),
|
||||
PRIVATE_BROWSING(12, "private_browsing", R.string.restrictable_feature_private_browsing),
|
||||
|
||||
DISALLOW_LOCATION_SERVICE(13, "no_location_service", R.string.restriction_disallow_location_services_title),
|
||||
LOCATION_SERVICE(13, "location_service", R.string.restrictable_feature_location_services),
|
||||
|
||||
DISALLOW_CLEAR_HISTORY(14, "no_clear_history", R.string.restriction_disallow_clear_history_title),
|
||||
CLEAR_HISTORY(14, "clear_history", R.string.restrictable_feature_clear_history),
|
||||
|
||||
DISALLOW_MASTER_PASSWORD(15, "no_master_password", R.string.restriction_disallow_master_password_title),
|
||||
MASTER_PASSWORD(15, "master_password", R.string.restrictable_feature_master_password),
|
||||
|
||||
DISALLOW_GUEST_BROWSING(16, "no_guest_browsing", R.string.restriction_disallow_guest_browsing_title),
|
||||
GUEST_BROWSING(16, "guest_browsing", R.string.restrictable_feature_guest_browsing),
|
||||
|
||||
DISALLOW_ADVANCED_SETTINGS(17, "no_advanced_settings", R.string.restriction_disallow_advanced_settings_title),
|
||||
ADVANCED_SETTINGS(17, "advanced_settings", R.string.restrictable_feature_advanced_settings),
|
||||
|
||||
DISALLOW_CAMERA_MICROPHONE(18, "no_camera_microphone", R.string.restriction_disallow_camera_microphone_title);
|
||||
CAMERA_MICROPHONE(18, "camera_microphone", R.string.restrictable_feature_camera_microphone);
|
||||
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
@ -20,19 +20,20 @@ import java.util.List;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public class RestrictedProfileConfiguration implements RestrictionConfiguration {
|
||||
static List<Restrictable> DEFAULT_RESTRICTIONS = Arrays.asList(
|
||||
Restrictable.DISALLOW_INSTALL_EXTENSION,
|
||||
Restrictable.DISALLOW_PRIVATE_BROWSING,
|
||||
Restrictable.DISALLOW_LOCATION_SERVICE,
|
||||
Restrictable.DISALLOW_CLEAR_HISTORY,
|
||||
Restrictable.DISALLOW_MASTER_PASSWORD,
|
||||
Restrictable.DISALLOW_GUEST_BROWSING,
|
||||
Restrictable.DISALLOW_ADVANCED_SETTINGS,
|
||||
Restrictable.DISALLOW_CAMERA_MICROPHONE
|
||||
static List<Restrictable> DEFAULT_DISABLED_FEATURES = Arrays.asList(
|
||||
Restrictable.INSTALL_EXTENSION,
|
||||
Restrictable.PRIVATE_BROWSING,
|
||||
Restrictable.LOCATION_SERVICE,
|
||||
Restrictable.CLEAR_HISTORY,
|
||||
Restrictable.MASTER_PASSWORD,
|
||||
Restrictable.GUEST_BROWSING,
|
||||
Restrictable.ADVANCED_SETTINGS,
|
||||
Restrictable.CAMERA_MICROPHONE
|
||||
);
|
||||
|
||||
private Context context;
|
||||
private Bundle cachedRestrictions;
|
||||
private Bundle cachedAppRestrictions;
|
||||
private Bundle cachedUserRestrictions;
|
||||
private boolean isCacheInvalid = true;
|
||||
|
||||
public RestrictedProfileConfiguration(Context context) {
|
||||
@ -42,23 +43,28 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
|
||||
@Override
|
||||
public synchronized boolean isAllowed(Restrictable restrictable) {
|
||||
if (isCacheInvalid || !ThreadUtils.isOnUiThread()) {
|
||||
cachedRestrictions = readRestrictions();
|
||||
readRestrictions();
|
||||
isCacheInvalid = false;
|
||||
}
|
||||
|
||||
return !cachedRestrictions.getBoolean(restrictable.name, DEFAULT_RESTRICTIONS.contains(restrictable));
|
||||
// Special casing system/user restrictions
|
||||
if (restrictable == Restrictable.INSTALL_APPS || restrictable == Restrictable.MODIFY_ACCOUNTS) {
|
||||
return !cachedUserRestrictions.getBoolean(restrictable.name);
|
||||
}
|
||||
|
||||
return cachedAppRestrictions.getBoolean(restrictable.name, !DEFAULT_DISABLED_FEATURES.contains(restrictable));
|
||||
}
|
||||
|
||||
private Bundle readRestrictions() {
|
||||
private void readRestrictions() {
|
||||
final UserManager mgr = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
|
||||
StrictMode.ThreadPolicy policy = StrictMode.allowThreadDiskReads();
|
||||
|
||||
try {
|
||||
Bundle restrictions = new Bundle();
|
||||
restrictions.putAll(mgr.getApplicationRestrictions(context.getPackageName()));
|
||||
restrictions.putAll(mgr.getUserRestrictions());
|
||||
return restrictions;
|
||||
cachedAppRestrictions = mgr.getApplicationRestrictions(context.getPackageName());
|
||||
cachedUserRestrictions = mgr.getUserRestrictions();
|
||||
|
||||
|
||||
} finally {
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
}
|
||||
@ -66,11 +72,11 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
|
||||
|
||||
@Override
|
||||
public boolean canLoadUrl(String url) {
|
||||
if (!isAllowed(Restrictable.DISALLOW_INSTALL_EXTENSION) && AboutPages.isAboutAddons(url)) {
|
||||
if (!isAllowed(Restrictable.INSTALL_EXTENSION) && AboutPages.isAboutAddons(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isAllowed(Restrictable.DISALLOW_PRIVATE_BROWSING) && AboutPages.isAboutPrivateBrowsing(url)) {
|
||||
if (!isAllowed(Restrictable.PRIVATE_BROWSING) && AboutPages.isAboutPrivateBrowsing(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -91,4 +97,4 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
|
||||
public synchronized void update() {
|
||||
isCacheInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -50,13 +50,13 @@ public class RestrictionProvider extends BroadcastReceiver {
|
||||
private ArrayList<RestrictionEntry> initRestrictions(Context context, Bundle oldRestrictions) {
|
||||
ArrayList<RestrictionEntry> entries = new ArrayList<RestrictionEntry>();
|
||||
|
||||
for (Restrictable restrictable : RestrictedProfileConfiguration.DEFAULT_RESTRICTIONS) {
|
||||
if (restrictable == Restrictable.DISALLOW_LOCATION_SERVICE && !AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED) {
|
||||
for (Restrictable restrictable : RestrictedProfileConfiguration.DEFAULT_DISABLED_FEATURES) {
|
||||
if (restrictable == Restrictable.LOCATION_SERVICE && !AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RestrictionEntry entry = createRestrictionEntryWithDefaultValue(context, restrictable,
|
||||
oldRestrictions.getBoolean(restrictable.name, true));
|
||||
oldRestrictions.getBoolean(restrictable.name, false));
|
||||
entries.add(entry);
|
||||
}
|
||||
|
||||
|
@ -564,15 +564,15 @@
|
||||
<!-- Voice search from the Awesome Bar -->
|
||||
<string name="voicesearch_prompt">&voicesearch_prompt;</string>
|
||||
|
||||
<!-- Restrictions -->
|
||||
<string name="restriction_disallow_addons_title">&restriction_disallow_addons_title2;</string>
|
||||
<string name="restriction_disallow_private_browsing_title">&restriction_disallow_private_browsing_title2;</string>
|
||||
<string name="restriction_disallow_location_services_title">&restriction_disallow_location_services_title2;</string>
|
||||
<string name="restriction_disallow_clear_history_title">&restriction_disallow_clear_history_title2;</string>
|
||||
<string name="restriction_disallow_master_password_title">&restriction_disallow_master_password_title2;</string>
|
||||
<string name="restriction_disallow_guest_browsing_title">&restriction_disallow_guest_browsing_title2;</string>
|
||||
<string name="restriction_disallow_advanced_settings_title">&restriction_disallow_advanced_settings_title;</string>
|
||||
<string name="restriction_disallow_camera_microphone_title">&restriction_disallow_camera_microphone_title;</string>
|
||||
<!-- Restrictable features -->
|
||||
<string name="restrictable_feature_addons_installation">&restrictable_feature_addons_installation;</string>
|
||||
<string name="restrictable_feature_private_browsing">&restrictable_feature_private_browsing;</string>
|
||||
<string name="restrictable_feature_location_services">&restrictable_feature_location_services;</string>
|
||||
<string name="restrictable_feature_clear_history">&restrictable_feature_clear_history;</string>
|
||||
<string name="restrictable_feature_guest_browsing">&restrictable_feature_guest_browsing;</string>
|
||||
<string name="restrictable_feature_master_password">&restrictable_feature_master_password;</string>
|
||||
<string name="restrictable_feature_advanced_settings">&restrictable_feature_advanced_settings;</string>
|
||||
<string name="restrictable_feature_camera_microphone">&restrictable_feature_camera_microphone;</string>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<string name="ellipsis">&ellipsis;</string>
|
||||
|
@ -144,7 +144,7 @@ public class TabsPanel extends LinearLayout
|
||||
(ThemedImageButton) mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private);
|
||||
privateTabsPanel.setPrivateMode(true);
|
||||
|
||||
if (!Restrictions.isAllowed(mContext, Restrictable.DISALLOW_PRIVATE_BROWSING)) {
|
||||
if (!Restrictions.isAllowed(mContext, Restrictable.PRIVATE_BROWSING)) {
|
||||
mTabWidget.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ public class TabsPanel extends LinearLayout
|
||||
// Each panel has a "+" shortcut button, so don't show it for that panel.
|
||||
menu.findItem(R.id.new_tab).setVisible(mCurrentPanel != Panel.NORMAL_TABS);
|
||||
menu.findItem(R.id.new_private_tab).setVisible(mCurrentPanel != Panel.PRIVATE_TABS
|
||||
&& Restrictions.isAllowed(mContext, Restrictable.DISALLOW_PRIVATE_BROWSING));
|
||||
&& Restrictions.isAllowed(mContext, Restrictable.PRIVATE_BROWSING));
|
||||
|
||||
// Only show "Clear * tabs" for current panel.
|
||||
menu.findItem(R.id.close_all_tabs).setVisible(mCurrentPanel == Panel.NORMAL_TABS);
|
||||
|
@ -4487,8 +4487,8 @@ Tab.prototype = {
|
||||
fixedURI = URIFixup.createExposableURI(aLocationURI);
|
||||
} catch (ex) { }
|
||||
|
||||
// In restricted profiles, we refuse to let you open any file urls.
|
||||
if (!ParentalControls.isAllowed(ParentalControls.VISIT_FILE_URLS, fixedURI)) {
|
||||
// In restricted profiles, we refuse to let you open various urls.
|
||||
if (!ParentalControls.isAllowed(ParentalControls.BROWSE, fixedURI)) {
|
||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||
|
||||
this.browser.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PROTOCOL, fixedURI, null);
|
||||
|
@ -32,7 +32,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.DOWNLOAD));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_EXTENSION));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_APP));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.VISIT_FILE_URLS));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.BROWSE));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.SHARE));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.BOOKMARK));
|
||||
ok(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_EXTENSION));
|
||||
|
@ -11,7 +11,7 @@ interface nsIFile;
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIArray;
|
||||
|
||||
[scriptable, uuid(c7713ad7-0804-4353-91d5-4d7f1376bded)]
|
||||
[scriptable, uuid(ec6ae96e-e161-481e-bb51-78b11fc1fdbe)]
|
||||
interface nsIParentalControlsService : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -20,7 +20,7 @@ interface nsIParentalControlsService : nsISupports
|
||||
const short DOWNLOAD = 1; // Downloading files
|
||||
const short INSTALL_EXTENSION = 2; // Installing extensions
|
||||
const short INSTALL_APP = 3; // Installing webapps
|
||||
const short VISIT_FILE_URLS = 4; // Opening file:/// urls
|
||||
const short BROWSE = 4; // Opening specific urls
|
||||
const short SHARE = 5; // Sharing
|
||||
const short BOOKMARK = 6; // Creating bookmarks
|
||||
const short ADD_CONTACT = 7; // Add contacts to the system database
|
||||
|
Loading…
Reference in New Issue
Block a user