org.chromium.ui.base.PageTransition Java Examples

The following examples show how to use org.chromium.ui.base.PageTransition. 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 File: WebApkActivity.java    From delion with 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 #2
Source File: LocationBarLayout.java    From 365browser with 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 #3
Source File: LocationBarLayout.java    From delion with 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 File: CustomTabActivity.java    From delion with 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 #5
Source File: NewTabPage.java    From delion with 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 #6
Source File: LogoDelegateImpl.java    From 365browser with 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 #7
Source File: ChromeActionModeCallback.java    From 365browser with 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 #8
Source File: BookmarkUtils.java    From 365browser with 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 #9
Source File: Tab.java    From delion with 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 #10
Source File: WebappActivity.java    From delion with 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 #11
Source File: EmbedContentViewActivity.java    From AndroidChromium with 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 #12
Source File: BookmarkUtils.java    From AndroidChromium with 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 #13
Source File: WebappActivity.java    From AndroidChromium with 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 #14
Source File: WebApkActivity.java    From AndroidChromium with 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 #15
Source File: ChromeActionModeCallback.java    From AndroidChromium with 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 #16
Source File: CustomTabActivity.java    From AndroidChromium with 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 #17
Source File: TabBlimpContentsObserver.java    From AndroidChromium with 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 #18
Source File: LocationBarLayout.java    From AndroidChromium with 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 #19
Source File: NewTabPage.java    From AndroidChromium with 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 #20
Source File: EmbedContentViewActivity.java    From delion with 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 #21
Source File: IntentHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Some applications may request to load the URL with a particular transition type.
 * @param context The application context.
 * @param intent Intent causing the URL load, may be null.
 * @param defaultTransition The transition to return if none specified in the intent.
 * @return The transition type to use for loading the URL.
 */
public static int getTransitionTypeFromIntent(Context context, Intent intent,
        int defaultTransition) {
    if (intent == null) return defaultTransition;
    int transitionType = IntentUtils.safeGetIntExtra(
            intent, IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.LINK);
    if (transitionType == PageTransition.TYPED) {
        return transitionType;
    } else if (transitionType != PageTransition.LINK
            && isIntentChromeOrFirstParty(intent, context)) {
        // 1st party applications may specify any transition type.
        return transitionType;
    }
    return defaultTransition;
}
 
Example #22
Source File: LocationBarLayout.java    From AndroidChromium with 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 #23
Source File: WebappActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onNewIntent(Intent intent) {
    if (intent == null) return;
    super.onNewIntent(intent);

    WebappInfo newWebappInfo = createWebappInfo(intent);
    if (newWebappInfo == null) {
        Log.e(TAG, "Failed to parse new Intent: " + intent);
        ApiCompatibilityUtils.finishAndRemoveTask(this);
    } else if (newWebappInfo.shouldForceNavigation() && mIsInitialized) {
        getActivityTab().loadUrl(new LoadUrlParams(
                newWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEVEL));
    }
}
 
Example #24
Source File: TabDelegate.java    From 365browser with 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 #25
Source File: NewTabPageUma.java    From 365browser with 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 #26
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 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();
    }

    if (getInterceptNavigationDelegate() != null) {
        getInterceptNavigationDelegate().maybeUpdateNavigationHistory();
    }
}
 
Example #27
Source File: NewTabPageUma.java    From 365browser with 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 navigate-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 #28
Source File: Tab.java    From AndroidChromium with 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 File: TabContextMenuItemDelegate.java    From 365browser with 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 #30
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@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));
}