Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionActivity.java |
| index 2ba84753170c9b5157074cee028f0bd90afde7b1..1367b6aee1257afdcb599a481d3d9ca0f97b44eb 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionActivity.java |
| @@ -11,19 +11,23 @@ import android.net.Uri; |
| import android.os.Bundle; |
| import android.support.customtabs.browseractions.BrowserActionItem; |
| import android.support.customtabs.browseractions.BrowserActionsIntent; |
| +import android.view.Menu; |
| +import android.view.View; |
| import org.chromium.base.Log; |
| import org.chromium.base.annotations.SuppressFBWarnings; |
| import org.chromium.chrome.browser.IntentHandler; |
| import org.chromium.chrome.browser.UrlConstants; |
| +import org.chromium.chrome.browser.contextmenu.ContextMenuParams; |
| import org.chromium.chrome.browser.init.AsyncInitializationActivity; |
| import org.chromium.chrome.browser.util.IntentUtils; |
| +import org.chromium.content_public.common.Referrer; |
| import java.util.ArrayList; |
| import java.util.List; |
| /** |
| - * A transparent {@link AsyncInitializationActivity} that displays the browser action context menu. |
| + * A transparent {@link AsyncInitializationActivity} that displays the Browser Actions context menu. |
| */ |
| public class BrowserActionActivity extends AsyncInitializationActivity { |
| private static final String TAG = "BrowserActions"; |
| @@ -32,10 +36,13 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
| private Uri mUri; |
| private String mCreatorPackageName; |
| private List<BrowserActionItem> mActions = new ArrayList<>(); |
| + private BrowserActionsContextMenuHelper mHelper; |
| @Override |
| protected void setContentView() { |
| - openContextMenu(); |
| + View view = new View(this); |
| + setContentView(view); |
| + openContextMenu(view); |
| } |
| @Override |
| @@ -78,10 +85,25 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
| /** |
| * Opens a Browser Actions context menu based on the parsed data. |
| */ |
| - public void openContextMenu() { |
| + @Override |
| + public void openContextMenu(View view) { |
| + ContextMenuParams params = getContextMenuParams(); |
| + mHelper = new BrowserActionsContextMenuHelper(this, params, mActions); |
| + mHelper.displayBrowserActionsMenu(view); |
| return; |
| } |
| + /** |
| + * Populates a {@link ContextMenuParams} with given Uri and type. |
| + * @return The ContextMenuParams used to construct context menu. |
| + */ |
| + private ContextMenuParams getContextMenuParams() { |
|
Ted C
2017/05/12 23:35:25
s/get/create
ltian
2017/05/15 21:47:03
Done.
|
| + Referrer referrer = IntentHandler.constructValidReferrerForAuthority(mCreatorPackageName); |
| + return new ContextMenuParams(mType, mUri.toString(), mUri.toString(), mUri.toString(), |
| + mUri.toString(), mUri.toString(), mUri.toString(), false /* imageWasFetchedLoFi */, |
| + referrer, false /* canSaveMedia */); |
| + } |
| + |
| @Override |
| protected boolean shouldDelayBrowserStartup() { |
| return true; |
| @@ -122,7 +144,15 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
| /** |
| * Callback when Browser Actions menu dialog is shown. |
| */ |
| - private void onMenuShown() { |
| + public void onMenuShown() { |
| beginLoadingLibrary(); |
| } |
| + |
| + @Override |
| + public void onContextMenuClosed(Menu menu) { |
| + super.onContextMenuClosed(menu); |
| + if (mHelper != null) { |
| + mHelper.onContextMenuClosed(); |
| + } |
| + } |
| } |