Index: android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java b/android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cc078264449cf0063ae5094246693e68e329d9ee |
--- /dev/null |
+++ b/android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java |
@@ -0,0 +1,54 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.android_webview; |
+ |
+import android.content.Context; |
+import android.webkit.ValueCallback; |
+ |
+import org.chromium.base.Log; |
+ |
+import java.lang.reflect.InvocationTargetException; |
+ |
+/** |
+ * This class manages platform-specific services. (i.e. Google Services) The platform |
sgurun-gerrit only
2015/12/21 21:47:26
It is actually the Google Webview implementation t
paulmiller
2015/12/22 19:42:04
Google WebView is part of the "platform". Since th
sgurun-gerrit only
2015/12/23 00:08:55
Himm, Webview is part of the frameworks actually.
|
+ * should extend this class and use this base class to fetch their specialized version. |
+ */ |
+public class PlatformServiceBridge { |
+ private static final String TAG = "PlatformServiceBrid-"; |
+ private static final String PLATFORM_SERVICE_BRIDGE = |
+ "com.android.webview.chromium.PlatformServiceBridgeGoogle"; |
+ |
+ private static PlatformServiceBridge sInstance; |
+ |
+ protected PlatformServiceBridge() {} |
+ |
+ public static PlatformServiceBridge getInstance(Context applicationContext) { |
+ if (sInstance != null) { |
+ return sInstance; |
+ } |
+ |
+ // Try to get a specialized service bridge. |
+ try { |
+ Class<?> cls = Class.forName(PLATFORM_SERVICE_BRIDGE); |
+ sInstance = (PlatformServiceBridge) cls.getDeclaredConstructor(Context.class) |
+ .newInstance(applicationContext); |
+ return sInstance; |
+ } catch (ClassNotFoundException e) { |
+ // This is not an error; it just means this device doesn't have specialized services. |
+ } catch (IllegalAccessException | IllegalArgumentException | InstantiationException |
+ | NoSuchMethodException e) { |
+ Log.e(TAG, "Failed to get " + PLATFORM_SERVICE_BRIDGE + ": " + e); |
+ } catch (InvocationTargetException e) { |
+ Log.e(TAG, "Failed invocation to get " + PLATFORM_SERVICE_BRIDGE + ":", |
+ e.getCause()); |
+ } |
+ |
+ // Otherwise, get the generic service bridge. |
+ sInstance = new PlatformServiceBridge(); |
+ return sInstance; |
+ } |
+ |
+ public void setMetricsSettingListener(ValueCallback<Boolean> callback) {} |
+} |