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

The following examples show how to use org.chromium.ui.base.PageTransition#TYPED . 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: 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 5
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 6
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;
    }
}