• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChromePreferenceManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ContextualSearchPolicy

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * @param context The Android Context.
 */
public ContextualSearchPolicy(Context context,
                              ContextualSearchSelectionController selectionController,
                              ContextualSearchNetworkCommunicator networkCommunicator) {
    mPreferenceManager = ChromePreferenceManager.getInstance(context);

    mSelectionController = selectionController;
    mNetworkCommunicator = networkCommunicator;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:ContextualSearchPolicy.java


示例17: getInstance

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Gets the singleton instance used to access the persistent counter.
 * @param prefsManager The ChromePreferenceManager to get prefs from.
 * @return the counter.
 */
static DisableablePromoTapCounter getInstance(
        ChromePreferenceManager prefsManager) {
    if (sInstance == null) {
        sInstance = new DisableablePromoTapCounter(prefsManager);
    }
    return sInstance;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:DisableablePromoTapCounter.java


示例18: CtrSuppression

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/**
 * Constructs an object that tracks impressions and clicks per user to produce CTR and
 * impression metrics.
 * @param context An Android Context.
 */
CtrSuppression(Context context) {
    mPreferenceManager = ChromePreferenceManager.getInstance(context);

    // This needs to be done last in this constructor because the native code may call
    // into this object.
    mNativePointer = nativeInit();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:CtrSuppression.java


示例19: SignInPromo

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
public SignInPromo(NodeParent parent, NewTabPageAdapter adapter) {
    super(parent);
    mDismissed = ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext())
                         .getNewTabPageSigninPromoDismissed();

    final SigninManager signinManager = SigninManager.get(ContextUtils.getApplicationContext());
    mObserver = mDismissed ? null : new SigninObserver(signinManager, adapter);
    setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInOnNative());
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:SignInPromo.java


示例20: dismiss

import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入依赖的package包/类
/** Hides the sign in promo and sets a preference to make sure it is not shown again. */
public void dismiss() {
    mDismissed = true;
    setVisible(false);

    ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext())
            .setNewTabPageSigninPromoDismissed(true);
    mObserver.unregister();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:SignInPromo.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProfilerAggregator类代码示例发布时间:2022-05-15
下一篇:
Java FederateNotExecutionMember类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap