Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / contextmenu / ChromeContextMenuItemDelegate.java
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
5 package org.chromium.chrome.browser.contextmenu;
6
7 import org.chromium.chrome.browser.Tab;
8 import org.chromium.content.browser.ContentViewCore;
9 import org.chromium.content_public.common.Referrer;
10
11 /**
12  * A delegate responsible for taking actions based on context menu selections.
13  */
14 public interface ChromeContextMenuItemDelegate {
15     /**
16      * @return Whether or not this context menu is being shown for an incognito
17      *     {@link ContentViewCore}.
18      */
19     boolean isIncognito();
20
21     /**
22      * @return Whether or not the current application can show incognito tabs.
23      */
24     boolean isIncognitoSupported();
25
26     /**
27      * @return Whether or not the context menu should give the user the chance to show the original
28      *         image.
29      */
30     boolean canLoadOriginalImage();
31
32     /**
33      * Called when the context menu is trying to start a download.
34      * @param url Url of the download item.
35      * @param isLink Whether or not the download is a link (as opposed to an image/video).
36      * @return       Whether or not a download should actually be started.
37      */
38     boolean startDownload(String url, boolean isLink);
39
40     /**
41      * Called when the {@code url} should be opened in a new tab with the same incognito state as
42      * the current {@link Tab}.
43      * @param url The URL to open.
44      */
45     void onOpenInNewTab(String url, Referrer referrer);
46
47     /**
48      * Called when the {@code url} should be opened in a new incognito tab.
49      * @param url The URL to open.
50      */
51     void onOpenInNewIncognitoTab(String url);
52
53     /**
54      * Called when the {@code url} is of an image and should be opened in the same tab.
55      * @param url The image URL to open.
56      */
57     void onOpenImageUrl(String url, Referrer referrer);
58
59     /**
60      * Called when the {@code url} is of an image and should be opened in a new tab.
61      * @param url The image URL to open.
62      */
63     void onOpenImageInNewTab(String url, Referrer referrer);
64
65     /**
66      * Called when the {@code text} should be saved to the clipboard.
67      * @param text  The text to save to the clipboard.
68      * @param isUrl Whether or not the text is a URL.
69      */
70     void onSaveToClipboard(String text, boolean isUrl);
71
72     /**
73      * Called when the {@code url} is of an image and a link to the image should be saved to the
74      * clipboard.
75      * @param url The image URL.
76      */
77     void onSaveImageToClipboard(String url);
78
79     /**
80      * Called when a search by image should be performed in a new tab.
81      */
82     void onSearchByImageInNewTab();
83
84    /**
85     * @return page url.
86     */
87     String getPageUrl();
88 }