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

The following examples show how to use org.chromium.ui.base.PageTransition#LINK . 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: IntentHandler.java    From delion 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 2
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 3
Source File: IntentHandler.java    From 365browser 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 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(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)) {
        // 1st party applications may specify any transition type.
        return transitionType;
    }
    return defaultTransition;
}
 
Example 4
Source File: LocationBarLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
private void findMatchAndLoadUrl(String urlText) {
    int suggestionMatchPosition;
    OmniboxSuggestion suggestionMatch;
    boolean skipOutOfBoundsCheck = false;

    if (mSuggestionList != null
            && mSuggestionList.isShown()
            && mSuggestionList.getSelectedItemPosition()
            != ListView.INVALID_POSITION) {
        // Bluetooth keyboard case: the user highlighted a suggestion with the arrow
        // keys, then pressed enter.
        suggestionMatchPosition = mSuggestionList.getSelectedItemPosition();
        OmniboxResultItem selectedItem =
                (OmniboxResultItem) mSuggestionListAdapter.getItem(suggestionMatchPosition);
        suggestionMatch = selectedItem.getSuggestion();
    } else if (!mSuggestionItems.isEmpty()
            && urlText.equals(mUrlTextAfterSuggestionsReceived)) {
        // Common case: the user typed something, received suggestions, then pressed enter.
        suggestionMatch = mSuggestionItems.get(0).getSuggestion();
        suggestionMatchPosition = 0;
    } else {
        // Less common case: there are no valid omnibox suggestions. This can happen if the
        // user tapped the URL bar to dismiss the suggestions, then pressed enter. This can
        // also happen if the user presses enter before any suggestions have been received
        // from the autocomplete controller.
        suggestionMatch = mAutocomplete.classify(urlText);
        suggestionMatchPosition = 0;
        // Classify matches don't propagate to java, so skip the OOB check.
        skipOutOfBoundsCheck = true;

        // If urlText couldn't be classified, bail.
        if (suggestionMatch == null) return;
    }

    String suggestionMatchUrl = updateSuggestionUrlIfNeeded(suggestionMatch,
                suggestionMatchPosition, skipOutOfBoundsCheck);


    // It's important to use the page transition from the suggestion or we might end
    // up saving generated URLs as typed URLs, which would then pollute the subsequent
    // omnibox results. There is one special case where the suggestion text was pasted,
    // where we want the transition type to be LINK.
    int transition = suggestionMatch.getType() == OmniboxSuggestionType.URL_WHAT_YOU_TYPED
            && mUrlBar.isPastedText() ? PageTransition.LINK
                    : suggestionMatch.getTransition();

    loadUrlFromOmniboxMatch(suggestionMatchUrl, transition, suggestionMatchPosition,
            suggestionMatch.getType());
}
 
Example 5
Source File: TabRedirectHandler.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Updates new url loading information to trace navigation.
 * A time based heuristic is used to determine if this loading is an effective redirect or not
 * if core of |pageTransType| is LINK.
 *
 * http://crbug.com/322567 : Trace navigation started from an external app.
 * http://crbug.com/331571 : Trace navigation started from user typing to do not override such
 * navigation.
 * http://crbug.com/426679 : Trace every navigation and the last committed entry index right
 * before starting the navigation.
 *
 * @param pageTransType page transition type of this loading.
 * @param isRedirect whether this loading is http redirect or not.
 * @param hasUserGesture whether this loading is started by a user gesture.
 * @param lastUserInteractionTime time when the last user interaction was made.
 * @param lastCommittedEntryIndex the last committed entry index right before this loading.
 */
