/**
  * 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);
   ContentSetting locationPermission = locationSettings.getContentSetting();
   if (locationPermission == null || locationPermission == ContentSetting.ASK) {
     WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(
         url, url, allowed ? ContentSetting.ALLOW.toInt() : ContentSetting.BLOCK.toInt());
     SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
     sharedPreferences.edit().putBoolean(LOCATION_AUTO_ALLOWED, true).apply();
   }
 }
 /**
  * Adds/Edit a popup exception
  *
  * @param pattern attribute for the popup exception pattern
  * @param allow attribute to specify whether to allow or block pattern
  */
 public void setPopupException(String pattern, boolean allow) {
   nativeSetPopupException(
       pattern, allow ? ContentSetting.ALLOW.toInt() : ContentSetting.BLOCK.toInt());
 }
 /**
  * Sets whether JavaScript is allowed to run on the given website/domain.
  *
  * @param pattern A pattern that matches one or multiple domains. For details see examples in
  *     content_settings_pattern.h.
  * @param allow Whether to allow JavaScript on the given site/domain.
  */
 public void setJavaScriptAllowed(String pattern, boolean allow) {
   nativeSetJavaScriptAllowed(
       pattern, allow ? ContentSetting.ALLOW.toInt() : ContentSetting.BLOCK.toInt());
 }