Implement the full screen WebView plugin.

Use a NoTitleBar_Fullscreen dialog to implement the
full screen plugin. This runs in the same thread as
WebView (UI in the Browser case). One catch is that
the SurfaceView provided by the plugin needs to be
opaque if it doesn't want to see through the WebView.

The PluginFullScreenHolder translates the events to
the underline WebView. Special treatment in the touch
case as it needs to translate the coordinates.

WebView can't be panned, or double tap to zoom, or
long press to trigger the context menu while having
a full screen plugin.

Inside webkit, we also give the plugin element focus
when it goes to the full screen so that it takes key
events. While handling key events, we don't let it 
loose focus or scroll out.

Todo:
When a plugin goes to full screen, we should make
sure the embedded plugin is fully visible. Otherwise
when we translate the touch events back, they will be
outside of the visible rect and will be ignored.

This is part 2 of 2-project check in.
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 4266a9a..69e0541 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -348,6 +348,10 @@
 
     if (m_plugin->pluginFuncs()->event(m_instance, &evt)) {
         event->setDefaultHandled();
+    } else if (m_window->inFullScreen()){
+        // while in the full screen mode, always consumes the key events and
+        // keeps the document focus
+        event->setDefaultHandled();
     } else {
         // remove the plugin from the document's focus
         m_parentFrame->document()->focusedNodeRemoved();
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index e62b362..26bf315 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -212,6 +212,7 @@
     jmethodID   m_createPluginJavaInstance;
     jmethodID   m_showFullScreenPlugin;
     jmethodID   m_hideFullScreenPlugin;
+    jmethodID   m_updateFullScreenPlugin;
     jmethodID   m_createSurface;
     jmethodID   m_updateSurface;
     jmethodID   m_destroySurface;
@@ -291,8 +292,9 @@
     m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V");
     m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
     m_javaGlue->m_createPluginJavaInstance = GetJMethod(env, clazz, "createPluginJavaInstance", "(Ljava/lang/String;I)Landroid/webkit/plugin/WebkitPlugin;");
-    m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/plugin/WebkitPlugin;I)V");
+    m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/plugin/WebkitPlugin;IIIII)V");
     m_javaGlue->m_hideFullScreenPlugin = GetJMethod(env, clazz, "hideFullScreenPlugin", "()V");
+    m_javaGlue->m_updateFullScreenPlugin = GetJMethod(env, clazz, "updateFullScreenPlugin", "(IIII)V");
     m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Landroid/webkit/plugin/WebkitPlugin;IIII)Landroid/webkit/ViewManager$ChildView;");
     m_javaGlue->m_updateSurface = GetJMethod(env, clazz, "updateSurface", "(Landroid/webkit/ViewManager$ChildView;IIII)V");
     m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/webkit/ViewManager$ChildView;)V");
@@ -2560,7 +2562,8 @@
     return result;
 }
 
-void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp)
+void WebViewCore::showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x,
+        int y, int width, int height)
 {
     JNIEnv* env = JSC::Bindings::getJNIEnv();
     AutoJObject obj = m_javaGlue->object(env);
@@ -2571,7 +2574,7 @@
 
     env->CallVoidMethod(obj.get(),
                         m_javaGlue->m_showFullScreenPlugin,
-                        webkitPlugin, (int)npp);
+                        webkitPlugin, (int)npp, x, y, width, height);
     checkException(env);
 }
 
@@ -2588,6 +2591,20 @@
     checkException(env);
 }
 
+void WebViewCore::updateFullScreenPlugin(int x, int y, int width, int height)
+{
+    JNIEnv* env = JSC::Bindings::getJNIEnv();
+    AutoJObject obj = m_javaGlue->object(env);
+    // if it is called during DESTROY is handled, the real object of WebViewCore
+    // can be gone. Check before using it.
+    if (!obj.get())
+        return;
+
+    env->CallVoidMethod(obj.get(), m_javaGlue->m_updateFullScreenPlugin, x, y,
+            width, height);
+    checkException(env);
+}
+
 jobject WebViewCore::createSurface(jobject webkitPlugin, int x, int y, int width, int height)
 {
     JNIEnv* env = JSC::Bindings::getJNIEnv();
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 21dd51b..4c8de78 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -383,11 +383,14 @@
         jobject createPluginJavaInstance(const WebCore::String& libName, NPP npp);
 
         // Creates a full screen surface for a plugin
-        void showFullScreenPlugin(jobject webkitPlugin, NPP npp);
+        void showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x, int y, int width, int height);
 
         // Instructs the UI thread to discard the plugin's full-screen surface
         void hideFullScreenPlugin();
 
+        // Update coordinates and dimensions for a full screen plugin
+        void updateFullScreenPlugin(int x, int y, int width, int height);
+
         // Creates a Surface (i.e. View) for a plugin
         jobject createSurface(jobject webkitPlugin, int x, int y, int width, int height);
 
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index c8c2c70..f3304a9 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -54,6 +54,8 @@
 
 static void anp_requestFullScreen(NPP instance) {
     PluginView* pluginView = pluginViewForInstance(instance);
+    // call focusPluginElement() so that the pluginView receives keyboard events
+    pluginView->focusPluginElement();
     PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
     pluginWidget->requestFullScreen();
 }
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index f8862b2..cd7076d 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -135,6 +135,10 @@
                 m_embeddedView = env->NewGlobalRef(tempObj);
             }
         }
+        if (m_isFullScreen && m_pluginBounds != oldPluginBounds) {
+            m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(),
+                    window->width, window->height);
+        }
     } else {
         m_flipPixelRef->safeUnref();
         m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent),
@@ -437,7 +441,10 @@
         return;
     }
 
-    m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance());
+    IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y);
+    m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance(),
+            docPoint.x(), docPoint.y(), m_pluginWindow->width,
+            m_pluginWindow->height);
     m_isFullScreen = true;
 }
 
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index ef3e40c..3a76073 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -145,6 +145,8 @@
      */
     void exitFullScreen(bool pluginInitiated);
 
+    bool inFullScreen() { return m_isFullScreen; }
+
 private:
     WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const;
     void computeVisibleFrameRect();