Java Code Examples for org.chromium.chrome.browser.device.DeviceClassManager#enablePrerendering()

The following examples show how to use org.chromium.chrome.browser.device.DeviceClassManager#enablePrerendering() . 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: CustomTabsConnection.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean mayPrerender(CustomTabsSessionToken session) {
    if (!DeviceClassManager.enablePrerendering()) return false;
    // TODO(yusufo): The check for prerender in PrivacyManager now checks for the network
    // connection type as well, we should either change that or add another check for custom
    // tabs. Then PrivacyManager should be used to make the below check.
    if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) return false;
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) return false;
    ConnectivityManager cm =
            (ConnectivityManager) mApplication.getApplicationContext().getSystemService(
                    Context.CONNECTIVITY_SERVICE);
    return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSession(session);
}
 
Example 2
Source File: CustomTabsConnection.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private boolean mayPrerender(CustomTabsSessionToken session) {
    if (!DeviceClassManager.enablePrerendering()) return false;
    // TODO(yusufo): The check for prerender in PrivacyManager now checks for the network
    // connection type as well, we should either change that or add another check for custom
    // tabs. Then PrivacyManager should be used to make the below check.
    if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) return false;
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) return false;
    ConnectivityManager cm =
            (ConnectivityManager) mApplication.getApplicationContext().getSystemService(
                    Context.CONNECTIVITY_SERVICE);
    return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSession(session);
}
 
Example 3
Source File: CustomTabsConnection.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
boolean maySpeculate(CustomTabsSessionToken session) {
    if (!DeviceClassManager.enablePrerendering()) return false;
    PrefServiceBridge prefs = PrefServiceBridge.getInstance();
    if (prefs.isBlockThirdPartyCookiesEnabled()) return false;
    // TODO(yusufo): The check for prerender in PrivacyManager now checks for the network
    // connection type as well, we should either change that or add another check for custom
    // tabs. Then PrivacyManager should be used to make the below check.
    if (!prefs.getNetworkPredictionEnabled()) return false;
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) return false;
    ConnectivityManager cm =
            (ConnectivityManager) mApplication.getApplicationContext().getSystemService(
                    Context.CONNECTIVITY_SERVICE);
    return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSession(session);
}
 
Example 4
Source File: PrivacyPreferencesManager.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Checks whether prerender should be allowed and updates the preference if it is not set yet.
 * @return Whether prerendering should be allowed.
 */
public boolean shouldPrerender() {
    if (!DeviceClassManager.enablePrerendering()) return false;
    migrateNetworkPredictionPreferences();
    return PrefServiceBridge.getInstance().canPrefetchAndPrerender();
}
 
Example 5
Source File: PrivacyPreferencesManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Checks whether prerender should be allowed and updates the preference if it is not set yet.
 * @return Whether prerendering should be allowed.
 */
public boolean shouldPrerender() {
    if (!DeviceClassManager.enablePrerendering()) return false;
    migrateNetworkPredictionPreferences();
    return PrefServiceBridge.getInstance().canPrefetchAndPrerender();
}
 
Example 6
Source File: PrivacyPreferencesManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Checks whether prerender should be allowed and updates the preference if it is not set yet.
 * @return Whether prerendering should be allowed.
 */
public boolean shouldPrerender() {
    if (!DeviceClassManager.enablePrerendering()) return false;
    migrateNetworkPredictionPreferences();
    return PrefServiceBridge.getInstance().canPrefetchAndPrerender();
}