added gain/loose focus support for plugins. (focus = eligible to receive user events)
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 30cafc5..5622744 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -237,17 +237,12 @@
 void PluginView::handleMouseEvent(MouseEvent* event)
 {
     const AtomicString& type = event->type();
-    bool isOut = (eventNames().mouseoutEvent == type);
     bool isUp = (eventNames().mouseupEvent == type);
     bool isDown = (eventNames().mousedownEvent == type);
 
     ANPEvent    evt;
 
-    if (isOut) {
-        SkANP::InitEvent(&evt, kLifecycle_ANPEventType);
-        evt.data.lifecycle.action = kLooseFocus_ANPLifecycleAction;
-    }
-    else if (isUp || isDown) {
+    if (isUp || isDown) {
         SkANP::InitEvent(&evt, kMouse_ANPEventType);
         evt.data.mouse.action = isUp ? kUp_ANPMouseAction : kDown_ANPMouseAction;
         // these are relative to plugin
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 142f0de..57d324c 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -69,6 +69,7 @@
 #include "PlatformKeyboardEvent.h"
 #include "PlatformString.h"
 #include "PluginWidgetAndroid.h"
+#include "PluginView.h"
 #include "Position.h"
 #include "ProgressTracker.h"
 #include "RenderBox.h"
@@ -1185,13 +1186,14 @@
     }
 }
 
-static bool nodeIsPlugin(Node* node) {
+static PluginView* nodeIsPlugin(Node* node) {
     RenderObject* renderer = node->renderer();
     if (renderer && renderer->isWidget()) {
         Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
-        return widget && widget->isPluginView();
+        if (widget && widget->isPluginView())
+            return static_cast<PluginView*>(widget);
     }
-    return false;
+    return 0;
 }
 
 Node* WebViewCore::cursorNodeIsPlugin() {
@@ -1208,6 +1210,32 @@
 }
 
 
+void WebViewCore::updatePluginState(Frame* frame, Node* node, PluginState state) {
+
+    // check that the node and frame pointers are (still) valid
+    if (!frame || !node || !CacheBuilder::validNode(m_mainFrame, frame, node))
+        return;
+
+    // check that the node is a plugin view
+    PluginView* pluginView = nodeIsPlugin(node);
+    if (!pluginView)
+        return;
+
+    // create the event
+    ANPEvent event;
+    SkANP::InitEvent(&event, kLifecycle_ANPEventType);
+
+    if (state == kLoseFocus_PluginState)
+        event.data.lifecycle.action = kLooseFocus_ANPLifecycleAction;
+    else if (state == kGainFocus_PluginState)
+        event.data.lifecycle.action = kGainFocus_ANPLifecycleAction;
+    else
+        return;
+
+    // send the event
+    pluginView->platformPluginWidget()->sendEvent(event);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 void WebViewCore::moveMouseIfLatest(int moveGeneration,
     WebCore::Frame* frame, int x, int y)
@@ -2454,6 +2482,17 @@
     return GET_NATIVE_VIEW(env, obj)->pictureReady();
 }
 
+static void UpdatePluginState(JNIEnv* env, jobject obj, jint framePtr, jint nodePtr, jint state)
+{
+#ifdef ANDROID_INSTRUMENT
+    TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
+    WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+    LOG_ASSERT(viewImpl, "viewImpl not set in nativeUpdatePluginState");
+    viewImpl->updatePluginState((WebCore::Frame*) framePtr, (WebCore::Node*) nodePtr,
+                                (PluginState) state);
+}
+
 static void Pause(JNIEnv* env, jobject obj)
 {
     ANPEvent event;
@@ -2562,6 +2601,7 @@
     { "nativeResume", "()V", (void*) Resume },
     { "nativeFreeMemory", "()V", (void*) FreeMemory },
     { "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags },
+    { "nativeUpdatePluginState", "(III)V", (void*) UpdatePluginState },
 };
 
 int register_webviewcore(JNIEnv* env)
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index f076bf1..fe1caa2 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -60,6 +60,11 @@
 
 namespace android {
 
+    enum PluginState {
+        kGainFocus_PluginState  = 0,
+        kLoseFocus_PluginState  = 1,
+    };
+
     class CachedRoot;
     class ListBoxReply;
 
@@ -298,6 +303,9 @@
         // return the cursorNode if it is a plugin
         Node* cursorNodeIsPlugin();
 
+        // notify the plugin of an update in state
+        void updatePluginState(Frame* frame, Node* node, PluginState state);
+
         // Notify the Java side whether it needs to pass down the touch events
         void needTouchEvents(bool);
 
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 74acdf7..56570a6 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -98,6 +98,7 @@
     jobject     m_obj;
     jmethodID   m_clearTextEntry;
     jmethodID   m_overrideLoading;
+    jmethodID   m_sendPluginState;
     jmethodID   m_scrollBy;
     jmethodID   m_sendMoveMouse;
     jmethodID   m_sendMoveMouseIfLatest;
@@ -127,6 +128,7 @@
     m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)V");
     m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V");
     m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V");
+    m_javaGlue.m_sendPluginState = GetJMethod(env, clazz, "sendPluginState", "(I)V");
     m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V");
     m_javaGlue.m_sendMoveMouseIfLatest = GetJMethod(env, clazz, "sendMoveMouseIfLatest", "(Z)V");
     m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIIII)V");
@@ -161,7 +163,10 @@
     m_matches = 0;
     m_hasCurrentLocation = false;
     m_isFindPaintSetUp = false;
-    m_pluginReceivesEvents = false;
+    m_pluginReceivesEvents = false; // initialization is the only time this
+                                    // variable should be set directly, all
+                                    // other changes should be made through
+                                    // setPluginReceivesEvents(bool)
 }
 
 ~WebView()
@@ -407,7 +412,8 @@
 
 void resetCursorRing()
 {
-    m_followedLink = m_pluginReceivesEvents = false;
+    m_followedLink = false;
+    setPluginReceivesEvents(false);
     m_viewImpl->m_hasCursorBounds = false;
 }
 
@@ -471,7 +477,8 @@
         DBG_NAV_LOGD("canvas->quickReject cursorNode=%d (nodePointer=%p)"
             " bounds=(%d,%d,w=%d,h=%d)", node->index(), node->nodePointer(),
             bounds.x(), bounds.y(), bounds.width(), bounds.height());
-        m_followedLink = m_pluginReceivesEvents = false;
+        m_followedLink = false;
+        setPluginReceivesEvents(false);
         return;
     }
     CursorRing::Flavor flavor = CursorRing::NORMAL_FLAVOR;
