use of org.chromium.chrome.browser.IntentHandler in project AndroidChromium by JackyAndroid.
the class ChromeLauncherActivity method doOnCreate.
private final void doOnCreate(Bundle savedInstanceState) {
// This Activity is only transient. It launches another activity and
// terminates itself. However, some of the work is performed outside of
// {@link Activity#onCreate()}. To capture this, the TraceEvent starts
// in onCreate(), and ends in onPause().
// Needs to be called as early as possible, to accurately capture the
// time at which the intent was received.
setIntent(IntentUtils.sanitizeIntent(getIntent()));
IntentHandler.addTimestampToIntent(getIntent());
// Initialize the command line in case we've disabled document mode from there.
CommandLineInitUtil.initCommandLine(this, ChromeApplication.COMMAND_LINE_FILE);
// Read partner browser customizations information asynchronously.
// We want to initialize early because when there is no tabs to restore, we should possibly
// show homepage, which might require reading PartnerBrowserCustomizations provider.
PartnerBrowserCustomizations.initializeAsync(getApplicationContext(), PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
recordIntentMetrics();
mIsInLegacyMultiInstanceMode = MultiWindowUtils.getInstance().shouldRunInLegacyMultiInstanceMode(this);
mIntentHandler = new IntentHandler(this, getPackageName());
mIsCustomTabIntent = isCustomTabIntent(getIntent());
if (!mIsCustomTabIntent) {
mIsHerbIntent = isHerbIntent();
mIsCustomTabIntent = mIsHerbIntent;
}
Intent intent = getIntent();
int tabId = IntentUtils.safeGetIntExtra(intent, TabOpenType.BRING_TAB_TO_FRONT.name(), Tab.INVALID_TAB_ID);
boolean incognito = intent.getBooleanExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false);
// Check if this intent was fired at the end of the first run experience and return if
// first run was not successfully completed.
boolean firstRunActivityResult = IntentUtils.safeGetBooleanExtra(intent, FirstRunActivity.EXTRA_FIRST_RUN_ACTIVITY_RESULT, false);
boolean firstRunComplete = IntentUtils.safeGetBooleanExtra(intent, FirstRunActivity.EXTRA_FIRST_RUN_COMPLETE, false);
if (firstRunActivityResult && !firstRunComplete) {
finish();
return;
}
// Check if a web search Intent is being handled.
String url = IntentHandler.getUrlFromIntent(intent);
if (url == null && tabId == Tab.INVALID_TAB_ID && !incognito && mIntentHandler.handleWebSearchIntent(intent)) {
finish();
return;
}
// https://crbug.com/443772, https://crbug.com/522918
if (WebappLauncherActivity.bringWebappToFront(tabId)) {
ApiCompatibilityUtils.finishAndRemoveTask(this);
return;
}
// Settings "App Notifications" view will open us with a specific category.
if (intent.hasCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES)) {
NotificationPlatformBridge.launchNotificationPreferences(this, getIntent());
finish();
return;
}
// Check if we should launch an Instant App to handle the intent.
if (InstantAppsHandler.getInstance().handleIncomingIntent(this, intent, mIsCustomTabIntent && !mIsHerbIntent)) {
finish();
return;
}
// Check if we should launch the ChromeTabbedActivity.
if (!mIsCustomTabIntent && !FeatureUtilities.isDocumentMode(this)) {
boolean checkedFre = false;
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
// ChromeTabbedActivity if necessary.
if (getIntent() != null && getIntent().getAction() == Intent.ACTION_VIEW && IntentHandler.getUrlFromIntent(getIntent()) != null) {
if (launchFirstRunExperience(true)) {
finish();
return;
}
checkedFre = true;
}
}
launchTabbedMode(checkedFre);
finish();
return;
}
// ChromeTabbedActivity because ChromeTabbedActivity handles FRE in its own way.
if (launchFirstRunExperience(false)) {
finish();
return;
}
// Check if we should launch a Custom Tab.
if (mIsCustomTabIntent) {
launchCustomTabActivity();
finish();
return;
}
// Force a user to migrate to document mode, if necessary.
if (DocumentModeAssassin.getInstance().isMigrationNecessary()) {
Log.d(TAG, "Diverting to UpgradeActivity via ChromeLauncherActivity.");
UpgradeActivity.launchInstance(this, intent);
ApiCompatibilityUtils.finishAndRemoveTask(this);
return;
}
// All possible bounces to other activities should have already been enumerated above.
Log.e(TAG, "User wasn't sent to another Activity.");
assert false;
ApiCompatibilityUtils.finishAndRemoveTask(this);
}
Aggregations