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 c611ca60c6b322e82a6d977fafb3bf8fd432459c..1e5919f43b6d04e4113de4f7e807179adc1afa5e 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,10 +11,12 @@ import android.net.Uri; |
import android.os.Bundle; |
import android.support.customtabs.browseractions.BrowserActionItem; |
import android.support.customtabs.browseractions.BrowserActionsIntent; |
+import android.text.TextUtils; |
import android.view.Menu; |
import android.view.View; |
import org.chromium.base.Log; |
+import org.chromium.base.VisibleForTesting; |
import org.chromium.base.annotations.SuppressFBWarnings; |
import org.chromium.chrome.browser.IntentHandler; |
import org.chromium.chrome.browser.UrlConstants; |
@@ -74,7 +76,8 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
} else if (mCreatorPackageName == null) { |
Log.e(TAG, "Missing creator's pacakge name"); |
return false; |
- } else if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { |
+ } else if (!TextUtils.equals(mCreatorPackageName, getPackageName()) |
+ && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { |
Log.e(TAG, "Intent should not be started with FLAG_ACTIVITY_NEW_TASK"); |
return false; |
} else if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) { |
@@ -91,12 +94,26 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
@Override |
public void openContextMenu(View view) { |
ContextMenuParams params = createContextMenuParams(); |
- mHelper = new BrowserActionsContextMenuHelper( |
- this, params, mActions, mCreatorPackageName, mOnBrowserActionSelectedCallback); |
+ Runnable listener = new Runnable() { |
+ @Override |
+ public void run() { |
+ startDelayedNativeInitialization(); |
+ } |
+ }; |
+ mHelper = new BrowserActionsContextMenuHelper(this, params, mActions, mCreatorPackageName, |
+ mOnBrowserActionSelectedCallback, listener); |
mHelper.displayBrowserActionsMenu(view); |
return; |
} |
+ /** |
+ * @return The {@link BrowserActionsContextMenuHelper} for testing. |
+ */ |
+ @VisibleForTesting |
+ BrowserActionsContextMenuHelper getHelperForTesting() { |
+ return mHelper; |
+ } |
+ |
/** |
* Creates a {@link ContextMenuParams} with given Uri and type. |
* @return The ContextMenuParams used to construct context menu. |
@@ -125,13 +142,6 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
return true; |
} |
- /** |
- * Callback when Browser Actions menu dialog is shown. |
- */ |
- public void onMenuShown() { |
- startDelayedNativeInitialization(); |
- } |
- |
@Override |
public void onContextMenuClosed(Menu menu) { |
super.onContextMenuClosed(menu); |
@@ -139,4 +149,10 @@ public class BrowserActionActivity extends AsyncInitializationActivity { |
mHelper.onContextMenuClosed(); |
} |
} |
+ |
+ @Override |
+ public void finishNativeInitialization() { |
+ super.finishNativeInitialization(); |
+ mHelper.onNativeInitialized(); |
+ } |
} |