Commit 62d16d51 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Prevent offline pages/downloads from sending intents with the .Main alias.

Downloaded an offline page, clicked the infobar, and it crahsed
using this code path.

BUG=789732

Change-Id: I55e18d8b3ab5abe17743f25fe0b090140cb0530f
Reviewed-on: https://chromium-review.googlesource.com/1117213Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570959}
parent 983efdd0
...@@ -358,10 +358,10 @@ public class ChromeTabbedActivity ...@@ -358,10 +358,10 @@ public class ChromeTabbedActivity
* @param component The client generated component to be validated. * @param component The client generated component to be validated.
* @param currentActivity The activity triggering the intent. * @param currentActivity The activity triggering the intent.
*/ */
public static void setNonAliasedComponent( public static void setNonAliasedComponent(Intent intent, ComponentName component) {
Intent intent, ComponentName component, Activity currentActivity) {
assert component != null; assert component != null;
if (!TextUtils.equals(component.getPackageName(), currentActivity.getPackageName())) { Context appContext = ContextUtils.getApplicationContext();
if (!TextUtils.equals(component.getPackageName(), appContext.getPackageName())) {
return; return;
} }
if (component.getClassName() != null if (component.getClassName() != null
...@@ -370,9 +370,9 @@ public class ChromeTabbedActivity ...@@ -370,9 +370,9 @@ public class ChromeTabbedActivity
// Keep in sync with the activities that the .Main alias points to in // Keep in sync with the activities that the .Main alias points to in
// AndroidManifest.xml. // AndroidManifest.xml.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
intent.setClass(currentActivity, ChromeLauncherActivity.class); intent.setClass(appContext, ChromeLauncherActivity.class);
} else { } else {
intent.setClass(currentActivity, ChromeTabbedActivity.class); intent.setClass(appContext, ChromeTabbedActivity.class);
} }
} else { } else {
intent.setComponent(component); intent.setComponent(component);
......
...@@ -290,7 +290,7 @@ public class BookmarkUtils { ...@@ -290,7 +290,7 @@ public class BookmarkUtils {
intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.AUTO_BOOKMARK); intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.AUTO_BOOKMARK);
if (componentName != null) { if (componentName != null) {
ChromeTabbedActivity.setNonAliasedComponent(intent, componentName, activity); ChromeTabbedActivity.setNonAliasedComponent(intent, componentName);
} else { } else {
// If the bookmark manager is shown in a tab on a phone (rather than in a separate // If the bookmark manager is shown in a tab on a phone (rather than in a separate
// activity) the component name may be null. Send the intent through // activity) the component name may be null. Send the intent through
......
...@@ -321,7 +321,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ...@@ -321,7 +321,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
mActivity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT); mActivity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
} }
if (component != null) { if (component != null) {
ChromeTabbedActivity.setNonAliasedComponent(viewIntent, component, mActivity); ChromeTabbedActivity.setNonAliasedComponent(viewIntent, component);
} else { } else {
viewIntent.setClass(mActivity, ChromeLauncherActivity.class); viewIntent.setClass(mActivity, ChromeLauncherActivity.class);
} }
......
...@@ -13,6 +13,7 @@ import android.provider.Browser; ...@@ -13,6 +13,7 @@ import android.provider.Browser;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.ServiceTabLauncher; import org.chromium.chrome.browser.ServiceTabLauncher;
import org.chromium.chrome.browser.TabState; import org.chromium.chrome.browser.TabState;
...@@ -145,7 +146,7 @@ public class TabDelegate extends TabCreator { ...@@ -145,7 +146,7 @@ public class TabDelegate extends TabCreator {
if (componentName == null) { if (componentName == null) {
intent.setClass(ContextUtils.getApplicationContext(), ChromeLauncherActivity.class); intent.setClass(ContextUtils.getApplicationContext(), ChromeLauncherActivity.class);
} else { } else {
intent.setComponent(componentName); ChromeTabbedActivity.setNonAliasedComponent(intent, componentName);
} }
Map<String, String> extraHeaders = asyncParams.getLoadUrlParams().getExtraHeaders(); Map<String, String> extraHeaders = asyncParams.getLoadUrlParams().getExtraHeaders();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment