当前位置: 首页>>代码示例>>Java>>正文


Java ChromePreferenceManager类代码示例

本文整理汇总了Java中org.chromium.chrome.browser.preferences.ChromePreferenceManager的典型用法代码示例。如果您正苦于以下问题:Java ChromePreferenceManager类的具体用法?Java ChromePreferenceManager怎么用?Java ChromePreferenceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChromePreferenceManager类属于org.chromium.chrome.browser.preferences包,在下文中一共展示了ChromePreferenceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cacheInstantAppsEnabled

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Cache whether the Instant Apps feature is enabled.
 * This should only be called with the native library loaded.
 */
public void cacheInstantAppsEnabled() {
    Context context = ContextUtils.getApplicationContext();
    boolean isEnabled = false;
    boolean wasEnabled = isEnabled(context);
    CommandLine instance = CommandLine.getInstance();
    if (instance.hasSwitch(ChromeSwitches.DISABLE_APP_LINK)) {
        isEnabled = false;
    } else if (instance.hasSwitch(ChromeSwitches.ENABLE_APP_LINK)) {
        isEnabled = true;
    } else {
        String experiment = FieldTrialList.findFullName(INSTANT_APPS_EXPERIMENT_NAME);
        if (INSTANT_APPS_DISABLED_ARM.equals(experiment)) {
            isEnabled = false;
        } else if (INSTANT_APPS_ENABLED_ARM.equals(experiment)) {
            isEnabled = true;
        }
    }

    if (isEnabled != wasEnabled) {
        ChromePreferenceManager.getInstance(context).setCachedInstantAppsEnabled(isEnabled);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:InstantAppsHandler.java

示例2: launchSigninPromoIfNeeded

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Launches the signin promo if it needs to be displayed.
 * @param activity The parent activity.
 * @return Whether the signin promo is shown.
 */
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
    // The promo is displayed if Chrome is launched directly (i.e., not with the intent to
    // navigate to and view a URL on startup), the instance is part of the field trial,
    // and the promo has been marked to display.
    ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
    if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return false;
    if (!preferenceManager.getShowSigninPromo()) return false;
    preferenceManager.setShowSigninPromo(false);

    String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
    if (ChromeSigninController.get(activity).isSignedIn() || !TextUtils.isEmpty(lastSyncName)) {
        return false;
    }

    AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_PROMO);
    preferenceManager.setSigninPromoShown();
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:SigninPromoUtil.java

示例3: onSnippetBound

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * To be triggered when a snippet is bound to a ViewHolder.
 */
public void onSnippetBound(View cardView) {
    // We only run if the feature is enabled and once per NTP.
    if (!SnippetsConfig.isIncreasedCardVisibilityEnabled() || mFirstCardAnimationRun) return;
    mFirstCardAnimationRun = true;

    // We only want an animation to run if we are not scrolled.
    if (computeVerticalScrollOffset() != 0) return;

    // We only show the animation a certain number of times to a user.
    ChromePreferenceManager manager = ChromePreferenceManager.getInstance(getContext());
    int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
    if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
    manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);

    // We do not show the animation if the user has previously seen it then scrolled.
    if (manager.getCardsImpressionAfterAnimation()) return;

    // The peeking card bounces up twice from its position.
    ObjectAnimator animator = ObjectAnimator.ofFloat(cardView, View.TRANSLATION_Y,
            0f, -mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
    animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
    animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
    animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
    animator.start();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:NewTabPageRecyclerView.java

示例4: cacheEnabledStateForNextLaunch

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Once native is loaded we can consult the command-line (set via about:flags) and also finch
 * state to see if we should enable WebAPKs.
 */
public static void cacheEnabledStateForNextLaunch() {
    ChromePreferenceManager preferenceManager =
            ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext());

    boolean wasCommandLineEnabled = preferenceManager.getCachedWebApkCommandLineEnabled();
    boolean isCommandLineEnabled = isCommandLineFlagSet();
    if (isCommandLineEnabled != wasCommandLineEnabled) {
        // {@link launchWebApkRequirementsDialogIfNeeded()} is skipped the first time Chrome is
        // launched so do caching here instead.
        preferenceManager.setCachedWebApkCommandLineEnabled(isCommandLineEnabled);
    }

    boolean wasEnabled = isEnabledInPrefs();
    boolean isEnabled = computeEnabled();
    if (isEnabled != wasEnabled) {
        Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnabled);
        preferenceManager.setCachedWebApkRuntimeEnabled(isEnabled);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ChromeWebApkHost.java

示例5: getHerbFlavor

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * @return Which flavor of Herb is being tested.
 *         See {@link ChromeSwitches#HERB_FLAVOR_ELDERBERRY} and its related switches.
 */
public static String getHerbFlavor() {
    Context context = ContextUtils.getApplicationContext();
    if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED;

    if (!sIsHerbFlavorCached) {
        sCachedHerbFlavor = null;

        // Allowing disk access for preferences while prototyping.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        try {
            sCachedHerbFlavor =
                    ChromePreferenceManager.getInstance(context).getCachedHerbFlavor();
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }

        sIsHerbFlavorCached = true;
        Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor);
    }

    return sCachedHerbFlavor;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:FeatureUtilities.java

示例6: cacheChromeHomeEnabled

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Cache whether or not Chrome Home is enabled.
 */
public static void cacheChromeHomeEnabled() {
    Context context = ContextUtils.getApplicationContext();

    // Chrome Home doesn't work with tablets.
    if (DeviceFormFactor.isTablet(context)) return;

    boolean isChromeHomeEnabled = ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME);
    ChromePreferenceManager manager = ChromePreferenceManager.getInstance(context);
    boolean valueChanged = isChromeHomeEnabled != manager.isChromeHomeEnabled();
    manager.setChromeHomeEnabled(isChromeHomeEnabled);
    sChromeHomeEnabled = isChromeHomeEnabled;

    // If the cached value changed, restart chrome.
    if (valueChanged) ApplicationLifetime.terminate(true);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:FeatureUtilities.java

示例7: storeBreakpadUploadStatsInUma

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Stores the successes and failures from uploading crash to UMA,
 */
public static void storeBreakpadUploadStatsInUma(ChromePreferenceManager pref) {
    for (String type : TYPES) {
        for (int success = pref.getCrashSuccessUploadCount(type); success > 0; success--) {
            RecordHistogram.recordEnumeratedHistogram(
                    HISTOGRAM_NAME_PREFIX + type,
                    SUCCESS,
                    HISTOGRAM_MAX);
        }
        for (int fail = pref.getCrashFailureUploadCount(type); fail > 0; fail--) {
            RecordHistogram.recordEnumeratedHistogram(
                    HISTOGRAM_NAME_PREFIX + type,
                    FAILURE,
                    HISTOGRAM_MAX);
        }

        pref.setCrashSuccessUploadCount(type, 0);
        pref.setCrashFailureUploadCount(type, 0);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:MinidumpUploadService.java

示例8: launchSigninPromoIfNeeded

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Launches the signin promo if it needs to be displayed.
 * @param activity The parent activity.
 * @return Whether the signin promo is shown.
 */
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
    // The promo is displayed if Chrome is launched directly (i.e., not with the intent to
    // navigate to and view a URL on startup), the instance is part of the field trial,
    // and the promo has been marked to display.
    ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
    if (MultiWindowUtils.getInstance().isMultiWindow(activity)) return false;
    if (!preferenceManager.getShowSigninPromo()) return false;
    preferenceManager.setShowSigninPromo(false);

    String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
    if (SigninManager.getAndroidSigninPromoExperimentGroup() < 0
            || ChromeSigninController.get(activity).isSignedIn()
            || !TextUtils.isEmpty(lastSyncName)) {
        return false;
    }

    SigninPromoScreen promoScreen = new SigninPromoScreen(activity);
    promoScreen.show();
    preferenceManager.setSigninPromoShown();
    return true;
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:27,代码来源:SigninPromoScreen.java

示例9: migrateTabsToDocumentForUpgrade

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Migrate tabs saved in classic mode to document mode for an upgrade. This doesn't restart
 * the app process but only finishes the {@link ChromeLauncherActivity} it was being called
 * with.
 * @param activity The activity to use for carrying out and finalizing the migration.
 * @param finalizeMode The mode in which the migration should be finalized.
 * @return Whether any tabs will be migrated.
 */
public static boolean migrateTabsToDocumentForUpgrade(Activity activity,
        int finalizeMode) {
    // Allow StrictMode violations here as state file read/write is on the critical path. This
    // is also a one-time migration, so optimizing further does not improve daily experience.
    // See http://crbug.com/493157 for more context.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    StrictMode.allowThreadDiskWrites();
    try {
        ChromePreferenceManager.getInstance(activity).setAttemptedMigrationOnUpgrade();

        File[] fileList = TabPersistentStore.getStateDirectory(activity, 0).listFiles();
        if (fileList == null || fileList.length == 0
                || (fileList.length == 1
                && fileList[0].getName().equals(TabPersistentStore.SAVED_STATE_FILE))) {
            return false;
        }

        migrateTabsFromClassicToDocument(activity, finalizeMode);
        return true;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:32,代码来源:DocumentMigrationHelper.java

示例10: launchSigninPromoIfNeeded

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Launches the signin promo if it needs to be displayed.
 * @param activity The parent activity.
 * @return Whether the signin promo is shown.
 */
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
    // The promo is displayed if Chrome is launched directly (i.e., not with the intent to
    // navigate to and view a URL on startup), the instance is part of the field trial,
    // and the promo has been marked to display.
    ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
    if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return false;
    if (!preferenceManager.getShowSigninPromo()) return false;
    preferenceManager.setShowSigninPromo(false);

    String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
    if (ChromeSigninController.get().isSignedIn() || !TextUtils.isEmpty(lastSyncName)) {
        return false;
    }

    AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_PROMO);
    preferenceManager.setSigninPromoShown();
    return true;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:24,代码来源:SigninPromoUtil.java

示例11: getHerbFlavor

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * @return Which flavor of Herb is being tested.
 *         See {@link ChromeSwitches#HERB_FLAVOR_ELDERBERRY} and its related switches.
 */
public static String getHerbFlavor() {
    Context context = ContextUtils.getApplicationContext();
    if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED;

    if (!sIsHerbFlavorCached) {
        sCachedHerbFlavor = null;

        // Allowing disk access for preferences while prototyping.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        try {
            sCachedHerbFlavor = ChromePreferenceManager.getInstance().getCachedHerbFlavor();
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }

        sIsHerbFlavorCached = true;
        Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor);
    }

    return sCachedHerbFlavor;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:26,代码来源:FeatureUtilities.java

示例12: storeBreakpadUploadStatsInUma

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Stores the successes and failures from uploading crash to UMA,
 */
public static void storeBreakpadUploadStatsInUma(ChromePreferenceManager pref) {
    for (String type : TYPES) {
        for (int success = pref.getCrashSuccessUploadCount(type); success > 0; success--) {
            RecordHistogram.recordEnumeratedHistogram(
                    HISTOGRAM_NAME_PREFIX + type, SUCCESS, HISTOGRAM_MAX);
        }
        for (int fail = pref.getCrashFailureUploadCount(type); fail > 0; fail--) {
            RecordHistogram.recordEnumeratedHistogram(
                    HISTOGRAM_NAME_PREFIX + type, FAILURE, HISTOGRAM_MAX);
        }

        pref.setCrashSuccessUploadCount(type, 0);
        pref.setCrashFailureUploadCount(type, 0);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:MinidumpUploadService.java

示例13: cacheIsChromeDefaultBrowser

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Caches whether Chrome is set as a default browser on the device.
 */
@WorkerThread
private void cacheIsChromeDefaultBrowser() {
    // Retrieve whether Chrome is default in background to avoid strict mode checks.
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://www.madeupdomainforcheck123.com/"));
    ResolveInfo info = mAppContext.getPackageManager().resolveActivity(intent, 0);
    boolean isDefault = (info != null && info.match != 0
            && mAppContext.getPackageName().equals(info.activityInfo.packageName));
    ChromePreferenceManager.getInstance(mAppContext).setCachedChromeDefaultBrowser(isDefault);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:DeferredStartupHandler.java

示例14: isEnabled

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Check the cached value to figure out if the feature is enabled. We have to use the cached
 * value because native library hasn't yet been loaded.
 * @param context The application context.
 * @return Whether the feature is enabled.
 */
protected boolean isEnabled(Context context) {
    // Will go away once the feature is enabled for everyone by default.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ChromePreferenceManager.getInstance(context).getCachedInstantAppsEnabled();
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:InstantAppsHandler.java

示例15: isChromeDefaultHandler

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/** @return Whether Chrome is the default browser on the device. */
private boolean isChromeDefaultHandler(Context context) {
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ChromePreferenceManager.getInstance(context).getCachedChromeDefaultBrowser();
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:InstantAppsHandler.java


注:本文中的org.chromium.chrome.browser.preferences.ChromePreferenceManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。