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


Java ContentSetting类代码示例

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


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

示例1: searchEngineSelected

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private void searchEngineSelected(int position) {
    // First clean up any automatically added permissions (if any) for the previously selected
    // search engine.
    SharedPreferences sharedPreferences =
            ContextUtils.getAppSharedPreferences();
    if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) {
        if (locationEnabled(mSelectedSearchEnginePosition, false)) {
            String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
                    toIndex(mSelectedSearchEnginePosition));
            WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(
                    url, url, ContentSetting.DEFAULT.toInt(), false);
        }
        sharedPreferences.edit().remove(PrefServiceBridge.LOCATION_AUTO_ALLOWED).apply();
    }

    // Record the change in search engine.
    mSelectedSearchEnginePosition = position;

    // Report the change back.
    mCallback.currentSearchEngineDetermined(toIndex(mSelectedSearchEnginePosition));

    notifyDataSetChanged();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:SearchEngineAdapter.java

示例2: maybeCreatePermissionForDefaultSearchEngine

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Add a permission entry for Location for the default search engine.
 * @param allowed Whether to create an Allowed permission or a Denied permission.
 * @param context The current context to use.
 */
public static void maybeCreatePermissionForDefaultSearchEngine(
        boolean allowed, Context context) {
    TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
    String url = templateUrlService.getSearchEngineUrlFromTemplateUrl(
            templateUrlService.getDefaultSearchEngineIndex());
    if (allowed && !url.startsWith("https:")) return;
    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    if (locationPermission == null || locationPermission == ContentSetting.ASK) {
        WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(url, url,
                allowed ? ContentSetting.ALLOW.toInt() : ContentSetting.BLOCK.toInt(), false);
        SharedPreferences sharedPreferences =
                ContextUtils.getAppSharedPreferences();
        sharedPreferences.edit().putBoolean(LOCATION_AUTO_ALLOWED, true).apply();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:PrefServiceBridge.java

示例3: searchEngineSelected

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private void searchEngineSelected(int position) {
    // First clean up any automatically added permissions (if any) for the previously selected
    // search engine.
    SharedPreferences sharedPreferences =
            PreferenceManager.getDefaultSharedPreferences(mContext);
    if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) {
        if (locationEnabled(mSelectedSearchEnginePosition, false)) {
            String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
                    toIndex(mSelectedSearchEnginePosition));
            WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(
                    url, url, ContentSetting.DEFAULT.toInt(), false);
        }
        sharedPreferences.edit().remove(PrefServiceBridge.LOCATION_AUTO_ALLOWED).apply();
    }

    // Record the change in search engine.
    mSelectedSearchEnginePosition = position;
    TemplateUrlService.getInstance().setSearchEngine(toIndex(mSelectedSearchEnginePosition));

    // Report the change back.
    TemplateUrl templateUrl = mSearchEngines.get(mSelectedSearchEnginePosition);
    mCallback.currentSearchEngineDetermined(getSearchEngineNameAndDomain(
            mContext.getResources(), templateUrl));

    notifyDataSetChanged();
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:27,代码来源:SearchEngineAdapter.java

示例4: maybeCreatePermissionForDefaultSearchEngine

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Add a permission entry for Location for the default search engine.
 * @param allowed Whether to create an Allowed permission or a Denied permission.
 * @param context The current context to use.
 */
public static void maybeCreatePermissionForDefaultSearchEngine(
        boolean allowed, Context context) {
    TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
    String url = templateUrlService.getSearchEngineUrlFromTemplateUrl(
            templateUrlService.getDefaultSearchEngineIndex());
    if (allowed && !url.startsWith("https:")) return;
    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    if (locationPermission == null || locationPermission == ContentSetting.ASK) {
        WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(url, url,
                allowed ? ContentSetting.ALLOW.toInt() : ContentSetting.BLOCK.toInt(), false);
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(context);
        sharedPreferences.edit().putBoolean(LOCATION_AUTO_ALLOWED, true).apply();
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:22,代码来源:PrefServiceBridge.java

示例5: locationShouldBeShown

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private boolean locationShouldBeShown(TemplateUrl templateUrl) {
    String url = getSearchEngineUrl(templateUrl);
    if (url.isEmpty()) return false;

    // Do not show location if the scheme isn't HTTPS.
    Uri uri = Uri.parse(url);
    if (!UrlConstants.HTTPS_SCHEME.equals(uri.getScheme())) return false;

    // Only show the location setting if it is explicitly enabled or disabled.
    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    if (locationPermission != ContentSetting.ASK) return true;

    if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) {
        return WebsitePreferenceBridge.shouldUseDSEGeolocationSetting(url, false);
    }

    return GeolocationHeader.isGeoHeaderEnabledForUrl(url, false);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:20,代码来源:SearchEngineAdapter.java

示例6: locationEnabled

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private boolean locationEnabled(TemplateUrl templateUrl) {
    String url = getSearchEngineUrl(templateUrl);
    if (url.isEmpty()) return false;

    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    if (locationPermission == ContentSetting.ASK) {
        // Handle the case where the geoHeader being sent when no permission has been specified.
        if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) {
            if (WebsitePreferenceBridge.shouldUseDSEGeolocationSetting(url, false)) {
                return WebsitePreferenceBridge.getDSEGeolocationSetting();
            }
        } else if (GeolocationHeader.isGeoHeaderEnabledForUrl(url, false)) {
            return true;
        }
    }

    return locationPermission == ContentSetting.ALLOW;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:20,代码来源:SearchEngineAdapter.java

示例7: addPermissionSection

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Adds a new row for the given permission.
 *
 * @param name The title of the permission to display to the user.
 * @param type The ContentSettingsType of the permission.
 * @param currentSettingValue The ContentSetting value of the currently selected setting.
 */
@CalledByNative
private void addPermissionSection(String name, int type, int currentSettingValue) {
    // We have at least one permission, so show the lower permissions area.
    setVisibilityOfPermissionsList(true);
    mDisplayedPermissions.add(new PageInfoPermissionEntry(name, type, ContentSetting
            .fromInt(currentSettingValue)));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:WebsiteSettingsPopup.java

示例8: locationEnabled

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private boolean locationEnabled(int position, boolean checkGeoHeader) {
    if (position == -1) return false;

    String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
            toIndex(position));
    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    // Handle the case where the geoHeader being sent when no permission has been specified.
    if (locationPermission == ContentSetting.ASK && checkGeoHeader) {
        return GeolocationHeader.isGeoHeaderEnabledForUrl(mContext, url, false);
    }
    return locationPermission == ContentSetting.ALLOW;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:SearchEngineAdapter.java

示例9: addContentSettingExceptionToList

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
@CalledByNative
private static void addContentSettingExceptionToList(
        ArrayList<ContentSettingException> list,
        int contentSettingsType,
        String pattern,
        int contentSetting,
        String source) {
    ContentSettingException exception = new ContentSettingException(
            contentSettingsType, pattern, ContentSetting.fromInt(contentSetting), source);
    list.add(exception);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:PrefServiceBridge.java

示例10: locationEnabled

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
private boolean locationEnabled(int position, boolean checkGeoHeader) {
    if (position == -1) return false;

    String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
            toIndex(position));
    GeolocationInfo locationSettings = new GeolocationInfo(url, null, false);
    ContentSetting locationPermission = locationSettings.getContentSetting();
    // Handle the case where the geoHeader being sent when no permission has been specified.
    if (locationPermission == ContentSetting.ASK && checkGeoHeader) {
        return PrefServiceBridge.isGeoHeaderEnabledForUrl(mContext, url, false);
    }
    return locationPermission == ContentSetting.ALLOW;
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:14,代码来源:SearchEngineAdapter.java

示例11: statusTextForDSEPermission

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Update the permission string for the Default Search Engine.
 */
private String statusTextForDSEPermission(PageInfoPermissionEntry permission) {
    if (permission.setting == ContentSetting.ALLOW) {
        return mContext.getString(R.string.page_info_dse_permission_allowed);
    }

    return mContext.getString(R.string.page_info_dse_permission_blocked);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:PageInfoPopup.java

示例12: isLocationDisabledForUrl

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Returns true if the user has disabled sharing their location with url (e.g. via the
 * geolocation infobar).
 */
static boolean isLocationDisabledForUrl(Uri uri, boolean isIncognito) {
    if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) {
        boolean enabled = WebsitePreferenceBridge.shouldUseDSEGeolocationSetting(
                                  uri.toString(), isIncognito)
                && WebsitePreferenceBridge.getDSEGeolocationSetting();
        return !enabled;
    } else {
        return locationContentSettingForUrl(uri, isIncognito) == ContentSetting.BLOCK;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:GeolocationHeader.java

示例13: getDomainPermission

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Returns the domain permission as either granted, blocked or prompt.
 * This is based upon the location permission for sharing their location with url (e.g. via the
 * geolocation infobar).
 */
@Permission
private static int getDomainPermission(String url, boolean isIncognito) {
    ContentSetting domainPermission = locationContentSettingForUrl(Uri.parse(url), isIncognito);
    switch (domainPermission) {
        case ALLOW:
            return PERMISSION_GRANTED;
        case ASK:
            return PERMISSION_PROMPT;
        default:
            return PERMISSION_BLOCKED;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:GeolocationHeader.java

示例14: PageInfoPermissionEntry

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
PageInfoPermissionEntry(String name, int type, ContentSetting setting) {
    this.name = name;
    this.type = type;
    this.setting = setting;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:WebsiteSettingsPopup.java

示例15: onFullscreenAllowed

import org.chromium.chrome.browser.preferences.website.ContentSetting; //导入依赖的package包/类
/**
 * Called when fullscreen is allowed for a particular origin.
 *
 * @param origin The site origin that fullscreen is allowed.
 */
@CalledByNative
private void onFullscreenAllowed(String origin) {
    FullscreenInfo fullscreenInfo = new FullscreenInfo(origin, null, mTab.isIncognito());
    fullscreenInfo.setContentSetting(ContentSetting.ALLOW);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:11,代码来源:FullscreenInfoBarDelegate.java


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