Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java

Issue 2931433004: [Android] Open a tab in the background from Browser Actions if ChromeTabbedActivity is available (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java
index 96cb081ded651aa2e9352fc245689e17450e1de0..495417deb6bd107ab265f1557cc9fabaea309235 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsContextMenuHelper.java
@@ -64,6 +64,8 @@ public class BrowserActionsContextMenuHelper implements OnCreateContextMenuListe
private final List<Pair<Integer, List<ContextMenuItem>>> mItems;
+ private boolean mIsOpenInBackgroundPending;
+
public BrowserActionsContextMenuHelper(BrowserActionActivity activity, ContextMenuParams params,
List<BrowserActionItem> customItems, String sourcePackageName) {
mActivity = activity;
@@ -77,7 +79,9 @@ public class BrowserActionsContextMenuHelper implements OnCreateContextMenuListe
mOnMenuClosed = new Runnable() {
@Override
public void run() {
- mActivity.finish();
+ if (!mIsOpenInBackgroundPending) {
+ mActivity.finish();
Yusuf 2017/06/29 19:05:26 one line
ltian 2017/06/30 23:57:56 The "git cl format" forces this to be into multipl
+ }
}
};
mItemSelectedCallback = new Callback<Integer>() {
@@ -127,7 +131,12 @@ public class BrowserActionsContextMenuHelper implements OnCreateContextMenuListe
private boolean onItemSelected(int itemId) {
if (itemId == R.id.browser_actions_open_in_background) {
- mDelegate.onOpenInBackground(mCurrentContextMenuParams.getLinkUrl());
+ if (mActivity.isNatvieInitialized()) {
+ mDelegate.onOpenInBackground(mCurrentContextMenuParams.getLinkUrl());
Yusuf 2017/06/29 19:05:26 maybe this is all the delegate's job?
ltian 2017/06/30 23:57:56 I feel the delegate is only responsible for execut
+ } else {
+ mIsOpenInBackgroundPending = true;
+ mActivity.waitNativeInitialized();
+ }
} else if (itemId == R.id.browser_actions_open_in_incognito_tab) {
mDelegate.onOpenInIncognitoTab(mCurrentContextMenuParams.getLinkUrl());
} else if (itemId == R.id.browser_actions_save_link_as) {
@@ -179,4 +188,15 @@ public class BrowserActionsContextMenuHelper implements OnCreateContextMenuListe
@Override
public void onViewDetachedFromWindow(View v) {}
+
+ /**
+ * Finishes all pending actions which requires Chrome native libraries.
+ */
+ public void handlePendingActions() {
+ if (mIsOpenInBackgroundPending) {
+ mIsOpenInBackgroundPending = false;
+ mDelegate.onOpenInBackground(mCurrentContextMenuParams.getLinkUrl());
+ mActivity.finish();
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698