public void updateNewUrlLoading(int pageTransType, boolean isRedirect, boolean hasUserGesture,
        long lastUserInteractionTime, int lastCommittedEntryIndex) {
    long prevNewUrlLoadingTime = mLastNewUrlLoadingTime;
    mLastNewUrlLoadingTime = SystemClock.elapsedRealtime();

    int pageTransitionCore = pageTransType & PageTransition.CORE_MASK;

    boolean isNewLoadingStartedByUser = false;
    boolean isFromIntent = pageTransitionCore == PageTransition.LINK
            && (pageTransType & PageTransition.FROM_API) != 0;
    if (!isRedirect) {
        if ((pageTransType & PageTransition.FORWARD_BACK) != 0) {
            isNewLoadingStartedByUser = true;
        } else if (pageTransitionCore != PageTransition.LINK) {
            isNewLoadingStartedByUser = true;
        } else if (prevNewUrlLoadingTime == INVALID_TIME || isFromIntent
                || lastUserInteractionTime > prevNewUrlLoadingTime) {
            isNewLoadingStartedByUser = true;
        }
    }

    if (isNewLoadingStartedByUser) {
        // Updates mInitialNavigationType for a new loading started by a user's gesture.
        if (isFromIntent && mInitialIntent != null) {
            mInitialNavigationType = NAVIGATION_TYPE_FROM_INTENT;
        } else {
            clearIntentHistory();
            if (pageTransitionCore == PageTransition.TYPED) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_USER_TYPING;
            } else if (pageTransitionCore == PageTransition.RELOAD
                    || (pageTransType & PageTransition.FORWARD_BACK) != 0) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_RELOAD;
            } else if (pageTransitionCore == PageTransition.LINK && !hasUserGesture) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_LINK_WITHOUT_USER_GESTURE;
            } else {
                mInitialNavigationType = NAVIGATION_TYPE_OTHER;
            }
        }
        mIsOnEffectiveRedirectChain = false;
        mLastCommittedEntryIndexBeforeStartingNavigation = lastCommittedEntryIndex;
        mShouldNotOverrideUrlLoadingUntilNewUrlLoading = false;
    } else if (mInitialNavigationType != NAVIGATION_TYPE_NONE) {
        // Redirect chain starts from the second url loading.
        mIsOnEffectiveRedirectChain = true;
    }
}
 
Example 6
Source File: LocationBarLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void findMatchAndLoadUrl(String urlText) {
    int suggestionMatchPosition;
    OmniboxSuggestion suggestionMatch;
    boolean skipOutOfBoundsCheck = false;

    if (mSuggestionList != null
            && mSuggestionList.isShown()
            && mSuggestionList.getSelectedItemPosition()
            != ListView.INVALID_POSITION) {
        // Bluetooth keyboard case: the user highlighted a suggestion with the arrow
        // keys, then pressed enter.
        suggestionMatchPosition = mSuggestionList.getSelectedItemPosition();
        OmniboxResultItem selectedItem =
                (OmniboxResultItem) mSuggestionListAdapter.getItem(suggestionMatchPosition);
        suggestionMatch = selectedItem.getSuggestion();
    } else if (!mSuggestionItems.isEmpty()
            && urlText.equals(mUrlTextAfterSuggestionsReceived)) {
        // Common case: the user typed something, received suggestions, then pressed enter.
        suggestionMatch = mSuggestionItems.get(0).getSuggestion();
        suggestionMatchPosition = 0;
    } else {
        // Less common case: there are no valid omnibox suggestions. This can happen if the
        // user tapped the URL bar to dismiss the suggestions, then pressed enter. This can
        // also happen if the user presses enter before any suggestions have been received
        // from the autocomplete controller.
        suggestionMatch = mAutocomplete.classify(urlText);
        suggestionMatchPosition = 0;
        // Classify matches don't propagate to java, so skip the OOB check.
        skipOutOfBoundsCheck = true;

        // If urlText couldn't be classified, bail.
        if (suggestionMatch == null) return;
    }

    String suggestionMatchUrl = updateSuggestionUrlIfNeeded(suggestionMatch,
                suggestionMatchPosition, skipOutOfBoundsCheck);


    // It's important to use the page transition from the suggestion or we might end
    // up saving generated URLs as typed URLs, which would then pollute the subsequent
    // omnibox results. There is one special case where the suggestion text was pasted,
    // where we want the transition type to be LINK.
    int transition = suggestionMatch.getType() == OmniboxSuggestionType.URL_WHAT_YOU_TYPED
            && mUrlBar.isPastedText() ? PageTransition.LINK
                    : suggestionMatch.getTransition();

    loadUrlFromOmniboxMatch(suggestionMatchUrl, transition, suggestionMatchPosition,
            suggestionMatch.getType());
}
 
