use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class Tab method openNewTab.
@CalledByNative
protected void openNewTab(String url, String extraHeaders, ResourceRequestBody postData, int disposition, boolean hasParent, boolean isRendererInitiated) {
if (isClosing())
return;
boolean incognito = isIncognito();
TabLaunchType tabLaunchType = TabLaunchType.FROM_LONGPRESS_FOREGROUND;
Tab parentTab = hasParent ? this : null;
switch(disposition) {
// fall through
case WindowOpenDisposition.NEW_WINDOW:
case WindowOpenDisposition.NEW_FOREGROUND_TAB:
break;
// fall through
case WindowOpenDisposition.NEW_POPUP:
case WindowOpenDisposition.NEW_BACKGROUND_TAB:
tabLaunchType = TabLaunchType.FROM_LONGPRESS_BACKGROUND;
break;
case WindowOpenDisposition.OFF_THE_RECORD:
assert incognito;
incognito = true;
break;
default:
assert false;
}
// is not accessible, then we can't open a new tab.
if (shouldIgnoreNewTab(url, incognito) || getTabModelSelector() == null)
return;
LoadUrlParams loadUrlParams = new LoadUrlParams(url);
loadUrlParams.setVerbatimHeaders(extraHeaders);
loadUrlParams.setPostData(postData);
loadUrlParams.setIsRendererInitiated(isRendererInitiated);
getTabModelSelector().openNewTab(loadUrlParams, tabLaunchType, parentTab, incognito);
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class Tab method unfreezeContents.
/**
* Restores the WebContents from its saved state. This should only be called if the tab is
* frozen with a saved TabState, and NOT if it was frozen for a lazy load.
* @return Whether or not the restoration was successful.
*/
protected boolean unfreezeContents() {
try {
TraceEvent.begin("Tab.unfreezeContents");
assert mFrozenContentsState != null;
assert getContentViewCore() == null;
WebContents webContents = mFrozenContentsState.restoreContentsFromByteBuffer(isHidden());
if (webContents == null) {
// State restore failed, just create a new empty web contents as that is the best
// that can be done at this point. TODO(jcivelli) http://b/5910521 - we should show
// an error page instead of a blank page in that case (and the last loaded URL).
webContents = WebContentsFactory.createWebContents(isIncognito(), isHidden());
mTabUma = new TabUma(TabCreationState.FROZEN_ON_RESTORE_FAILED);
mFailedToRestore = true;
}
mFrozenContentsState = null;
initContentViewCore(webContents);
if (mFailedToRestore) {
String url = TextUtils.isEmpty(mUrl) ? UrlConstants.NTP_URL : mUrl;
loadUrl(new LoadUrlParams(url, PageTransition.GENERATED));
}
return !mFailedToRestore;
} finally {
TraceEvent.end("Tab.unfreezeContents");
}
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class TabContextMenuItemDelegate method onOpenInOtherWindow.
@Override
public void onOpenInOtherWindow(String url, Referrer referrer) {
TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito());
LoadUrlParams loadUrlParams = new LoadUrlParams(url);
loadUrlParams.setReferrer(referrer);
tabDelegate.createTabInOtherWindow(loadUrlParams, mTab.getActivity(), mTab.getParentId());
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class ToolbarManager method openHomepage.
@Override
public void openHomepage() {
RecordUserAction.record("Home");
Tab currentTab = mToolbarModel.getTab();
if (currentTab == null)
return;
Context context = mToolbar.getContext();
String homePageUrl = HomepageManager.getHomepageUri(context);
if (TextUtils.isEmpty(homePageUrl)) {
homePageUrl = UrlConstants.NTP_URL;
}
currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE));
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class FullScreenActivity method preInflationStartup.
@Override
public void preInflationStartup() {
super.preInflationStartup();
setTabCreators(createTabDelegate(false), createTabDelegate(true));
setTabModelSelector(new SingleTabModelSelector(this, false, false) {
@Override
public Tab openNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent, boolean incognito) {
getTabCreator(incognito).createNewTab(loadUrlParams, type, parent);
return null;
}
});
}
Aggregations