Commit 8204e1e8 authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Remove references to ChromeActivity from .c.b.omaha.notification

Instead, refer to Android Activity and ActivityLifecycleDispatcher.

Bug: 1123209
Change-Id: Ib073793ec0f78b7c7b1e0fcd9216f2fb9bf9b757
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472614Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819972}
parent 10617430
......@@ -263,15 +263,6 @@ specific_include_rules = {
"FakeAppUpdateManagerWrapper\.java": [
"+chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java",
],
"UpdateNotificationControllerFactory\.java": [
"+chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java",
],
"UpdateNotificationControllerImpl\.java": [
"+chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java",
],
"UpdateNotificationServiceBridge\.java": [
"+chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java",
],
"AutocompleteMediator\.java": [
"+chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java",
],
......
......@@ -1005,7 +1005,8 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
VrModuleProvider.getDelegate().onNewIntentWithNative(this, intent);
mIntentHandler.onNewIntent(intent);
if (mUpdateNotificationController == null) {
mUpdateNotificationController = UpdateNotificationControllerFactory.create(this);
mUpdateNotificationController =
UpdateNotificationControllerFactory.create(this, getLifecycleDispatcher());
}
mUpdateNotificationController.onNewIntent(intent);
}
......@@ -1053,8 +1054,8 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
if (isActivityFinishingOrDestroyed()) return;
UpdateInfoBarController.createInstance(ChromeActivity.this);
if (mUpdateNotificationController == null) {
mUpdateNotificationController =
UpdateNotificationControllerFactory.create(ChromeActivity.this);
mUpdateNotificationController = UpdateNotificationControllerFactory.create(
ChromeActivity.this, ChromeActivity.this.getLifecycleDispatcher());
}
mUpdateNotificationController.onNewIntent(getIntent());
});
......
......@@ -3,22 +3,26 @@
// found in the LICENSE file.
package org.chromium.chrome.browser.omaha.notification;
import org.chromium.chrome.browser.app.ChromeActivity;
import android.app.Activity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
/**
* A factory that creates an {@link UpdateNotificationController} instance.
*/
public class UpdateNotificationControllerFactory {
/**
* @param activity A {@link ChromeActivity} instance the notification will be shown in.
* @param activity Activity the notification will be shown in.
* @param lifecycleDispatcher Lifecycle of an Activity the notification will be shown in.
* @return a new {@link UpdateNotificationController} to use.
*/
public static UpdateNotificationController create(ChromeActivity activity) {
public static UpdateNotificationController create(
Activity activity, ActivityLifecycleDispatcher lifecycleDispatcher) {
if (ChromeFeatureList.isEnabled(
ChromeFeatureList.UPDATE_NOTIFICATION_SCHEDULING_INTEGRATION)) {
return new UpdateNotificationServiceBridge(activity);
return new UpdateNotificationServiceBridge(lifecycleDispatcher);
}
return new UpdateNotificationControllerImpl(activity);
return new UpdateNotificationControllerImpl(activity, lifecycleDispatcher);
}
}
......@@ -11,6 +11,7 @@ import static org.chromium.chrome.browser.omaha.UpdateConfigs.isUpdateNotificati
import static org.chromium.chrome.browser.omaha.UpdateStatusProvider.UpdateState.INLINE_UPDATE_AVAILABLE;
import static org.chromium.chrome.browser.omaha.UpdateStatusProvider.UpdateState.UPDATE_AVAILABLE;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
......@@ -23,10 +24,10 @@ import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.init.BrowserParts;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.init.EmptyBrowserParts;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.chrome.browser.notifications.NotificationUmaTracker;
......@@ -62,17 +63,21 @@ public class UpdateNotificationControllerImpl implements UpdateNotificationContr
processUpdateStatus();
};
private ChromeActivity mActivity;
private Activity mActivity;
private ActivityLifecycleDispatcher mActivityLifecycle;
private boolean mShouldStartInlineUpdate;
private @Nullable UpdateStatus mUpdateStatus;
/**
* @param activity A {@link ChromeActivity} instance the notification will be shown in.
* @param activity Activity the notification will be shown in.
* @param lifecycleDispatcher Lifecycle of an Activity the notification will be shown in.
*/
public UpdateNotificationControllerImpl(ChromeActivity activity) {
public UpdateNotificationControllerImpl(
Activity activity, ActivityLifecycleDispatcher lifecycleDispatcher) {
mActivity = activity;
mActivityLifecycle = lifecycleDispatcher;
UpdateStatusProvider.getInstance().addObserver(mObserver);
mActivity.getLifecycleDispatcher().register(this);
mActivityLifecycle.register(this);
}
// UpdateNotificationController implementation.
......@@ -87,7 +92,8 @@ public class UpdateNotificationControllerImpl implements UpdateNotificationContr
@Override
public void destroy() {
UpdateStatusProvider.getInstance().removeObserver(mObserver);
mActivity.getLifecycleDispatcher().unregister(this);
mActivityLifecycle.unregister(this);
mActivityLifecycle = null;
mActivity = null;
}
......
......@@ -19,8 +19,8 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.browser.omaha.UpdateStatusProvider;
import org.chromium.chrome.browser.omaha.UpdateStatusProvider.UpdateState;
......@@ -37,17 +37,17 @@ public class UpdateNotificationServiceBridge implements UpdateNotificationContro
processUpdateStatus();
};
private ChromeActivity mActivity;
private ActivityLifecycleDispatcher mActivityLifecycle;
private @Nullable UpdateStatusProvider.UpdateStatus mUpdateStatus;
private static final String TAG = "cr_UpdateNotif";
/**
* @param activity A {@link ChromeActivity} instance the notification will be shown in.
* @param lifecycleDispatcher Lifecycle of an Activity the notification will be shown in.
*/
public UpdateNotificationServiceBridge(ChromeActivity activity) {
mActivity = activity;
public UpdateNotificationServiceBridge(ActivityLifecycleDispatcher lifecycleDispatcher) {
mActivityLifecycle = lifecycleDispatcher;
UpdateStatusProvider.getInstance().addObserver(mObserver);
mActivity.getLifecycleDispatcher().register(this);
mActivityLifecycle.register(this);
}
// UpdateNotificationController implementation.
......@@ -60,8 +60,8 @@ public class UpdateNotificationServiceBridge implements UpdateNotificationContro
@Override
public void destroy() {
UpdateStatusProvider.getInstance().removeObserver(mObserver);
mActivity.getLifecycleDispatcher().unregister(this);
mActivity = null;
mActivityLifecycle.unregister(this);
mActivityLifecycle = null;
}
private void processUpdateStatus() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment