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 19e5a935d6b721306e3371fbc31881e8009aeb73..47968fa6cab096b696bd522848e1f0edca58a2a6 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 |
| @@ -9,6 +9,7 @@ import android.content.SharedPreferences; |
| import android.graphics.Bitmap; |
| import android.os.AsyncTask; |
| +import org.chromium.base.VisibleForTesting; |
| import org.chromium.chrome.browser.ShortcutHelper; |
| /** |
| @@ -23,6 +24,8 @@ public class WebappDataStorage { |
| static final String KEY_SPLASH_ICON = "splash_icon"; |
| static final String KEY_LAST_USED = "last_used"; |
| + private static Observer sObserver = new Observer(); |
| + |
| private final SharedPreferences mPreferences; |
| /** |
| @@ -50,6 +53,14 @@ public class WebappDataStorage { |
| .getLastUsedTime(callback); |
| } |
| + /** |
| + * Sets the observer to use. |
| + */ |
| + @VisibleForTesting |
| + public static void setObserverForTests(Observer observer) { |
| + sObserver = observer; |
| + } |
| + |
| private WebappDataStorage(Context context, String webappId) { |
| mPreferences = context.getSharedPreferences( |
| SHARED_PREFS_FILE_PREFIX + webappId, Context.MODE_PRIVATE); |
| @@ -70,6 +81,7 @@ public class WebappDataStorage { |
| * @param splashScreenImage The image which should be shown on the splash screen of the webapp. |
| */ |
| public void updateSplashScreenImage(Bitmap splashScreenImage) { |
| + sObserver.onUpdateSplashScreenImage(splashScreenImage); |
|
gone
2015/09/01 18:33:51
Why not set sObserver to null and check if it's nu
Lalit Maganti
2015/09/01 19:45:52
That's what I did initially when I wrote this CL b
gone
2015/09/01 20:50:53
Where exactly does AppBanner* code set an empty ob
|
| new UpdateTask(splashScreenImage).execute(); |
| } |
| @@ -108,6 +120,18 @@ public class WebappDataStorage { |
| public void onDataRetrieved(T readObject); |
| } |
| + /** |
| + * Observer used to check splash screen download in tests. |
| + */ |
|
gone
2015/09/01 18:33:51
* Don't bother saying it's for tests; it might be
Lalit Maganti
2015/09/01 19:45:52
Done.
|
| + public static class Observer { |
| + |
| + /** |
|
gone
2015/09/01 18:33:51
nit: indentation is off.
Lalit Maganti
2015/09/01 19:45:52
Done.
|
| + * Called when a splash screen update is queued. |
| + */ |
| + public void onUpdateSplashScreenImage(Bitmap image) { |
| + } |
| + } |
| + |
| private final class BitmapFetchTask extends AsyncTask<Void, Void, Bitmap> { |
| private final String mKey; |