| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
|
| index 297953ff187599e7751df8d0002a09736433c858..95ac152183bdbe5931c02f36bc5bc8aa8c70ef32 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/GoogleServicesNotificationController.java
|
| @@ -10,6 +10,7 @@
|
| import android.content.Context;
|
| import android.content.Intent;
|
| import android.support.v4.app.NotificationCompat;
|
| +import android.util.Log;
|
|
|
| import org.chromium.base.VisibleForTesting;
|
| import org.chromium.chrome.R;
|
| @@ -26,31 +27,29 @@
|
| private static final Object LOCK = new Object();
|
|
|
| private static GoogleServicesNotificationController sInstance;
|
| + private static NotificationManagerProxy sNotificationManagerProxyOverride;
|
|
|
| private final Context mApplicationContext;
|
| - private NotificationManagerProxy mNotificationManager;
|
| + private final NotificationManagerProxy mNotificationManager;
|
|
|
| - /**
|
| - * Retrieve the singleton instance of this class.
|
| - *
|
| - * @param context the current context.
|
| - * @return the singleton instance.
|
| - */
|
| - public static GoogleServicesNotificationController get(Context context) {
|
| + @VisibleForTesting
|
| + public static void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
|
| + sNotificationManagerProxyOverride = managerProxy;
|
| + }
|
| +
|
| + public static GoogleServicesNotificationController createNewInstance(Context context) {
|
| synchronized (LOCK) {
|
| if (sInstance == null) {
|
| sInstance = new GoogleServicesNotificationController(context);
|
| + } else {
|
| + Log.e(TAG, "GoogleServicesNotificationController already created. "
|
| + + "Currently on thread: " + Thread.currentThread());
|
| }
|
| return sInstance;
|
| }
|
| }
|
|
|
| - @Deprecated
|
| - public static GoogleServicesNotificationController createNewInstance(Context context) {
|
| - return get(context);
|
| - }
|
| -
|
| - @Deprecated
|
| + @VisibleForTesting
|
| public static GoogleServicesNotificationController getInstance() {
|
| synchronized (LOCK) {
|
| return sInstance;
|
| @@ -64,9 +63,13 @@
|
|
|
| private GoogleServicesNotificationController(Context context) {
|
| mApplicationContext = context.getApplicationContext();
|
| - mNotificationManager = new NotificationManagerProxyImpl(
|
| - (NotificationManager) mApplicationContext.getSystemService(
|
| - Context.NOTIFICATION_SERVICE));
|
| + if (sNotificationManagerProxyOverride == null) {
|
| + mNotificationManager = new NotificationManagerProxyImpl(
|
| + (NotificationManager) mApplicationContext.getSystemService(
|
| + Context.NOTIFICATION_SERVICE));
|
| + } else {
|
| + mNotificationManager = sNotificationManagerProxyOverride;
|
| + }
|
| }
|
|
|
| public void updateSingleNotification(int id, String message, Intent intent) {
|
| @@ -104,9 +107,4 @@
|
| public void cancelNotification(int id) {
|
| mNotificationManager.cancel(id);
|
| }
|
| -
|
| - @VisibleForTesting
|
| - public void overrideNotificationManagerForTests(NotificationManagerProxy managerProxy) {
|
| - mNotificationManager = managerProxy;
|
| - }
|
| }
|
|
|