Java Code Examples for org.chromium.ui.base.PageTransition

The following examples show how to use org.chromium.ui.base.PageTransition. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: delion   Source File: EmbedContentViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    super.finishNativeInitialization();
    getSupportActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);

    final String titleRes = getIntent().getStringExtra(TITLE_INTENT_EXTRA);
    if (titleRes != null) {
        setTitle(titleRes);
    }

    final String urlRes = getIntent().getStringExtra(URL_INTENT_EXTRA);
    if (urlRes != null) {
        getActivityTab().loadUrl(new LoadUrlParams(urlRes, PageTransition.AUTO_TOPLEVEL));
    }
}
 
Example 2
Source Project: delion   Source File: CustomTabActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source Project: delion   Source File: LocationBarLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onIntentCompleted(WindowAndroid window, int resultCode,
        ContentResolver contentResolver, Intent data) {
    if (resultCode != Activity.RESULT_OK) return;
    if (data.getExtras() == null) return;

    VoiceResult topResult = mAutocomplete.onVoiceResults(data.getExtras());
    if (topResult == null) return;

    String topResultQuery = topResult.getMatch();
    if (TextUtils.isEmpty(topResultQuery)) return;

    if (topResult.getConfidence() < VOICE_SEARCH_CONFIDENCE_NAVIGATE_THRESHOLD) {
        setSearchQuery(topResultQuery);
        return;
    }

    String url = AutocompleteController.nativeQualifyPartialURLQuery(topResultQuery);
    if (url == null) {
        url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(
                topResultQuery);
    }
    loadUrl(url, PageTransition.TYPED);
}
 
Example 4
Source Project: delion   Source File: NewTabPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLogoClicked(boolean isAnimatedLogoShowing) {
    if (mIsDestroyed) return;

    if (!isAnimatedLogoShowing && mAnimatedLogoUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME, CTA_IMAGE_CLICKED);
        mNewTabPageView.showLogoLoadingView();
        mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback() {
            @Override
            public void onAnimatedLogoAvailable(BaseGifImage animatedLogoImage) {
                if (mIsDestroyed) return;
                mNewTabPageView.playAnimatedLogo(animatedLogoImage);
            }
        }, mAnimatedLogoUrl);
    } else if (mOnLogoClickUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME,
                isAnimatedLogoShowing ? ANIMATED_LOGO_CLICKED : STATIC_LOGO_CLICKED);
        mTab.loadUrl(new LoadUrlParams(mOnLogoClickUrl, PageTransition.LINK));
    }
}
 
Example 5
Source Project: delion   Source File: Tab.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Update internal Tab state when provisional load gets committed.
 * @param url The URL that was loaded.
 * @param transitionType The transition type to the current URL.
 */
void handleDidCommitProvisonalLoadForFrame(String url, int transitionType) {
    mIsNativePageCommitPending = false;
    boolean isReload = (transitionType == PageTransition.RELOAD);
    if (!maybeShowNativePage(url, isReload)) {
        showRenderedPage();
    }

    mHandler.removeMessages(MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD);
    mHandler.sendEmptyMessageDelayed(
            MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD, MAX_FULLSCREEN_LOAD_DELAY_MS);
    updateFullscreenEnabledState();

    if (getInterceptNavigationDelegate() != null) {
        getInterceptNavigationDelegate().maybeUpdateNavigationHistory();
    }
}
 
Example 6
Source Project: delion   Source File: WebApkActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // We could bring a WebAPK hosted WebappActivity to foreground and navigate it to a
    // different URL. For example, WebAPK "foo" is launched and navigates to
    // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search
    // results. After clicking the link, WebAPK "foo" is brought to foreground, and
    // loads the page of "www.foo.com/bar" at the same time.
    // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will
    // navigate to.
    String overrideUrl = intent.getStringExtra(ShortcutHelper.EXTRA_URL);
    if (overrideUrl != null && isInitialized()
            && !overrideUrl.equals(getActivityTab().getUrl())) {
        getActivityTab().loadUrl(
                new LoadUrlParams(overrideUrl, PageTransition.AUTO_TOPLEVEL));
    }
}
 
