use of org.chromium.chrome.browser.tab.TabDelegateFactory in project AndroidChromium by JackyAndroid.
the class ChromeTabCreator method createNewTab.
/**
* 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.
*/
private Tab 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;
// Sanitize the url.
loadUrlParams.setUrl(UrlFormatter.fixupUrl(loadUrlParams.getUrl()));
loadUrlParams.setTransitionType(getTransitionType(type, intent));
// Check if the tab is being created asynchronously.
int assignedTabId = intent == null ? Tab.INVALID_TAB_ID : IntentUtils.safeGetIntExtra(intent, IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID);
AsyncTabParams asyncParams = AsyncTabParamsManager.remove(assignedTabId);
boolean openInForeground = mOrderController.willOpenInForeground(type, mIncognito);
TabDelegateFactory delegateFactory = parent == null ? createDefaultTabDelegateFactory() : parent.getDelegateFactory();
Tab tab;
if (asyncParams != null && asyncParams.getTabToReparent() != null) {
type = TabLaunchType.FROM_REPARENTING;
openInForeground = true;
TabReparentingParams params = (TabReparentingParams) asyncParams;
tab = params.getTabToReparent();
tab.attachAndFinishReparenting(mActivity, createDefaultTabDelegateFactory(), params);
} else if (asyncParams != null && asyncParams.getWebContents() != null) {
openInForeground = true;
WebContents webContents = asyncParams.getWebContents();
// A WebContents was passed through the Intent. Create a new Tab to hold it.
Intent parentIntent = IntentUtils.safeGetParcelableExtra(intent, IntentHandler.EXTRA_PARENT_INTENT);
parentId = IntentUtils.safeGetIntExtra(intent, IntentHandler.EXTRA_PARENT_TAB_ID, parentId);
assert TabModelUtils.getTabIndexById(mTabModel, assignedTabId) == TabModel.INVALID_TAB_INDEX;
tab = Tab.createLiveTab(assignedTabId, mActivity, mIncognito, mNativeWindow, type, parentId, !openInForeground);
tab.initialize(webContents, mTabContentManager, delegateFactory, !openInForeground, false);
tab.setParentIntent(parentIntent);
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 = Tab.createTabForLazyLoad(mActivity, mIncognito, mNativeWindow, type, parentId, loadUrlParams);
tab.initialize(null, mTabContentManager, delegateFactory, !openInForeground, false);
} else {
tab = Tab.createLiveTab(Tab.INVALID_TAB_ID, mActivity, mIncognito, mNativeWindow, type, parentId, !openInForeground);
tab.initialize(null, mTabContentManager, delegateFactory, !openInForeground, false);
tab.loadUrl(loadUrlParams);
}
tab.getTabRedirectHandler().updateIntent(intent);
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");
}
}
use of org.chromium.chrome.browser.tab.TabDelegateFactory in project AndroidChromium by JackyAndroid.
the class ChromeTabCreator method createTabWithWebContents.
@Override
public boolean createTabWithWebContents(Tab parent, WebContents webContents, int parentId, TabLaunchType type, String url) {
// The parent tab was already closed. Do not open child tabs.
if (mTabModel.isClosurePending(parentId))
return false;
// If parent is in the same tab model, place the new tab next to it.
int position = TabModel.INVALID_TAB_INDEX;
int index = TabModelUtils.getTabIndexById(mTabModel, parentId);
if (index != TabModel.INVALID_TAB_INDEX)
position = index + 1;
boolean openInForeground = mOrderController.willOpenInForeground(type, mIncognito);
TabDelegateFactory delegateFactory = parent == null ? createDefaultTabDelegateFactory() : parent.getDelegateFactory();
Tab tab = Tab.createLiveTab(Tab.INVALID_TAB_ID, mActivity, mIncognito, mNativeWindow, type, parentId, !openInForeground);
tab.initialize(webContents, mTabContentManager, delegateFactory, !openInForeground, false);
mTabModel.addTab(tab, position, type);
return true;
}
Aggregations