@@ -728,7 +735,7 @@
 /* returns true if the key had no effect (neither scrolled nor changed cursor) */
 bool moveCursor(int keyCode, int count, bool ignoreScroll)
 {
-    m_pluginReceivesEvents = false;
+    setPluginReceivesEvents(false);
     CachedRoot* root = getFrameCache(AllowNewer);
     if (!root) {
         DBG_NAV_LOG("!root");
@@ -902,7 +909,7 @@
 bool motionUp(int x, int y, int slop)
 {
     bool pageScrolled = false;
-    m_followedLink = m_pluginReceivesEvents = false;
+    m_followedLink = false;
     const CachedFrame* frame;
     WebCore::IntRect rect = WebCore::IntRect(x - slop, y - slop, slop * 2, slop * 2);
     int rx, ry;
@@ -924,6 +931,7 @@
             0, x, y, slop);
         viewInvalidate();
         clearTextEntry();
+        setPluginReceivesEvents(false);
         return pageScrolled;
     }
     DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result,
@@ -968,13 +976,28 @@
         m_hasCurrentLocation = false;
 }
 
+void setPluginReceivesEvents(bool value)
+{
+    if (value == m_pluginReceivesEvents)
+        return;
+
+    //send message to plugin in webkit
+    JNIEnv* env = JSC::Bindings::getJNIEnv();
+    env->CallVoidMethod(m_javaGlue.object(env).get(),
+                        m_javaGlue.m_sendPluginState,
+                        value ? kGainFocus_PluginState : kLoseFocus_PluginState);
+    checkException(env);
+
+    m_pluginReceivesEvents = value;
+}
+
 void updatePluginReceivesEvents()
 {
     CachedRoot* root = getFrameCache(DontAllowNewer);
     if (!root)
         return;
     const CachedNode* cursor = root->currentCursor();
-    m_pluginReceivesEvents = cursor && cursor->isPlugin();
+    setPluginReceivesEvents(cursor && cursor->isPlugin());
     DBG_NAV_LOGD("m_pluginReceivesEvents=%s cursor=%p", m_pluginReceivesEvents
         ? "true" : "false", cursor);
 }