From ce259207909174ed4c1654964a0f448bc275197d Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 23 Oct 2014 17:36:32 +0100 Subject: 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 (cherry picked from commit 9f3473ac53192eca3e10c9a1dd3614dea48ea8a7) --- .../android/webview/chromium/WebViewChromium.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'chromium') diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java index 6cf4238..b38c40d 100644 --- a/chromium/java/com/android/webview/chromium/WebViewChromium.java +++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java @@ -1348,19 +1348,27 @@ class WebViewChromium implements WebViewProvider, 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; - } - try { - client.getClass().getDeclaredMethod("onShowCustomView", View.class, - CustomViewCallback.class); - client.getClass().getDeclaredMethod("onHideCustomView"); - return true; - } catch (NoSuchMethodException e) { - 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(); } + return foundShowMethod && foundHideMethod; } @Override -- cgit v1.2.3