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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java

Issue 2005053002: WebAPKs: Open links which are outside of WebAPK scope in Chrome not in WebAPK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/externalnav/ExternalNavigationDelegateImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
index 620fa92ad56e6b6bc637b9e8aa648c0764509cd1..7d922c81b2481c812c55db10856dd2051a3e4f72 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
@@ -57,9 +57,17 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
protected final Context mApplicationContext;
private final Tab mTab;
+ private final String mWebApkPackageName;
- public ExternalNavigationDelegateImpl(Tab tab) {
+ /**
+ * Creates instance of a {@link ExternalNavigationDelegateImpl}.
+ * @param tab The associated tab.
+ * @param webApkPackage The package of the WebAPK hosting {@link tab}. Null if
+ * {@link tab} is not hosted by a WebAPK.
+ */
+ public ExternalNavigationDelegateImpl(Tab tab, String webApkPackageName) {
mTab = tab;
+ mWebApkPackageName = webApkPackageName;
mApplicationContext = tab.getWindowAndroid().getApplicationContext();
}
@@ -273,11 +281,16 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
}
@Override
- public String getPackageName() {
+ public String getBrowserPackageName() {
return mApplicationContext.getPackageName();
}
@Override
+ public String getWebApkPackageName() {
+ return mWebApkPackageName;
+ }
+
+ @Override
public void startActivity(Intent intent) {
try {
forcePdfViewerAsIntentHandlerIfNeeded(mApplicationContext, intent);
@@ -396,10 +409,10 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
if (needsToStartIntent) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, getBrowserPackageName());
if (launchIncogntio) intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
- intent.setClassName(getPackageName(), ChromeLauncherActivity.class.getName());
+ intent.setClassName(getBrowserPackageName(), ChromeLauncherActivity.class.getName());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IntentHandler.addTrustedIntentExtras(intent, mApplicationContext);
startActivity(intent);
@@ -432,9 +445,9 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
assert false : "clobberCurrentTab was called with an empty tab.";
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, getBrowserPackageName());
intent.addCategory(Intent.CATEGORY_BROWSABLE);
- intent.setPackage(getPackageName());
+ intent.setPackage(getBrowserPackageName());
startActivity(intent);
return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
}
@@ -459,6 +472,16 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
}
@Override
+ public void startChromeActivity(String url) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, getBrowserPackageName());
+ intent.addCategory(Intent.CATEGORY_BROWSABLE);
+ intent.setClassName(getBrowserPackageName(), ChromeLauncherActivity.class.getName());
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }
+
+ @Override
public String getDefaultSmsPackageName() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return null;
return Telephony.Sms.getDefaultSmsPackage(mApplicationContext);

Powered by Google App Engine
This is Rietveld 408576698