| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import android.view.ContextMenu; | 7 import android.view.ContextMenu; |
| 8 import android.view.ContextMenu.ContextMenuInfo; | 8 import android.view.ContextMenu.ContextMenuInfo; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.view.View.OnClickListener; | 10 import android.view.View.OnClickListener; |
| 11 import android.view.View.OnCreateContextMenuListener; | 11 import android.view.View.OnCreateContextMenuListener; |
| 12 | 12 |
| 13 import org.chromium.chrome.browser.ntp.ContextMenuManager.ContextMenuItemId; |
| 13 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; | 14 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; |
| 14 import org.chromium.ui.mojom.WindowOpenDisposition; | 15 import org.chromium.ui.mojom.WindowOpenDisposition; |
| 15 | 16 |
| 16 import java.util.Arrays; | |
| 17 import java.util.HashSet; | |
| 18 import java.util.Set; | |
| 19 | |
| 20 /** | 17 /** |
| 21 * Displays the title, thumbnail, and favicon of a most visited page. The item c
an be clicked, or | 18 * Displays the title, thumbnail, and favicon of a most visited page. The item c
an be clicked, or |
| 22 * long-pressed to trigger a context menu with options to "open in new tab", "op
en in incognito | 19 * long-pressed to trigger a context menu with options to "open in new tab", "op
en in incognito |
| 23 * tab", or "remove". | 20 * tab", or "remove". |
| 24 */ | 21 */ |
| 25 public class MostVisitedItem implements OnCreateContextMenuListener, OnClickList
ener { | 22 public class MostVisitedItem implements OnCreateContextMenuListener, OnClickList
ener { |
| 26 /** | 23 /** |
| 27 * Interface for an object that handles callbacks from a MostVisitedItem. | 24 * Interface for an object that handles callbacks from a MostVisitedItem. |
| 28 */ | 25 */ |
| 29 public interface MostVisitedItemManager { | 26 public interface MostVisitedItemManager { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 public void removeItem() { | 161 public void removeItem() { |
| 165 mManager.removeMostVisitedItem(MostVisitedItem.this); | 162 mManager.removeMostVisitedItem(MostVisitedItem.this); |
| 166 } | 163 } |
| 167 | 164 |
| 168 @Override | 165 @Override |
| 169 public String getUrl() { | 166 public String getUrl() { |
| 170 return MostVisitedItem.this.getUrl(); | 167 return MostVisitedItem.this.getUrl(); |
| 171 } | 168 } |
| 172 | 169 |
| 173 @Override | 170 @Override |
| 174 public Set<Integer> getSupportedMenuItems() { | 171 public boolean isItemSupported(@ContextMenuItemId int menuIt
emId) { |
| 175 return new HashSet<>(Arrays.asList(ContextMenuManager.ID
_OPEN_IN_NEW_WINDOW, | 172 return true; |
| 176 ContextMenuManager.ID_OPEN_IN_NEW_TAB, | |
| 177 ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB, | |
| 178 ContextMenuManager.ID_REMOVE, | |
| 179 ContextMenuManager.ID_SAVE_FOR_OFFLINE)); | |
| 180 } | 173 } |
| 181 }); | 174 }); |
| 182 } | 175 } |
| 183 | 176 |
| 184 @Override | 177 @Override |
| 185 public void onClick(View v) { | 178 public void onClick(View v) { |
| 186 mManager.openMostVisitedItem(WindowOpenDisposition.CURRENT_TAB, MostVisi
tedItem.this); | 179 mManager.openMostVisitedItem(WindowOpenDisposition.CURRENT_TAB, MostVisi
tedItem.this); |
| 187 } | 180 } |
| 188 } | 181 } |
| OLD | NEW |