Example 7
Source Project: delion   Source File: WebappActivity.java    License: Apache License 2.0 6 votes vote down vote up
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
}
 
Example 8
Source Project: AndroidChromium   Source File: EmbedContentViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    super.finishNativeInitialization();
    getSupportActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);

    final String titleRes = getIntent().getStringExtra(TITLE_INTENT_EXTRA);
    if (titleRes != null) {
        setTitle(titleRes);
    }

    final String urlRes = getIntent().getStringExtra(URL_INTENT_EXTRA);
    if (urlRes != null) {
        getActivityTab().loadUrl(new LoadUrlParams(urlRes, PageTransition.AUTO_TOPLEVEL));
    }
}
 
Example 9
Source Project: AndroidChromium   Source File: BookmarkUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static void openUrl(Activity activity, String url, ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.putExtra(Browser.EXTRA_APPLICATION_ID,
            activity.getApplicationContext().getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.AUTO_BOOKMARK);

    if (componentName != null) {
        intent.setComponent(componentName);
    } else {
        // If the bookmark manager is shown in a tab on a phone (rather than in a separate
        // activity) the component name may be null. Send the intent through
        // ChromeLauncherActivity instead to avoid crashing. See crbug.com/615012.
        intent.setClass(activity, ChromeLauncherActivity.class);
    }

    IntentHandler.startActivityForTrustedIntent(intent, activity);
}
 
Example 10
Source Project: AndroidChromium   Source File: ChromeActionModeCallback.java    License: Apache License 2.0 6 votes vote down vote up
private void search() {
    RecordUserAction.record("MobileActionMode.WebSearch");
    if (mTab.getTabModelSelector() == null) return;

    String query = mHelper.sanitizeQuery(mHelper.getSelectedText(),
            ActionModeCallbackHelper.MAX_SEARCH_QUERY_LENGTH);
    if (TextUtils.isEmpty(query)) return;

    String url = TemplateUrlService.getInstance().getUrlForSearchQuery(query);
    String headers = GeolocationHeader.getGeoHeader(mContext.getApplicationContext(),
            url, mTab.isIncognito());

    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setVerbatimHeaders(headers);
    loadUrlParams.setTransitionType(PageTransition.GENERATED);
    mTab.getTabModelSelector().openNewTab(loadUrlParams,
            TabLaunchType.FROM_LONGPRESS_FOREGROUND, mTab, mTab.isIncognito());
}
 
Example 11
Source Project: AndroidChromium   Source File: CustomTabActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source Project: AndroidChromium   Source File: LocationBarLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onIntentCompleted(WindowAndroid window, int resultCode,
        ContentResolver contentResolver, Intent data) {
    if (resultCode != Activity.RESULT_OK) return;
    if (data.getExtras() == null) return;

    VoiceResult topResult = mAutocomplete.onVoiceResults(data.getExtras());
    if (topResult == null) return;

    String topResultQuery = topResult.getMatch();
    if (TextUtils.isEmpty(topResultQuery)) return;

    if (topResult.getConfidence() < VOICE_SEARCH_CONFIDENCE_NAVIGATE_THRESHOLD) {
        setSearchQuery(topResultQuery);
        return;
    }

    String url = AutocompleteController.nativeQualifyPartialURLQuery(topResultQuery);
    if (url == null) {
        url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(
                topResultQuery);
    }
    loadUrl(url, PageTransition.TYPED);
}
 
Example 13
Source Project: AndroidChromium   Source File: NewTabPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLogoClicked(boolean isAnimatedLogoShowing) {
    if (mIsDestroyed) return;

    if (!isAnimatedLogoShowing && mAnimatedLogoUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME, CTA_IMAGE_CLICKED);
        mNewTabPageView.showLogoLoadingView();
        mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback() {
            @Override
            public void onAnimatedLogoAvailable(BaseGifImage animatedLogoImage) {
                if (mIsDestroyed) return;
                mNewTabPageView.playAnimatedLogo(animatedLogoImage);
            }
        }, mAnimatedLogoUrl);
    } else if (mOnLogoClickUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME,
                isAnimatedLogoShowing ? ANIMATED_LOGO_CLICKED : STATIC_LOGO_CLICKED);
        mTab.loadUrl(new LoadUrlParams(mOnLogoClickUrl, PageTransition.LINK));
    }
}
 
