Add requestCenterFitZoom to android_npapi so that
Flash can trigger the smart-zoom

Fix http://b/issue?id=2510670
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index bee6fb9..3a2a427 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -230,6 +230,7 @@
     jmethodID   m_getContext;
     jmethodID   m_sendFindAgain;
     jmethodID   m_showRect;
+    jmethodID   m_centerFitRect;
     AutoJObject object(JNIEnv* env) {
         return getRealObject(env, m_obj);
     }
@@ -319,6 +320,7 @@
     m_javaGlue->m_getContext = GetJMethod(env, clazz, "getContext", "()Landroid/content/Context;");
     m_javaGlue->m_sendFindAgain = GetJMethod(env, clazz, "sendFindAgain", "()V");
     m_javaGlue->m_showRect = GetJMethod(env, clazz, "showRect", "(IIIIIIFFFF)V");
+    m_javaGlue->m_centerFitRect = GetJMethod(env, clazz, "centerFitRect", "(IIII)V");
 
     env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this);
 
@@ -2480,6 +2482,14 @@
     checkException(env);
 }
 
+void WebViewCore::centerFitRect(int x, int y, int width, int height)
+{
+    JNIEnv* env = JSC::Bindings::getJNIEnv();
+    env->CallVoidMethod(m_javaGlue->object(env).get(),
+            m_javaGlue->m_centerFitRect, x, y, width, height);
+    checkException(env);
+}
+
 //----------------------------------------------------------------------
 // Native JNI methods
 //----------------------------------------------------------------------
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 2bb45a6..608643e 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -425,6 +425,10 @@
             int contentHeight, float xPercentInDoc, float xPercentInView,
             float yPercentInDoc, float yPercentInView);
 
+        // Scale the rect (x, y, width, height) to make it just fit and centered
+        // in the current view.
+        void centerFitRect(int x, int y, int width, int height);
+
         // other public functions
     public:
         // Open a file chooser for selecting a file to upload
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index bb7b9a3..0a31ed3 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -67,6 +67,12 @@
     pluginWidget->exitFullScreen(true);
 }
 
+static void anp_requestCenterFitZoom(NPP instance) {
+    PluginView* pluginView = pluginViewForInstance(instance);
+    PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+    pluginWidget->requestCenterFitZoom();
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 #define ASSIGN(obj, name)   (obj)->name = anp_##name
@@ -79,4 +85,5 @@
     ASSIGN(i, showKeyboard);
     ASSIGN(i, requestFullScreen);
     ASSIGN(i, exitFullScreen);
+    ASSIGN(i, requestCenterFitZoom);
 }
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 7642f13..e1d6bb4 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -530,3 +530,9 @@
 
     m_isFullScreen = false;
 }
+
+void PluginWidgetAndroid::requestCenterFitZoom() {
+    m_core->centerFitRect(m_pluginWindow->x, m_pluginWindow->y,
+            m_pluginWindow->width, m_pluginWindow->height);
+}
+
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 7223a16..e71413d 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -148,6 +148,10 @@
      */
     void updateSurfaceIfNeeded(bool pluginBoundsChanged = false);
 
+    /** Called when a plugin wishes to be zoomed and centered in the current view.
+     */
+    void requestCenterFitZoom();
+
 private:
     void computeVisiblePluginRect();
     void scrollToVisiblePluginRect();
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 0ddc763..b4974f4 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -666,6 +666,9 @@
         the plugin's full screen view will be discarded by the view system.
      */
     void    (*exitFullScreen)(NPP instance);
+    /** Called when a plugin wishes to be zoomed and centered in the current view.
+     */
+    void    (*requestCenterFitZoom)(NPP instance);
 };
 
 ///////////////////////////////////////////////////////////////////////////////