Bug 1196708 - Restricted profiles: Hide Remove context menu item from Top Sites. r=mhaigh a=sylvestre
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 28 Aug 2015 12:41:10 +0200
changeset 277523 408b19349d5a8267a5e4fb90e767eed9fd2f7f52
parent 277522 125fb532285479feaffb06fb09c40a3e37ccefae
child 277524 437fb42ca4364757dacaaf65a526aaf92293b28d
push id8381
push userkwierso@gmail.com
push dateFri, 04 Sep 2015 20:23:22 +0000
treeherdermozilla-aurora@7ba5523ffb28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sylvestre
bugs1196708
milestone42.0a2
Bug 1196708 - Restricted profiles: Hide Remove context menu item from Top Sites. r=mhaigh a=sylvestre
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);
         }
     }
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
         if (super.onContextItemSelected(item)) {
             // HomeFragment was able to handle to selected item.