Example 14
Source Project: AndroidChromium   Source File: TabBlimpContentsObserver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This method is used to update the status of progress bar.
 */
@Override
public void onPageLoadingStateChanged(boolean loading) {
    mPageIsLoading = loading;
    if (loading) {
        mTab.didStartPageLoad(mTab.getUrl(), false);

        // Simulate provisional load start and completion events.
        mTab.handleDidStartProvisionalLoadForFrame(true, mTab.getUrl());

        // TODO(dtrainor): Investigate if we need to pipe through a more accurate PageTransition
        // here.
        mTab.handleDidCommitProvisonalLoadForFrame(mTab.getUrl(), PageTransition.TYPED);

        // Currently, blimp doesn't have a way to calculate the progress. So we are sending a
        // fake progress value.
        mTab.notifyLoadProgress(30);
    } else {
        mTab.notifyLoadProgress(100);
        mTab.didFinishPageLoad();
    }
}
 
Example 15
Source Project: AndroidChromium   Source File: WebApkActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // We could bring a WebAPK hosted WebappActivity to foreground and navigate it to a
    // different URL. For example, WebAPK "foo" is launched and navigates to
    // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search
    // results. After clicking the link, WebAPK "foo" is brought to foreground, and
    // loads the page of "www.foo.com/bar" at the same time.
    // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will
    // navigate to.
    String overrideUrl = intent.getStringExtra(ShortcutHelper.EXTRA_URL);
    if (overrideUrl != null && isInitialized()
            && !overrideUrl.equals(getActivityTab().getUrl())) {
        getActivityTab().loadUrl(
                new LoadUrlParams(overrideUrl, PageTransition.AUTO_TOPLEVEL));
    }
}
 
Example 16
Source Project: AndroidChromium   Source File: WebappActivity.java    License: Apache License 2.0 6 votes vote down vote up
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
}
 
Example 17
Source Project: 365browser   Source File: BookmarkUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static void openUrl(Activity activity, String url, ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.putExtra(Browser.EXTRA_APPLICATION_ID,
            activity.getApplicationContext().getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.AUTO_BOOKMARK);

    if (componentName != null) {
        intent.setComponent(componentName);
    } else {
        // If the bookmark manager is shown in a tab on a phone (rather than in a separate
        // activity) the component name may be null. Send the intent through
        // ChromeLauncherActivity instead to avoid crashing. See crbug.com/615012.
        intent.setClass(activity, ChromeLauncherActivity.class);
    }

    IntentHandler.startActivityForTrustedIntent(intent);
}
 
Example 18
Source Project: 365browser   Source File: ChromeActionModeCallback.java    License: Apache License 2.0 6 votes vote down vote up
private void search() {
    RecordUserAction.record("MobileActionMode.WebSearch");
    if (mTab.getTabModelSelector() == null) return;

    String query = ActionModeCallbackHelper.sanitizeQuery(mHelper.getSelectedText(),
            ActionModeCallbackHelper.MAX_SEARCH_QUERY_LENGTH);
    if (TextUtils.isEmpty(query)) return;

    String url = TemplateUrlService.getInstance().getUrlForSearchQuery(query);
    String headers = GeolocationHeader.getGeoHeader(url, mTab);

    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setVerbatimHeaders(headers);
    loadUrlParams.setTransitionType(PageTransition.GENERATED);
    mTab.getTabModelSelector().openNewTab(loadUrlParams,
            TabLaunchType.FROM_LONGPRESS_FOREGROUND, mTab, mTab.isIncognito());
}
 
Example 19
Source Project: 365browser   Source File: LocationBarLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onIntentCompleted(WindowAndroid window, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) return;
    if (data.getExtras() == null) return;

    VoiceResult topResult = mAutocomplete.onVoiceResults(data.getExtras());
    if (topResult == null) return;

    String topResultQuery = topResult.getMatch();
    if (TextUtils.isEmpty(topResultQuery)) return;

    if (topResult.getConfidence() < VOICE_SEARCH_CONFIDENCE_NAVIGATE_THRESHOLD) {
        setSearchQuery(topResultQuery);
        return;
    }

    String url = AutocompleteController.nativeQualifyPartialURLQuery(topResultQuery);
    if (url == null) {
        url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(
                topResultQuery);
    }
    loadUrl(url, PageTransition.TYPED);
}
 
