Fix reflection for detecting fullscreen API support.

We need to check the class hierarchy for the methods, all the way
up to the direct child of WebChromeClient.

Bug: 18099831
Change-Id: Ib1c647643e601015eb1bc16c613d51aca4cf38c6
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java
index e29c3d3..d6aaed1 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromium.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java
@@ -1344,19 +1344,27 @@
         if (client == null) {
             return false;
         }
-        // If client is not a subclass of WebChromeClient then the methods have not been
-        // implemented because WebChromeClient has empty implementations.
-        if (client.getClass().isAssignableFrom(WebChromeClient.class)) {
-            return false;
+        Class<?> clientClass = client.getClass();
+        boolean foundShowMethod = false;
+        boolean foundHideMethod = false;
+        while (clientClass != WebChromeClient.class && (!foundShowMethod || !foundHideMethod)) {
+            if (!foundShowMethod) {
+                try {
+                    clientClass.getDeclaredMethod("onShowCustomView", View.class,
+                            CustomViewCallback.class);
+                    foundShowMethod = true;
+                } catch (NoSuchMethodException e) { }
+            }
+
+            if (!foundHideMethod) {
+                try {
+                    clientClass.getDeclaredMethod("onHideCustomView");
+                    foundHideMethod = true;
+                } catch (NoSuchMethodException e) { }
+            }
+            clientClass = clientClass.getSuperclass();
         }
-        try {
-            client.getClass().getDeclaredMethod("onShowCustomView", View.class,
-                    CustomViewCallback.class);
-            client.getClass().getDeclaredMethod("onHideCustomView");
-            return true;
-        } catch (NoSuchMethodException e) {
-            return false;
-        }
+        return foundShowMethod && foundHideMethod;
     }
 
     @Override