com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback Java Examples

The following examples show how to use com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: X5WebChromeClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
@Override
/**
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if(geolocation != null && !geolocation.hasPermisssion())
    {
        geolocation.requestPermissions(0);
    }

}
 
Example #2
Source File: X5WebChromeClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
@Override
/**
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
  super.onGeolocationPermissionsShowPrompt(origin, callback);
  callback.invoke(origin, true, false);
  //Get the plugin, it should be loaded
  CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
  if (geolocation != null && !geolocation.hasPermisssion()) {
    geolocation.requestPermissions(0);
  }

}
 
Example #3
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
/**
 * 指定源的网页内容在没有设置权限状态下尝试使用地理位置API。
 * 从API24开始,此方法只为安全的源(https)调用,非安全的源会被自动拒绝
 * @param origin                            origin
 * @param geolocationPermissionsCallback    callback
 */
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback geolocationPermissionsCallback) {
    //boolean allow = true;   // 是否允许origin使用定位API
    //boolean retain = false; // 内核是否记住这次制授权
    //geolocationPermissionsCallback.invoke(origin, allow, retain);
    super.onGeolocationPermissionsShowPrompt(origin, geolocationPermissionsCallback);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int code = ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION);
        if (code != PackageManager.PERMISSION_GRANTED && context instanceof Activity) {
            // 还没有定位的授权,需要动态申请。
            ActivityCompat.requestPermissions((Activity) context,
                    new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_LOCATION);
        }
    }
}
 
Example #4
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
@Override
/**
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if(geolocation != null && !geolocation.hasPermisssion())
    {
        geolocation.requestPermissions(0);
    }

}
 
Example #5
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
Example #6
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@Override
public void onGeolocationPermissionsShowPrompt(String origin,
                                               GeolocationPermissionsCallback callback) {
    if (this.mRealWebChromeClient != null){
        this.mRealWebChromeClient.onGeolocationPermissionsShowPrompt(origin,  callback);
        return;
    }
    super.onGeolocationPermissionsShowPrompt(origin,callback);

}
 
Example #7
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {

    LogUtils.i(TAG, "onGeolocationPermissionsShowPrompt:" + origin + "   callback:" + callback);
    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onGeolocationPermissionsShowPrompt", "public void " + ChromePath + ".onGeolocationPermissionsShowPrompt", String.class, GeolocationPermissionsCallback.class)) {
        super.onGeolocationPermissionsShowPrompt(origin, callback);
        return;
    }
    onGeolocationPermissionsShowPromptInternal(origin, callback);
}
 
Example #8
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
private void onGeolocationPermissionsShowPromptInternal(String origin, GeolocationPermissionsCallback callback) {

        if (mPermissionInterceptor != null) {
            if (mPermissionInterceptor.intercept(this.mWebView.getUrl(), AgentWebX5Permissions.LOCATION, "location")) {
                callback.invoke(origin, false, false);
                return;
            }
        }

        Activity mActivity = mActivityWeakReference.get();
        if (mActivity == null) {
            callback.invoke(origin, false, false);
            return;
        }

        List<String> deniedPermissions = null;
        if ((deniedPermissions = AgentWebX5Utils.getDeniedPermissions(mActivity, AgentWebX5Permissions.LOCATION)).isEmpty()) {
            callback.invoke(origin, true, false);
        } else {

            ActionActivity.Action mAction = ActionActivity.Action.createPermissionsAction(deniedPermissions.toArray(new String[]{}));
            mAction.setFromIntention(FROM_CODE_INTENTION_LOCATION);
            ActionActivity.setPermissionListener(mPermissionListener);
            this.mCallback = callback;
            this.origin = origin;
            ActionActivity.start(mActivity, mAction);
        }


    }
 
Example #9
Source File: X5WebChromeClient.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
/**
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if(geolocation != null && !geolocation.hasPermisssion())
    {
        geolocation.requestPermissions(0);
    }

}
 
Example #10
Source File: WebChromeClientListener.java    From JsBridge with MIT License 2 votes vote down vote up
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback geolocationPermissionsCallback) {

}
 
Example #11
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback geolocationPermissionsCallback);