org.chromium.chrome.browser.tab.TabUma.TabCreationState Java Examples

The following examples show how to use org.chromium.chrome.browser.tab.TabUma.TabCreationState. 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: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tab to be loaded lazily. This can be used for tabs opened in the background
 * that should be loaded when switched to. initialize() needs to be called afterwards to
 * complete the second level initialization.
 */
public static Tab createTabForLazyLoad(ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId,
        LoadUrlParams loadUrlParams) {
    Tab tab = new Tab(
            INVALID_TAB_ID, parentId, incognito, activity, nativeWindow, type,
            TabCreationState.FROZEN_FOR_LAZY_LOAD, null);
    tab.setPendingLoadParams(loadUrlParams);
    return tab;
}
 
Example #2
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a fresh tab. initialize() needs to be called afterwards to complete the second level
 * initialization.
 * @param initiallyHidden true iff the tab being created is initially in background
 */
public static Tab createLiveTab(int id, ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId, boolean initiallyHidden) {
    return new Tab(id, parentId, incognito, activity, nativeWindow, type, initiallyHidden
            ? TabCreationState.LIVE_IN_BACKGROUND
            : TabCreationState.LIVE_IN_FOREGROUND, null);
}
 
Example #3
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tab to be loaded lazily. This can be used for tabs opened in the background
 * that should be loaded when switched to. initialize() needs to be called afterwards to
 * complete the second level initialization.
 */
public static Tab createTabForLazyLoad(ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId,
        LoadUrlParams loadUrlParams) {
    Tab tab = new Tab(
            INVALID_TAB_ID, parentId, incognito, activity, nativeWindow, type,
            TabCreationState.FROZEN_FOR_LAZY_LOAD, null);
    tab.setPendingLoadParams(loadUrlParams);
    return tab;
}
 
Example #4
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a fresh tab. initialize() needs to be called afterwards to complete the second level
 * initialization.
 * @param initiallyHidden true iff the tab being created is initially in background
 */
public static Tab createLiveTab(int id, ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId, boolean initiallyHidden) {
    return new Tab(id, parentId, incognito, activity, nativeWindow, type, initiallyHidden
            ? TabCreationState.LIVE_IN_BACKGROUND
            : TabCreationState.LIVE_IN_FOREGROUND, null);
}
 
Example #5
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tab to be loaded lazily. This can be used for tabs opened in the background
 * that should be loaded when switched to. initialize() needs to be called afterwards to
 * complete the second level initialization.
 */
public static Tab createTabForLazyLoad(ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId,
        LoadUrlParams loadUrlParams) {
    Tab tab = new Tab(
            INVALID_TAB_ID, parentId, incognito, activity, nativeWindow, type,
            TabCreationState.FROZEN_FOR_LAZY_LOAD, null);
    tab.setPendingLoadParams(loadUrlParams);
    return tab;
}
 
Example #6
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a fresh tab. initialize() needs to be called afterwards to complete the second level
 * initialization.
 * @param initiallyHidden true iff the tab being created is initially in background
 */
public static Tab createLiveTab(int id, ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, TabLaunchType type, int parentId, boolean initiallyHidden) {
    return new Tab(id, parentId, incognito, activity, nativeWindow, type, initiallyHidden
            ? TabCreationState.LIVE_IN_BACKGROUND
            : TabCreationState.LIVE_IN_FOREGROUND, null);
}
 
Example #7
Source File: Tab.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of a {@link Tab}.
 *
 * This constructor can be called before the native library has been loaded, so any additions
 * must be vetted for library calls.
 *
 * @param id          The id this tab should be identified with.
 * @param parentId    The id id of the tab that caused this tab to be opened.
 * @param incognito   Whether or not this tab is incognito.
 * @param context     An instance of a {@link Context}.
 * @param window      An instance of a {@link WindowAndroid}.
 * @param creationState State in which the tab is created, needed to initialize TabUma
 *                      accounting. When null, TabUma will not be initialized.
 * @param frozenState State containing information about this Tab, if it was persisted.
 */