Example 20
Source Project: 365browser   Source File: LogoDelegateImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLogoClicked(boolean isAnimatedLogoShowing) {
    if (mIsDestroyed) return;

    if (!isAnimatedLogoShowing && mAnimatedLogoUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME, CTA_IMAGE_CLICKED);
        mLogoView.showLoadingView();
        mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback() {
            @Override
            public void onAnimatedLogoAvailable(BaseGifImage animatedLogoImage) {
                if (mIsDestroyed) return;
                mLogoView.playAnimatedLogo(animatedLogoImage);
            }
        }, mAnimatedLogoUrl);
    } else if (mOnLogoClickUrl != null) {
        RecordHistogram.recordSparseSlowlyHistogram(LOGO_CLICK_UMA_NAME,
                isAnimatedLogoShowing ? ANIMATED_LOGO_CLICKED : STATIC_LOGO_CLICKED);
        mTab.loadUrl(new LoadUrlParams(mOnLogoClickUrl, PageTransition.LINK));
    }
}
 
Example 21
Source Project: delion   Source File: ReaderModeManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Open a link from the panel in a new tab.
 * @param url The URL to load.
 */
public void createNewTab(String url) {
    if (mChromeActivity == null) return;

    Tab currentTab = mTabModelSelector.getCurrentTab();
    if (currentTab == null) return;

    TabCreatorManager.TabCreator tabCreator =
            mChromeActivity.getTabCreator(currentTab.isIncognito());
    if (tabCreator == null) return;

    tabCreator.createNewTab(new LoadUrlParams(url, PageTransition.LINK),
            TabModel.TabLaunchType.FROM_LINK, mChromeActivity.getActivityTab());
}
 
Example 22
Source Project: delion   Source File: TabDelegate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean createTabWithWebContents(Tab parent, WebContents webContents, int parentId,
        TabLaunchType type, String url) {
    if (url == null) url = "";

    AsyncTabCreationParams asyncParams =
            new AsyncTabCreationParams(
                    new LoadUrlParams(url, PageTransition.AUTO_TOPLEVEL), webContents);
    createNewTab(asyncParams, type, parentId);
    return true;
}
 
Example 23
Source Project: delion   Source File: LocationBarLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Performs a search query on the current {@link Tab}.  This calls
 * {@link TemplateUrlService#getUrlForSearchQuery(String)} to get a url based on {@code query}
 * and loads that url in the current {@link Tab}.
 * @param query The {@link String} that represents the text query that should be searched for.
 */
@VisibleForTesting
public void performSearchQueryForTest(String query) {
    if (TextUtils.isEmpty(query)) return;

    String queryUrl = TemplateUrlService.getInstance().getUrlForSearchQuery(query);

    if (!TextUtils.isEmpty(queryUrl)) {
        loadUrl(queryUrl, PageTransition.GENERATED);
    } else {
        setSearchQuery(query);
    }
}
 
Example 24
Source Project: delion   Source File: NewTabPageUma.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Record that the user has navigated away from the NTP using the omnibox.
 * @param destinationUrl The URL to which the user navigated.
 * @param transitionType The transition type of the navigation, from PageTransition.java.
 */
public static void recordOmniboxNavigation(String destinationUrl, int transitionType) {
    if ((transitionType & PageTransition.CORE_MASK) == PageTransition.GENERATED) {
        recordAction(ACTION_SEARCHED_USING_OMNIBOX);
    } else {
        if (UrlUtilities.nativeIsGoogleHomePageUrl(destinationUrl)) {
            recordAction(ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE);
        } else {
            recordAction(ACTION_NAVIGATED_USING_OMNIBOX);
        }
        recordExplicitUserNavigation(destinationUrl, RAPPOR_ACTION_NAVIGATED_USING_OMNIBOX);
    }
}
 
Example 25
Source Project: delion   Source File: NewTabPageUma.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
    // End recording if a new URL gets loaded e.g. after entering a new query in
    // the omnibox. This doesn't cover the nagivate-back case so we also need
    // onUpdateUrl.
    int transitionTypeMask = PageTransition.FROM_ADDRESS_BAR | PageTransition.HOME_PAGE
            | PageTransition.CHAIN_START | PageTransition.CHAIN_END;

    if ((params.getTransitionType() & transitionTypeMask) != 0) endRecording(tab);
}
 
