1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5package org.chromium.chrome.browser.contextmenu; 6 7import android.content.Context; 8import android.view.ContextMenu; 9 10/** 11 * A delegate responsible for populating context menus and processing results from 12 * {@link ContextMenuHelper}. 13 */ 14public interface ContextMenuPopulator { 15 /** 16 * Determines whether or not a context menu should be shown for {@code params}. 17 * @param params The {@link ContextMenuParams} that represent what should be shown in the 18 * context menu. 19 * @return Whether or not a context menu should be shown. 20 */ 21 public boolean shouldShowContextMenu(ContextMenuParams params); 22 23 /** 24 * Should be used to populate {@code menu} with the correct context menu items. 25 * @param menu The menu to populate. 26 * @param context A {@link Context} instance. 27 * @param params The parameters that represent what should be shown in the context menu. 28 */ 29 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuParams params); 30 31 /** 32 * Called when a context menu item has been selected. 33 * @param helper The {@link ContextMenuHelper} driving the menu operations. 34 * @param params The parameters that represent what is being shown in the context menu. 35 * @param itemId The id of the selected menu item. 36 * @return Whether or not the selection was handled. 37 */ 38 public boolean onItemSelected(ContextMenuHelper helper, ContextMenuParams params, int itemId); 39}