/** * @return Whether or not the Intent corresponds to a DownloadActivity that should show off the * record downloads. */ public static boolean shouldShowOffTheRecordDownloads(Intent intent) { return IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_OFF_THE_RECORD, false); }
/** * Creates a new tab and posts to UI. * * @param loadUrlParams parameters of the url load. * @param type Information about how the tab was launched. * @param parent the parent tab, if present. * @param position the requested position (index in the tab model) * @param intent the source of the url if it isn't null. * @return The new tab. */ public ChromeTab createNewTab( LoadUrlParams loadUrlParams, TabModel.TabLaunchType type, Tab parent, int position, Intent intent) { try { TraceEvent.begin("ChromeTabCreator.createNewTab"); int parentId = parent != null ? parent.getId() : Tab.INVALID_TAB_ID; WebContents webContents = IntentHandler.getWebContentsFromIntent(intent); boolean isWebContentsPaused = false; if (webContents != null) { // The WebContents comes with additional data, but it shouldn't be used if the // WebContents itself couldn't be parsed out. parentId = IntentUtils.safeGetIntExtra( intent, IntentHandler.EXTRA_PARENT_TAB_ID, Tab.INVALID_TAB_ID); isWebContentsPaused = IntentUtils.safeGetBooleanExtra(intent, IntentHandler.EXTRA_WEB_CONTENTS_PAUSED, false); } // Sanitize the url. loadUrlParams.setUrl(UrlUtilities.fixupUrl(loadUrlParams.getUrl())); loadUrlParams.setTransitionType(getTransitionType(type)); boolean openInForeground = mOrderController.willOpenInForeground(type, mIncognito) || webContents != null; ChromeTab tab; if (webContents != null) { tab = ChromeTab.createLiveTab( Tab.INVALID_TAB_ID, mActivity, mIncognito, mNativeWindow, type, parentId, !openInForeground); tab.initialize(webContents, mTabContentManager, !openInForeground); tab.getTabRedirectHandler().updateIntent(intent); if (isWebContentsPaused) webContents.resumeLoadingCreatedWebContents(); } else if (!openInForeground && SysUtils.isLowEndDevice()) { // On low memory devices the tabs opened in background are not loaded automatically // to preserve resources (cpu, memory, strong renderer binding) for the foreground // tab. tab = ChromeTab.createTabForLazyLoad( mActivity, mIncognito, mNativeWindow, type, parentId, loadUrlParams); tab.initialize(null, mTabContentManager, !openInForeground); mTabSaver.addTabToSaveQueue(tab); tab.getTabRedirectHandler().updateIntent(intent); } else { tab = ChromeTab.createLiveTab( Tab.INVALID_TAB_ID, mActivity, mIncognito, mNativeWindow, type, parentId, !openInForeground); webContents = WarmupManager.getInstance().hasPrerenderedUrl(loadUrlParams.getUrl()) ? WarmupManager.getInstance().takePrerenderedWebContents() : null; tab.initialize(webContents, mTabContentManager, !openInForeground); tab.getTabRedirectHandler().updateIntent(intent); tab.loadUrl(loadUrlParams); } if (intent != null && intent.hasExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EXTRA)) { ServiceTabLauncher.onWebContentsForRequestAvailable( intent.getIntExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EXTRA, 0), tab.getWebContents()); } mTabModel.addTab(tab, position, type); return tab; } finally { TraceEvent.end("ChromeTabCreator.createNewTab"); } }