Bug 1196708 - Restricted profiles: Hide Remove context menu item from Top Sites. r=mhaigh
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 28 Aug 2015 12:41:10 +0200
changeset 260533 ee9881d7a21c1e3aab8285dde3914be8e25db1e0
parent 260532 360fdece5ebb437abf7a0b39d267c4fc3e3cfef2
child 260534 b4ca0600cbe11f7536e4356dab3423efa263ee09
push id29313
push userryanvm@gmail.com
push dateWed, 02 Sep 2015 18:50:07 +0000
treeherdermozilla-central@296a82095345 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1196708
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1196708 - Restricted profiles: Hide Remove context menu item from Top Sites. r=mhaigh
mobile/android/base/home/TopSitesPanel.java
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -340,23 +340,27 @@ public class TopSitesPanel extends HomeF
 
         if (!(menuInfo instanceof TopSitesGridContextMenuInfo)) {
             // Long pressed item was not a Top Sites GridView item. Superclass
             // can handle this.
             super.onCreateContextMenu(menu, view, menuInfo);
             return;
         }
 
+        final Context context = view.getContext();
+
         // Long pressed item was a Top Sites GridView item, handle it.
-        MenuInflater inflater = new MenuInflater(view.getContext());
+        MenuInflater inflater = new MenuInflater(context);
         inflater.inflate(R.menu.home_contextmenu, menu);
 
         // Hide unused menu items.
         menu.findItem(R.id.home_edit_bookmark).setVisible(false);
 
+        menu.findItem(R.id.home_remove).setVisible(RestrictedProfiles.isAllowed(context, Restriction.DISALLOW_CLEAR_HISTORY));
+
         TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo;
         menu.setHeaderTitle(info.getDisplayTitle());
 
         if (info.type != TopSites.TYPE_BLANK) {
             if (info.type == TopSites.TYPE_PINNED) {
                 menu.findItem(R.id.top_sites_pin).setVisible(false);
             } else {
                 menu.findItem(R.id.top_sites_unpin).setVisible(false);
@@ -367,17 +371,17 @@ public class TopSitesPanel extends HomeF
             menu.findItem(R.id.top_sites_pin).setVisible(false);
             menu.findItem(R.id.top_sites_unpin).setVisible(false);
         }
 
         if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) {
             menu.findItem(R.id.home_share).setVisible(false);
         }
 
-        if (!RestrictedProfiles.isAllowed(view.getContext(), Restriction.DISALLOW_PRIVATE_BROWSING)) {
+        if (!RestrictedProfiles.isAllowed(context, Restriction.DISALLOW_PRIVATE_BROWSING)) {
             menu.findItem(R.id.home_open_private_tab).setVisible(false);
         }
 
         // We only show these menu items on the reading list panel:
         menu.findItem(R.id.mark_read).setVisible(false);
         menu.findItem(R.id.mark_unread).setVisible(false);
     }