本文整理汇总了Java中org.chromium.chrome.browser.preferences.website.ContentSetting.ASK属性的典型用法代码示例。如果您正苦于以下问题:Java ContentSetting.ASK属性的具体用法?Java ContentSetting.ASK怎么用?Java ContentSetting.ASK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.chromium.chrome.browser.preferences.website.ContentSetting
的用法示例。
在下文中一共展示了ContentSetting.ASK属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maybeCreatePermissionForDefaultSearchEngine
/**
* 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();
}
}
示例2: maybeCreatePermissionForDefaultSearchEngine
/**
* 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();
}
}
示例3: locationShouldBeShown
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);
}
示例4: locationEnabled
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;
}
示例5: locationEnabled
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;
}
示例6: locationEnabled
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;
}