package com.ccpony.avchat;

import android.app.Activity;
import android.webkit.WebView;

import com.ccpony.avchat.peerconnection.PCManager;

public class JSController {
	private WebView	js_runtime = null;		 
	
	public JSController(Activity activity) {
		js_runtime = new WebView(activity);
		js_runtime.getSettings().setJavaScriptEnabled(true);		
	}
	
	public WebView get_webView() {
		return js_runtime;
	}
	
	public void start(String js_controller_url, PCManager pcManager) {
		js_runtime.addJavascriptInterface(pcManager, "pcManagerProxy");
		js_runtime.loadUrl(js_controller_url);
	}
	
	public void stop() {
		js_runtime.removeJavascriptInterface("pcManagerProxy");
		js_runtime.getSettings().setJavaScriptEnabled(false);
		js_runtime.loadUrl("");		
		js_runtime = null;	
	}
}

@@ -50,16 +50,80 @@
 tivity;%0A
+import android.util.Log;%0Aimport android.webkit.WebChromeClient;%0A
 import a
@@ -145,16 +145,16 @@
 ebView;%0A
-
 %0Aimport 
@@ -242,17 +242,17 @@
  WebView
-%09
+ 
 js_runti
@@ -265,13 +265,9 @@
 ull;
-%09%09 %0A%09
+%0A
 %0A%09pu
@@ -401,16 +401,274 @@
 ue);
+%0A
 %09%09%0A
+%09%09// %E8%B0%83%E8%AF%95%E6%94%AF%E6%8C%81%E7%94%A8%0A%09%09js_runtime.setWebChromeClient(new WebChromeClient() %7B%0A%09%09%09public void onConsoleMessage(String message, int lineNumber,%0A%09%09%09%09%09String sourceID) %7B%0A%09%09%09%09Log.d(%22js_runtime%22, message + %22 -- From line %22 + lineNumber%0A%09%09%09%09%09%09+ %22 of %22 + sourceID);%0A%09%09%09%7D%0A%09%09%7D);%0A
 %09%7D%0A
-%09
 %0A
+
 %09pub
@@ -715,26 +715,25 @@
 runtime;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -898,18 +898,17 @@
 rl);%0A%09%7D%0A
-%09
 %0A
+
 %09public 
@@ -1060,18 +1060,16 @@
 Url(%22%22);
-%09%09
 %0A%09%09js_ru
@@ -1081,15 +1081,14 @@
  = null;
-%09
 %0A%09%7D%0A%7D%0A

debug js