OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.pm.PackageInfo; | 7 import android.content.pm.PackageInfo; |
8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 if (isShellApkVersionOutOfDate(info)) return true; | 288 if (isShellApkVersionOutOfDate(info)) return true; |
289 | 289 |
290 return mStorage.shouldCheckForUpdate(); | 290 return mStorage.shouldCheckForUpdate(); |
291 } | 291 } |
292 | 292 |
293 /** | 293 /** |
294 * Updates {@link WebappDataStorage} with the time of the latest WebAPK upda
te and whether the | 294 * Updates {@link WebappDataStorage} with the time of the latest WebAPK upda
te and whether the |
295 * WebAPK update succeeded. | 295 * WebAPK update succeeded. |
296 */ | 296 */ |
297 private static void recordUpdate(WebappDataStorage storage, | 297 private static void recordUpdate( |
298 @WebApkInstallResult.WebApkInstallResultEnum int result, boolean rel
axUpdates) { | 298 WebappDataStorage storage, @WebApkInstallResult int result, boolean
relaxUpdates) { |
299 // Update the request time and result together. It prevents getting a co
rrect request time | 299 // Update the request time and result together. It prevents getting a co
rrect request time |
300 // but a result from the previous request. | 300 // but a result from the previous request. |
301 storage.updateTimeOfLastWebApkUpdateRequestCompletion(); | 301 storage.updateTimeOfLastWebApkUpdateRequestCompletion(); |
302 storage.updateDidLastWebApkUpdateRequestSucceed(result == WebApkInstallR
esult.SUCCESS); | 302 storage.updateDidLastWebApkUpdateRequestSucceed(result == WebApkInstallR
esult.SUCCESS); |
303 storage.setRelaxedUpdates(relaxUpdates); | 303 storage.setRelaxedUpdates(relaxUpdates); |
304 } | 304 } |
305 | 305 |
306 /** | 306 /** |
307 * Checks whether the WebAPK needs to be updated. | 307 * Checks whether the WebAPK needs to be updated. |
308 * @param info Meta data from WebAPK's Android Manifest. | 308 * @param info Meta data from WebAPK's Android Manifest. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 */ | 350 */ |
351 protected boolean urlsMatchIgnoringFragments(String url1, String url2) { | 351 protected boolean urlsMatchIgnoringFragments(String url1, String url2) { |
352 return UrlUtilities.urlsMatchIgnoringFragments(url1, url2); | 352 return UrlUtilities.urlsMatchIgnoringFragments(url1, url2); |
353 } | 353 } |
354 | 354 |
355 /** | 355 /** |
356 * Called after either a request to update the WebAPK has been sent or the u
pdate process | 356 * Called after either a request to update the WebAPK has been sent or the u
pdate process |
357 * fails. | 357 * fails. |
358 */ | 358 */ |
359 @CalledByNative | 359 @CalledByNative |
360 private static void onBuiltWebApk(String id, | 360 private static void onBuiltWebApk( |
361 @WebApkInstallResult.WebApkInstallResultEnum int result, boolean rel
axUpdates) { | 361 String id, @WebApkInstallResult int result, boolean relaxUpdates) { |
362 WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataSt
orage(id); | 362 WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataSt
orage(id); |
363 if (storage == null) return; | 363 if (storage == null) return; |
364 | 364 |
365 recordUpdate(storage, result, relaxUpdates); | 365 recordUpdate(storage, result, relaxUpdates); |
366 } | 366 } |
367 | 367 |
368 private static native void nativeUpdateAsync(String id, String startUrl, Str
ing scope, | 368 private static native void nativeUpdateAsync(String id, String startUrl, Str
ing scope, |
369 String name, String shortName, String bestIconUrl, Bitmap bestIcon,
String[] iconUrls, | 369 String name, String shortName, String bestIconUrl, Bitmap bestIcon,
String[] iconUrls, |
370 String[] iconHashes, int displayMode, int orientation, long themeCol
or, | 370 String[] iconHashes, int displayMode, int orientation, long themeCol
or, |
371 long backgroundColor, String manifestUrl, String webApkPackage, int
webApkVersion, | 371 long backgroundColor, String manifestUrl, String webApkPackage, int
webApkVersion, |
372 boolean isManifestStale); | 372 boolean isManifestStale); |
373 } | 373 } |
OLD | NEW |