Search in sources :

Example 6 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class ContextualSearchManager method openResolvedSearchUrlInNewTab.

@Override
public void openResolvedSearchUrlInNewTab() {
    if (mSearchRequest != null && mSearchRequest.getSearchUrlForPromotion() != null) {
        TabModelSelector tabModelSelector = mActivity.getTabModelSelector();
        tabModelSelector.openNewTab(new LoadUrlParams(mSearchRequest.getSearchUrlForPromotion()), TabLaunchType.FROM_LINK, tabModelSelector.getCurrentTab(), tabModelSelector.isIncognitoSelected());
    }
}
Also used : TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 7 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class RecentTabsManager method openHistoryPage.

/**
     * Opens the history page.
     */
public void openHistoryPage() {
    if (mIsDestroyed)
        return;
    mTab.loadUrl(new LoadUrlParams(UrlConstants.HISTORY_URL));
    StartupMetrics.getInstance().recordOpenedHistory();
}
Also used : LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 8 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class CustomTabActivity method loadUrlInTab.

/**
     * Loads the current tab with the given load params while taking client
     * referrer and extra headers into account.
     */
private void loadUrlInTab(final Tab tab, final LoadUrlParams params, long timeStamp) {
    Intent intent = getIntent();
    String url = getUrlToLoad();
    if (mHasPrerendered && UrlUtilities.urlsFragmentsDiffer(mPrerenderedUrl, url)) {
        mHasPrerendered = false;
        LoadUrlParams temporaryParams = new LoadUrlParams(mPrerenderedUrl);
        IntentHandler.addReferrerAndHeaders(temporaryParams, intent, this);
        tab.loadUrl(temporaryParams);
        params.setShouldReplaceCurrentEntry(true);
    }
    IntentHandler.addReferrerAndHeaders(params, intent, this);
    if (params.getReferrer() == null) {
        params.setReferrer(CustomTabsConnection.getInstance(getApplication()).getReferrerForSession(mSession));
    }
    // See ChromeTabCreator#getTransitionType(). This marks the navigation chain as starting
    // from an external intent (unless otherwise specified by an extra in the intent).
    params.setTransitionType(IntentHandler.getTransitionTypeFromIntent(this, intent, PageTransition.LINK | PageTransition.FROM_API));
    mTabObserver.trackNextPageLoadFromTimestamp(timeStamp);
    tab.loadUrl(params);
}
Also used : CustomTabsIntent(android.support.customtabs.CustomTabsIntent) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 9 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class DataUseTabUIManager method startDataUseDialog.

/**
     * Shows a dialog with the option to cancel the navigation or continue. Also allows the user to
     * opt out of seeing this dialog again.
     *
     * @param activity Current activity.
     * @param tab The tab loading the url.
     * @param url URL that is pending.
     * @param pageTransitionType The type of transition. see
     *            {@link org.chromium.content.browser.PageTransition} for valid values.
     * @param referrerUrl URL for the referrer.
     */
private static void startDataUseDialog(final Activity activity, final Tab tab, final String url, final int pageTransitionType, final String referrerUrl) {
    View dataUseDialogView = View.inflate(activity, R.layout.data_use_dialog, null);
    final TextView textView = (TextView) dataUseDialogView.findViewById(R.id.data_use_message);
    textView.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_MESSAGE));
    final CheckBox checkBox = (CheckBox) dataUseDialogView.findViewById(R.id.data_use_checkbox);
    checkBox.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CHECKBOX_MESSAGE));
    View learnMore = dataUseDialogView.findViewById(R.id.learn_more);
    learnMore.setOnClickListener(new android.view.View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EmbedContentViewActivity.show(activity, getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_TITLE), getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_LINK_URL));
            recordDataUseUIAction(DataUsageUIAction.DIALOG_LEARN_MORE_CLICKED);
        }
    });
    new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setTitle(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_TITLE)).setView(dataUseDialogView).setPositiveButton(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CONTINUE), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
            LoadUrlParams loadUrlParams = new LoadUrlParams(url, pageTransitionType);
            if (!TextUtils.isEmpty(referrerUrl)) {
                Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
                loadUrlParams.setReferrer(referrer);
            }
            tab.loadUrl(loadUrlParams);
            recordDataUseUIAction(DataUsageUIAction.DIALOG_CONTINUE_CLICKED);
            userClickedContinueOnDialogBox(tab);
        }
    }).setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
            recordDataUseUIAction(DataUsageUIAction.DIALOG_CANCEL_CLICKED);
        }
    }).show();
    recordDataUseUIAction(DataUsageUIAction.DIALOG_SHOWN);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) TextView(android.widget.TextView) View(android.view.View) CheckBox(android.widget.CheckBox) Referrer(org.chromium.content_public.common.Referrer) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 10 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class CustomTabActivity method preInflationStartup.

@Override
public void preInflationStartup() {
    super.preInflationStartup();
    mIntentDataProvider = new CustomTabIntentDataProvider(getIntent(), this);
    mSession = mIntentDataProvider.getSession();
    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    mHasPrerender = !TextUtils.isEmpty(CustomTabsConnection.getInstance(getApplication()).getPrerenderedUrl(mSession));
    if (getSavedInstanceState() == null && CustomTabsConnection.hasWarmUpBeenFinished(getApplication())) {
        mMainTab = createMainTab();
        loadUrlInTab(mMainTab, new LoadUrlParams(getUrlToLoad()), IntentHandler.getTimestampFromIntent(getIntent()));
        mHasCreatedTabEarly = true;
    }
}
Also used : LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Aggregations

LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)35 Tab (org.chromium.chrome.browser.tab.Tab)9 Intent (android.content.Intent)6 Referrer (org.chromium.content_public.common.Referrer)5 TabDelegate (org.chromium.chrome.browser.tabmodel.document.TabDelegate)4 PendingIntent (android.app.PendingIntent)3 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)3 Context (android.content.Context)2 CustomTabsSessionToken (android.support.customtabs.CustomTabsSessionToken)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 CalledByNative (org.chromium.base.annotations.CalledByNative)2 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)2 AsyncTabCreationParams (org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams)2 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 SharedPreferences (android.content.SharedPreferences)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 SparseIntArray (android.util.SparseIntArray)1