Example 7
Source File: TabRedirectHandler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Updates new url loading information to trace navigation.
 * A time based heuristic is used to determine if this loading is an effective redirect or not
 * if core of |pageTransType| is LINK.
 *
 * http://crbug.com/322567 : Trace navigation started from an external app.
 * http://crbug.com/331571 : Trace navigation started from user typing to do not override such
 * navigation.
 * http://crbug.com/426679 : Trace every navigation and the last committed entry index right
 * before starting the navigation.
 *
 * @param pageTransType page transition type of this loading.
 * @param isRedirect whether this loading is http redirect or not.
 * @param hasUserGesture whether this loading is started by a user gesture.
 * @param lastUserInteractionTime time when the last user interaction was made.
 * @param lastCommittedEntryIndex the last committed entry index right before this loading.
 */
public void updateNewUrlLoading(int pageTransType, boolean isRedirect, boolean hasUserGesture,
        long lastUserInteractionTime, int lastCommittedEntryIndex) {
    long prevNewUrlLoadingTime = mLastNewUrlLoadingTime;
    mLastNewUrlLoadingTime = SystemClock.elapsedRealtime();

    int pageTransitionCore = pageTransType & PageTransition.CORE_MASK;

    boolean isNewLoadingStartedByUser = false;
    boolean isFromIntent = pageTransitionCore == PageTransition.LINK
            && (pageTransType & PageTransition.FROM_API) != 0;
    if (!isRedirect) {
        if ((pageTransType & PageTransition.FORWARD_BACK) != 0) {
            isNewLoadingStartedByUser = true;
        } else if (pageTransitionCore != PageTransition.LINK) {
            isNewLoadingStartedByUser = true;
        } else if (prevNewUrlLoadingTime == INVALID_TIME || isFromIntent
                || lastUserInteractionTime > prevNewUrlLoadingTime) {
            isNewLoadingStartedByUser = true;
        }
    }

    if (isNewLoadingStartedByUser) {
        // Updates mInitialNavigationType for a new loading started by a user's gesture.
        if (isFromIntent && mInitialIntent != null) {
            mInitialNavigationType = NAVIGATION_TYPE_FROM_INTENT;
        } else {
            clearIntentHistory();
            if (pageTransitionCore == PageTransition.TYPED) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_USER_TYPING;
            } else if (pageTransitionCore == PageTransition.RELOAD
                    || (pageTransType & PageTransition.FORWARD_BACK) != 0) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_RELOAD;
            } else if (pageTransitionCore == PageTransition.LINK && !hasUserGesture) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_LINK_WITHOUT_USER_GESTURE;
            } else {
                mInitialNavigationType = NAVIGATION_TYPE_OTHER;
            }
        }
        mIsOnEffectiveRedirectChain = false;
        mLastCommittedEntryIndexBeforeStartingNavigation = lastCommittedEntryIndex;
        mShouldNotOverrideUrlLoadingUntilNewUrlLoading = false;
    } else if (mInitialNavigationType != NAVIGATION_TYPE_NONE) {
        // Redirect chain starts from the second url loading.
        mIsOnEffectiveRedirectChain = true;
    }
}
 
Example 8
Source File: LocationBarLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void findMatchAndLoadUrl(String urlText) {
    int suggestionMatchPosition;
    OmniboxSuggestion suggestionMatch;
    boolean skipOutOfBoundsCheck = false;

    if (mSuggestionList != null
            && mSuggestionList.isShown()
            && mSuggestionList.getSelectedItemPosition()
            != ListView.INVALID_POSITION) {
        // Bluetooth keyboard case: the user highlighted a suggestion with the arrow
        // keys, then pressed enter.
        suggestionMatchPosition = mSuggestionList.getSelectedItemPosition();
        OmniboxResultItem selectedItem =
                (OmniboxResultItem) mSuggestionListAdapter.getItem(suggestionMatchPosition);
        suggestionMatch = selectedItem.getSuggestion();
    } else if (!mSuggestionItems.isEmpty()
            && urlText.equals(mUrlTextAfterSuggestionsReceived)) {
        // Common case: the user typed something, received suggestions, then pressed enter.
        suggestionMatch = mSuggestionItems.get(0).getSuggestion();
        suggestionMatchPosition = 0;
    } else {
        // Less common case: there are no valid omnibox suggestions. This can happen if the
        // user tapped the URL bar to dismiss the suggestions, then pressed enter. This can
        // also happen if the user presses enter before any suggestions have been received
        // from the autocomplete controller.
        suggestionMatch = mAutocomplete.classify(urlText);
        suggestionMatchPosition = 0;
        // Classify matches don't propagate to java, so skip the OOB check.
        skipOutOfBoundsCheck = true;

        // If urlText couldn't be classified, bail.
        if (suggestionMatch == null) return;
    }

    String suggestionMatchUrl = updateSuggestionUrlIfNeeded(suggestionMatch,
                suggestionMatchPosition, skipOutOfBoundsCheck);


    // It's important to use the page transition from the suggestion or we might end
    // up saving generated URLs as typed URLs, which would then pollute the subsequent
    // omnibox results. There is one special case where the suggestion text was pasted,
    // where we want the transition type to be LINK.
    int transition = suggestionMatch.getType() == OmniboxSuggestionType.URL_WHAT_YOU_TYPED
            && mUrlBar.isPastedText() ? PageTransition.LINK
                    : suggestionMatch.getTransition();

    loadUrlFromOmniboxMatch(suggestionMatchUrl, transition, suggestionMatchPosition,
            suggestionMatch.getType());
}
 
