Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java

Issue 1474483004: WebView Metrics client implementation (Chromium part) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..4051c2379cb9efd78845f10b838845709f37f7eb
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/PlatformServiceBridge.java
@@ -0,0 +1,53 @@
+// 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
+ * 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) {}
+}
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwMetricsServiceClient.java ('k') | android_webview/native/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698