OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.android_webview; | |
6 | |
7 import android.content.Context; | |
8 import android.webkit.ValueCallback; | |
9 | |
10 import org.chromium.base.Log; | |
11 | |
12 import java.lang.reflect.InvocationTargetException; | |
13 | |
14 /** | |
15 * This class manages platform-specific services. (i.e. Google Services) The pla tform | |
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.
| |
16 * should extend this class and use this base class to fetch their specialized v ersion. | |
17 */ | |
18 public class PlatformServiceBridge { | |
19 private static final String TAG = "PlatformServiceBrid-"; | |
20 private static final String PLATFORM_SERVICE_BRIDGE = | |
21 "com.android.webview.chromium.PlatformServiceBridgeGoogle"; | |
22 | |
23 private static PlatformServiceBridge sInstance; | |
24 | |
25 protected PlatformServiceBridge() {} | |
26 | |
27 public static PlatformServiceBridge getInstance(Context applicationContext) { | |
28 if (sInstance != null) { | |
29 return sInstance; | |
30 } | |
31 | |
32 // Try to get a specialized service bridge. | |
33 try { | |
34 Class<?> cls = Class.forName(PLATFORM_SERVICE_BRIDGE); | |
35 sInstance = (PlatformServiceBridge) cls.getDeclaredConstructor(Conte xt.class) | |
36 .newInstance(applicationContext); | |
37 return sInstance; | |
38 } catch (ClassNotFoundException e) { | |
39 // This is not an error; it just means this device doesn't have spec ialized services. | |
40 } catch (IllegalAccessException | IllegalArgumentException | Instantiati onException | |
41 | NoSuchMethodException e) { | |
42 Log.e(TAG, "Failed to get " + PLATFORM_SERVICE_BRIDGE + ": " + e); | |
43 } catch (InvocationTargetException e) { | |
44 Log.e(TAG, "Failed invocation to get " + PLATFORM_SERVICE_BRIDGE + " :", | |
45 e.getCause()); | |
46 } | |
47 | |
48 // Otherwise, get the generic service bridge. | |
49 sInstance = new PlatformServiceBridge(); | |
50 return sInstance; | |
51 } | |
52 | |
53 public void setMetricsSettingListener(ValueCallback<Boolean> callback) {} | |
54 } | |
OLD | NEW |