Add SetJSFlags option in debug mode.
diff --git a/Android.v8.mk b/Android.v8.mk
index d0da67d..3edcc36 100644
--- a/Android.v8.mk
+++ b/Android.v8.mk
@@ -209,7 +209,7 @@
 endif
 
 # Build the list of static libraries
-LOCAL_STATIC_LIBRARIES += libxml2 libv8
+LOCAL_STATIC_LIBRARIES += libv8 libxml2
 
 # Redefine LOCAL_SRC_FILES to be all the WebKit source files
 LOCAL_SRC_FILES := $(WEBKIT_SRC_FILES)
diff --git a/V8Binding/Android.v8shell.mk b/V8Binding/Android.v8shell.mk
index 46cf4ee..09a77ef 100644
--- a/V8Binding/Android.v8shell.mk
+++ b/V8Binding/Android.v8shell.mk
@@ -7,6 +7,7 @@
 LOCAL_CPP_EXTENSION := .cc
 
 LOCAL_STATIC_LIBRARIES := libv8
+LOCAL_SHARED_LIBRARIES := libcutils
 
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/v8/include
 
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 2564da5..a879b6f 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -98,6 +98,11 @@
 #include "jni_utility.h"
 #include <wtf/CurrentTime.h>
 
+#if USE(V8)
+#include "CString.h"
+#include "ScriptController.h"
+#endif
+
 #if DEBUG_NAV_UI
 #include "SkTime.h"
 #endif
@@ -2382,6 +2387,20 @@
     viewImpl->dumpNavTree();
 }
 
+static void SetJsFlags(JNIEnv *env, jobject obj, jstring flags)
+{
+#if USE(V8)
+    // This code is called from UI thread, but it is safe to call setFlags
+    // on ScriptController since it initializes global variables only.
+    // As long as the WebCore thread does not change the default JS flags,
+    // it is safe to call it here.
+    WebCore::String flagsString = to_string(env, flags);
+    WebCore::CString utf8String = flagsString.utf8();
+    WebCore::ScriptController::setFlags(utf8String.data(), utf8String.length());
+#endif
+}
+
+
 // Called from the Java side to set a new quota for the origin in response.
 // to a notification that the original quota was exceeded.
 static void SetDatabaseQuota(JNIEnv* env, jobject obj, jlong quota) {
@@ -2544,6 +2563,7 @@
     { "nativePause", "()V", (void*) Pause },
     { "nativeResume", "()V", (void*) Resume },
     { "nativeFreeMemory", "()V", (void*) FreeMemory },
+    { "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags },
 };
 
 int register_webviewcore(JNIEnv* env)