Example 26
Source Project: delion   Source File: TabContextMenuItemDelegate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onOpenImageUrl(String url, Referrer referrer) {
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setTransitionType(PageTransition.LINK);
    loadUrlParams.setReferrer(referrer);
    mTab.loadUrl(loadUrlParams);
}
 
Example 27
Source Project: delion   Source File: Tab.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void performWebSearch(String searchQuery) {
    if (TextUtils.isEmpty(searchQuery)) return;
    if (getTabModelSelector() == null) return;
    String url = TemplateUrlService.getInstance().getUrlForSearchQuery(searchQuery);
    String headers = GeolocationHeader.getGeoHeader(getApplicationContext(), url,
            isIncognito());

    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setVerbatimHeaders(headers);
    loadUrlParams.setTransitionType(PageTransition.GENERATED);
    getTabModelSelector().openNewTab(loadUrlParams,
            TabLaunchType.FROM_LONGPRESS_FOREGROUND, Tab.this, isIncognito());
}
 
Example 28
Source Project: delion   Source File: Tab.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Causes this tab to navigate to the specified URL.
 * @param params parameters describing the url load. Note that it is important to set correct
 *               page transition as it is used for ranking URLs in the history so the omnibox
 *               can report suggestions correctly.
 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if the page has been
 *         prerendered. DEFAULT_PAGE_LOAD if it had not.
 */
public int loadUrl(LoadUrlParams params) {
    try {
        TraceEvent.begin("Tab.loadUrl");
        // TODO(tedchoc): When showing the android NTP, delay the call to nativeLoadUrl until
        //                the android view has entirely rendered.
        if (!mIsNativePageCommitPending) {
            mIsNativePageCommitPending = maybeShowNativePage(params.getUrl(), false);
        }

        removeSadTabIfPresent();

        // Clear the app association if the user navigated to a different page from the omnibox.
        if ((params.getTransitionType() & PageTransition.FROM_ADDRESS_BAR)
                == PageTransition.FROM_ADDRESS_BAR) {
            mAppAssociatedWith = null;
            setIsAllowedToReturnToExternalApp(false);
        }

        // We load the URL from the tab rather than directly from the ContentView so the tab has
        // a chance of using a prerenderer page is any.
        int loadType = nativeLoadUrl(mNativeTabAndroid, params.getUrl(),
                params.getVerbatimHeaders(), params.getPostData(), params.getTransitionType(),
                params.getReferrer() != null ? params.getReferrer().getUrl() : null,
                // Policy will be ignored for null referrer url, 0 is just a placeholder.
                // TODO(ppi): Should we pass Referrer jobject and add JNI methods to read it
                //            from the native?
                params.getReferrer() != null ? params.getReferrer().getPolicy() : 0,
                params.getIsRendererInitiated(), params.getShouldReplaceCurrentEntry(),
                params.getIntentReceivedTimestamp(), params.getHasUserGesture());

        for (TabObserver observer : mObservers) {
            observer.onLoadUrl(this, params, loadType);
        }
        return loadType;
    } finally {
        TraceEvent.end("Tab.loadUrl");
    }
}
 
Example 29
Source Project: delion   Source File: ToolbarManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void openHomepage() {
    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));
}
 
Example 30
Source Project: delion   Source File: ChromeActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createContextualSearchTab(String searchUrl) {
    Tab currentTab = getActivityTab();
    if (currentTab == null) return;

    TabCreator tabCreator = getTabCreator(currentTab.isIncognito());
    if (tabCreator == null) return;

    tabCreator.createNewTab(
            new LoadUrlParams(searchUrl, PageTransition.LINK),
            TabModel.TabLaunchType.FROM_LINK, getActivityTab());
}