Example 9
Source File: TabRedirectHandler.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Updates new url loading information to trace navigation.
 * A time based heuristic is used to determine if this loading is an effective redirect or not
 * if core of |pageTransType| is LINK.
 *
 * http://crbug.com/322567 : Trace navigation started from an external app.
 * http://crbug.com/331571 : Trace navigation started from user typing to do not override such
 * navigation.
 * http://crbug.com/426679 : Trace every navigation and the last committed entry index right
 * before starting the navigation.
 *
 * @param pageTransType page transition type of this loading.
 * @param isRedirect whether this loading is http redirect or not.
 * @param hasUserGesture whether this loading is started by a user gesture.
 * @param lastUserInteractionTime time when the last user interaction was made.
 * @param lastCommittedEntryIndex the last committed entry index right before this loading.
 */
public void updateNewUrlLoading(int pageTransType, boolean isRedirect, boolean hasUserGesture,
        long lastUserInteractionTime, int lastCommittedEntryIndex) {
    long prevNewUrlLoadingTime = mLastNewUrlLoadingTime;
    mLastNewUrlLoadingTime = SystemClock.elapsedRealtime();

    int pageTransitionCore = pageTransType & PageTransition.CORE_MASK;

    boolean isNewLoadingStartedByUser = false;
    boolean isFromIntent = pageTransitionCore == PageTransition.LINK
            && (pageTransType & PageTransition.FROM_API) != 0;
    if (!isRedirect) {
        if ((pageTransType & PageTransition.FORWARD_BACK) != 0) {
            isNewLoadingStartedByUser = true;
        } else if (pageTransitionCore != PageTransition.LINK) {
            isNewLoadingStartedByUser = true;
        } else if (prevNewUrlLoadingTime == INVALID_TIME || isFromIntent
                || lastUserInteractionTime > prevNewUrlLoadingTime) {
            isNewLoadingStartedByUser = true;
        }
    }

    if (isNewLoadingStartedByUser) {
        // Updates mInitialNavigationType for a new loading started by a user's gesture.
        if (isFromIntent && mInitialIntent != null) {
            mInitialNavigationType = NAVIGATION_TYPE_FROM_INTENT;
        } else {
            clearIntentHistory();
            if (pageTransitionCore == PageTransition.TYPED) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_USER_TYPING;
            } else if (pageTransitionCore == PageTransition.RELOAD
                    || (pageTransType & PageTransition.FORWARD_BACK) != 0) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_RELOAD;
            } else if (pageTransitionCore == PageTransition.LINK && !hasUserGesture) {
                mInitialNavigationType = NAVIGATION_TYPE_FROM_LINK_WITHOUT_USER_GESTURE;
            } else {
                mInitialNavigationType = NAVIGATION_TYPE_OTHER;
            }
        }
        mIsOnEffectiveRedirectChain = false;
        mLastCommittedEntryIndexBeforeStartingNavigation = lastCommittedEntryIndex;
        mShouldNotOverrideUrlLoadingUntilNewUrlLoading = false;
    } else if (mInitialNavigationType != NAVIGATION_TYPE_NONE) {
        // Redirect chain starts from the second url loading.
        mIsOnEffectiveRedirectChain = true;
    }
}
 
Example 10
Source File: LoadUrlParams.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an instance with default page transition type.
 * @param url the url to be loaded
 */
public LoadUrlParams(String url) {
    this(url, PageTransition.LINK);
}