public Tab(int id, int parentId, boolean incognito, Context context,
        WindowAndroid window, TabLaunchType type, TabCreationState creationState,
        TabState frozenState) {
    mId = TabIdManager.getInstance().generateValidId(id);
    mParentId = parentId;
    mIncognito = incognito;
    mThemedApplicationContext = context != null ? new ContextThemeWrapper(
            context.getApplicationContext(), ChromeActivity.getThemeId()) : null;
    mWindowAndroid = window;
    mLaunchType = type;
    if (mThemedApplicationContext != null) {
        Resources resources = mThemedApplicationContext.getResources();
        mIdealFaviconSize = resources.getDimensionPixelSize(R.dimen.default_favicon_size);
        mDefaultThemeColor = mIncognito
                ? ApiCompatibilityUtils.getColor(resources, R.color.incognito_primary_color)
                : ApiCompatibilityUtils.getColor(resources, R.color.default_primary_color);
        mThemeColor = calculateThemeColor(false);
    } else {
        mIdealFaviconSize = 16;
        mDefaultThemeColor = 0;
        mThemeColor = mDefaultThemeColor;
    }

    // Restore data from the TabState, if it existed.
    if (frozenState == null) {
        assert type != TabLaunchType.FROM_RESTORE;
    } else {
        assert type == TabLaunchType.FROM_RESTORE;
        restoreFieldsFromState(frozenState);
    }

    setContentViewClient(new TabContentViewClient());

    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg == null) return;
            if (msg.what == MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD) {
                enableFullscreenAfterLoad();
            }
        }
    };
    mTabRedirectHandler = new TabRedirectHandler(mThemedApplicationContext);
    addObserver(mTabObserver);

    if (incognito) {
        CipherFactory.getInstance().triggerKeyGeneration();
    }

    ContextualSearchTabHelper.createForTab(this);
    MediaSessionTabHelper.createForTab(this);

    if (creationState != null) {
        mTabUma = new TabUma(creationState);
        if (frozenState == null) {
            assert type != TabLaunchType.FROM_RESTORE
                    && creationState != TabCreationState.FROZEN_ON_RESTORE;
        } else {
            assert type == TabLaunchType.FROM_RESTORE
                    && creationState == TabCreationState.FROZEN_ON_RESTORE;
        }
    }
}
 
Example #8
Source File: Tab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of a {@link Tab}.
 *
 * This constructor can be called before the native library has been loaded, so any additions
 * must be vetted for library calls.
 *
 * @param id          The id this tab should be identified with.
 * @param parentId    The id id of the tab that caused this tab to be opened.
 * @param incognito   Whether or not this tab is incognito.
 * @param context     An instance of a {@link Context}.
 * @param window      An instance of a {@link WindowAndroid}.
 * @param creationState State in which the tab is created, needed to initialize TabUma
 *                      accounting. When null, TabUma will not be initialized.
 * @param frozenState State containing information about this Tab, if it was persisted.
 */
