Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java |
| index 748883e2c19ac3d657c0620881881775dc755490..6b38852d947b4b0413afa10d2762e90a5b51de20 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java |
| @@ -10,6 +10,7 @@ import android.graphics.Bitmap; |
| import android.os.AsyncTask; |
| import org.chromium.base.ThreadUtils; |
| +import org.chromium.base.VisibleForTesting; |
| import org.chromium.chrome.browser.ShortcutHelper; |
| /** |
| @@ -30,6 +31,8 @@ public class WebappDataStorage { |
| static final String KEY_LAST_USED = "last_used"; |
| static final long INVALID_LAST_USED = -1; |
| + private static Observer sObserver = null; |
| + |
| private final SharedPreferences mPreferences; |
| /** |
| @@ -76,6 +79,14 @@ public class WebappDataStorage { |
| }.execute(); |
| } |
| + /** |
| + * Sets the observer to use. |
| + */ |
| + @VisibleForTesting |
| + public static void setObserverForTests(Observer observer) { |
|
mlamouri (slow - plz ping)
2015/09/03 22:58:40
So, after talking with you and Dan, I think we sho
Lalit Maganti
2015/09/04 11:13:24
Changed as discussed.
|
| + sObserver = observer; |
| + } |
| + |
| /** Package private for use by WebappRegistry */ |
| WebappDataStorage(Context context, String webappId) { |
| mPreferences = context.getSharedPreferences( |
| @@ -97,6 +108,7 @@ public class WebappDataStorage { |
| * @param splashScreenImage The image which should be shown on the splash screen of the web app. |
| */ |
| public void updateSplashScreenImage(Bitmap splashScreenImage) { |
| + if (sObserver != null) sObserver.onUpdateSplashScreenImage(splashScreenImage); |
| new UpdateTask(splashScreenImage).execute(); |
| } |
| @@ -118,6 +130,18 @@ public class WebappDataStorage { |
| public void onDataRetrieved(T readObject); |
| } |
| + /** |
| + * Observer used to monitor splash screen downloads. |
| + */ |
| + public static interface Observer { |
| + |
| + /** |
| + * Called when a splash screen update is queued. |
| + */ |
| + @VisibleForTesting |
| + public void onUpdateSplashScreenImage(Bitmap image); |
| + } |
| + |
| private final class BitmapFetchTask extends AsyncTask<Void, Void, Bitmap> { |
| private final String mKey; |