本文整理了Java中android.webkit.WebView.removeJavascriptInterface()
方法的一些代码示例,展示了WebView.removeJavascriptInterface()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.removeJavascriptInterface()
方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:removeJavascriptInterface
暂无
代码示例来源:origin: Justson/AgentWeb
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void dealHoneyComb(WebView view) {
if (Build.VERSION_CODES.HONEYCOMB > Build.VERSION.SDK_INT || Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1){
return;
}
view.removeJavascriptInterface("searchBoxJavaBridge_");
view.removeJavascriptInterface("accessibility");
view.removeJavascriptInterface("accessibilityTraversal");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldRemoveJavascriptInterfaces() {
String name = "myJavascriptInterface";
webView.addJavascriptInterface(new Object(), name);
assertThat(shadowOf(webView).getJavascriptInterface(name)).isNotNull();
webView.removeJavascriptInterface(name);
assertThat(shadowOf(webView).getJavascriptInterface(name)).isNull();
}
代码示例来源:origin: weexteam/weex-hackernews
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onException(NestedContainer comp, String errCode, String msg) {
//downgrade embed
if( errCode != null && comp instanceof WXEmbed && errCode.startsWith("1|")) {
ViewGroup container = comp.getViewContainer();
WebView webView = new WebView(container.getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
webView.setLayoutParams(params);
webView.getSettings().setJavaScriptEnabled(true);
//WebView Remote Code Execution Vulnerability
webView.removeJavascriptInterface("searchBoxJavaBridge_");
webView.removeJavascriptInterface("accessibility");
webView.removeJavascriptInterface("accessibilityTraversal");
webView.getSettings().setSavePassword(false);
container.removeAllViews();
container.addView(webView);
webView.loadUrl(((WXEmbed) comp).src);
}else{
super.onException(comp,errCode,msg);
}
}
}
代码示例来源:origin: luili16/UIMocker
@Override
public void removeJavascriptInterface(String name) {
mWebView.removeJavascriptInterface(name);
}
代码示例来源:origin: AlexMofer/ProjectX
private void onRemove(WebView view) {
view.removeJavascriptInterface(mName);
}
代码示例来源:origin: yangchong211/YCAudioPlayer
/**
* 例如,该案例中链接来于喜马拉雅,支付宝,购物网站等等,就需要注意程序漏洞
* 如果启用了JavaScript,务必做好安全措施,防止远程执行漏洞
*
* @param webView webView控件
*/
@SuppressLint("ObsoleteSdkInt")
@TargetApi(11) //支持api11以上
private void removeJavascriptInterfaces(WebView webView) {
try {
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 17) {
webView.removeJavascriptInterface("searchBoxJavaBridge_");
webView.removeJavascriptInterface("accessibility");
webView.removeJavascriptInterface("accessibilityTraversal");
}
} catch (Throwable tr) {
tr.printStackTrace();
}
}
代码示例来源:origin: onlyloveyd/JuheNews
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
ButterKnife.bind(this);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
URL = bundle.getString("URL");
}
setSupportActionBar(tlWeb);
tlWeb.setNavigationIcon(R.drawable.back);
tlWeb.setTitleTextAppearance(this, R.style.ToolBarTextAppearance);
initWebViewSettings();
wvContent.removeJavascriptInterface("searchBoxJavaBridge_");
wvContent.removeJavascriptInterface("accessibilityTraversal");
wvContent.removeJavascriptInterface("accessibility");
wvContent.loadUrl(URL);
}
代码示例来源:origin: Null-Ouwenjie/zhizhihu
mWebView.removeJavascriptInterface("searchBoxJavaBridge_");
内容来源于网络,如有侵权,请联系作者删除!