use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class OverlayPanelContent method loadUrl.
// ============================================================================================
// ContentViewCore related
// ============================================================================================
/**
* Load a URL; this will trigger creation of a new ContentViewCore if being loaded immediately,
* otherwise one is created when the panel's content becomes visible.
* @param url The URL that should be loaded.
* @param shouldLoadImmediately If a URL should be loaded immediately or wait until visibility
* changes.
*/
public void loadUrl(String url, boolean shouldLoadImmediately) {
mPendingUrl = null;
if (!shouldLoadImmediately) {
mPendingUrl = url;
} else {
createNewContentView();
mLoadedUrl = url;
mDidStartLoadingUrl = true;
mIsProcessingPendingNavigation = true;
if (!mContentDelegate.handleInterceptLoadUrl(mContentViewCore, url)) {
mContentViewCore.getWebContents().getNavigationController().loadUrl(new LoadUrlParams(url));
}
}
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class DownloadUtils method showDownloadManager.
/**
* Displays the download manager UI. Note the UI is different on tablets and on phones.
* @return Whether the UI was shown.
*/
public static boolean showDownloadManager(@Nullable Activity activity, @Nullable Tab tab) {
if (!isDownloadHomeEnabled())
return false;
// Figure out what tab was last being viewed by the user.
if (activity == null)
activity = ApplicationStatus.getLastTrackedFocusedActivity();
if (tab == null && activity instanceof ChromeTabbedActivity) {
tab = ((ChromeTabbedActivity) activity).getActivityTab();
}
Context appContext = ContextUtils.getApplicationContext();
if (DeviceFormFactor.isTablet(appContext)) {
// Download Home shows up as a tab on tablets.
LoadUrlParams params = new LoadUrlParams(UrlConstants.DOWNLOADS_URL);
if (tab == null || !tab.isInitialized()) {
// Open a new tab, which pops Chrome into the foreground.
TabDelegate delegate = new TabDelegate(false);
delegate.createNewTab(params, TabLaunchType.FROM_CHROME_UI, null);
} else {
// Download Home shows up inside an existing tab, but only if the last Activity was
// the ChromeTabbedActivity.
tab.loadUrl(params);
// Bring Chrome to the foreground, if possible.
Intent intent = Tab.createBringTabToFrontIntent(tab.getId());
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IntentUtils.safeStartActivity(appContext, intent);
}
}
} else {
// Download Home shows up as a new Activity on phones.
Intent intent = new Intent();
intent.setClass(appContext, DownloadActivity.class);
if (tab != null)
intent.putExtra(EXTRA_IS_OFF_THE_RECORD, tab.isIncognito());
if (activity == null) {
// Stands alone in its own task.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
appContext.startActivity(intent);
} else {
// Sits on top of another Activity.
intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
activity.startActivity(intent);
}
}
return true;
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class ExternalNavigationDelegateImpl method clobberCurrentTab.
@Override
public OverrideUrlLoadingResult clobberCurrentTab(String url, String referrerUrl, Tab tab) {
int transitionType = PageTransition.LINK;
LoadUrlParams loadUrlParams = new LoadUrlParams(url, transitionType);
if (!TextUtils.isEmpty(referrerUrl)) {
Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
loadUrlParams.setReferrer(referrer);
}
if (tab != null) {
tab.loadUrl(loadUrlParams);
return OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB;
} else {
assert false : "clobberCurrentTab was called with an empty tab.";
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setPackage(getPackageName());
startActivity(intent, false);
return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
}
}
use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.
the class WebappActivity method initializeUI.
private void initializeUI(Bundle savedInstanceState) {
// We do not load URL when restoring from saved instance states.
if (savedInstanceState == null && mWebappInfo.isInitialized()) {
if (TextUtils.isEmpty(getActivityTab().getUrl())) {
getActivityTab().loadUrl(new LoadUrlParams(mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEVEL));
}
} else {
if (NetworkChangeNotifier.isOnline())
getActivityTab().reloadIgnoringCache();
}
getActivityTab().addObserver(createTabObserver());
getActivityTab().getTabWebContentsDelegateAndroid().setDisplayMode(WebDisplayMode.Standalone);
// TODO(dominickn): send the web app into fullscreen if mDisplayMode is
// WebDisplayMode.Fullscreen. See crbug.com/581522
}
Aggregations