@SuppressLint("HandlerLeak")
public Tab(int id, int parentId, boolean incognito, Context context,
        WindowAndroid window, TabLaunchType type, TabCreationState creationState,
        TabState frozenState) {
    mId = TabIdManager.getInstance().generateValidId(id);
    mParentId = parentId;
    mIncognito = incognito;
    mThemedApplicationContext = context != null ? new ContextThemeWrapper(
            context.getApplicationContext(), ChromeActivity.getThemeId()) : null;
    mWindowAndroid = window;
    mLaunchType = type;
    if (mThemedApplicationContext != null) {
        Resources resources = mThemedApplicationContext.getResources();
        mIdealFaviconSize = resources.getDimensionPixelSize(R.dimen.default_favicon_size);
        mDefaultThemeColor = mIncognito
                ? ApiCompatibilityUtils.getColor(resources, R.color.incognito_primary_color)
                : ApiCompatibilityUtils.getColor(resources, R.color.default_primary_color);
        mThemeColor = calculateThemeColor(false);
    } else {
        mIdealFaviconSize = 16;
        mDefaultThemeColor = 0;
        mThemeColor = mDefaultThemeColor;
    }

    // Restore data from the TabState, if it existed.
    if (frozenState != null) {
        assert type == TabLaunchType.FROM_RESTORE;
        restoreFieldsFromState(frozenState);
    }

    setContentViewClient(new TabContentViewClient());

    mTabRedirectHandler = new TabRedirectHandler(mThemedApplicationContext);
    addObserver(mTabObserver);

    if (incognito) {
        CipherFactory.getInstance().triggerKeyGeneration();
    }

    ContextualSearchTabHelper.createForTab(this);
    MediaSessionTabHelper.createForTab(this);

    if (creationState != null) {
        mTabUma = new TabUma(creationState);
        if (frozenState == null) {
            assert creationState != TabCreationState.FROZEN_ON_RESTORE;
        } else {
            assert type == TabLaunchType.FROM_RESTORE
                    && creationState == TabCreationState.FROZEN_ON_RESTORE;
        }
    }
}
 
Example #9
Source File: Tab.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of a {@link Tab}.
 *
 * This constructor can be called before the native library has been loaded, so any additions
 * must be vetted for library calls.
 *
 * @param id          The id this tab should be identified with.
 * @param parentId    The id id of the tab that caused this tab to be opened.
 * @param incognito   Whether or not this tab is incognito.
 * @param context     An instance of a {@link Context}.
 * @param window      An instance of a {@link WindowAndroid}.
 * @param creationState State in which the tab is created, needed to initialize TabUma
 *                      accounting. When null, TabUma will not be initialized.
 * @param frozenState State containing information about this Tab, if it was persisted.
 */
@SuppressLint("HandlerLeak")
public Tab(int id, int parentId, boolean incognito, Context context,
        WindowAndroid window, TabLaunchType type, TabCreationState creationState,
        TabState frozenState) {
    mId = TabIdManager.getInstance().generateValidId(id);
    mParentId = parentId;
    mIncognito = incognito;
    mThemedApplicationContext = context != null ? new ContextThemeWrapper(
            context.getApplicationContext(), ChromeActivity.getThemeId()) : null;
    mWindowAndroid = window;
    mLaunchType = type;
    if (mLaunchType == TabLaunchType.FROM_DETACHED) mIsDetached = true;
    if (mThemedApplicationContext != null) {
        Resources resources = mThemedApplicationContext.getResources();
        mIdealFaviconSize = resources.getDimensionPixelSize(R.dimen.default_favicon_size);
        mDefaultThemeColor = mIncognito
                ? ApiCompatibilityUtils.getColor(resources, R.color.incognito_primary_color)
                : ApiCompatibilityUtils.getColor(resources, R.color.default_primary_color);
        mThemeColor = calculateThemeColor(false);
    } else {
        mIdealFaviconSize = 16;
        mDefaultThemeColor = 0;
        mThemeColor = mDefaultThemeColor;
    }

    // Restore data from the TabState, if it existed.
    if (frozenState != null) {
        assert type == TabLaunchType.FROM_RESTORE;
        restoreFieldsFromState(frozenState);
    }

    mTabRedirectHandler = new TabRedirectHandler(mThemedApplicationContext);
    addObserver(mTabObserver);

    if (incognito) {
        CipherFactory.getInstance().triggerKeyGeneration();
    }

    ContextualSearchTabHelper.createForTab(this);
    MediaSessionTabHelper.createForTab(this);

    if (creationState != null) {
        mTabUma = new TabUma(creationState);
        if (frozenState == null) {
            assert creationState != TabCreationState.FROZEN_ON_RESTORE;
        } else {
            assert type == TabLaunchType.FROM_RESTORE
                    && creationState == TabCreationState.FROZEN_ON_RESTORE;
        }
    }
}