Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Issue 1845233002: Store standalone web app data in WebappDataStorage as well as the homescreen intent. (Closed)

Created:
4 years, 8 months ago by dominickn
Modified:
4 years, 8 months ago
Reviewers:
gone
CC:
chromium-reviews, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@notification-deep-linking
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Store standalone web app data in WebappDataStorage as well as the homescreen intent. Homescreen launch intents for standalone web apps on Android contain several properties which WebappActivity requires to launch the app in the web frame (e.g. icon, names, theme/background color). This structure means that launching webapps from sources other than the homescreen (e.g. a notification) won't work. The root problem is that Android does not have an API for querying shortcuts on the home screen after they have been added. This CL mirrors the homescreen intent data into Android Shared Preferences via WebappDataStorage, and refactors how homescreen launch intents for standalone apps are created. Standalone web apps added to homescreen before this CL will have their data copied into a WebappDataStorage when they are next launched. A new scope field is computed from the URL to identify the URLs over which a web app may control. This CL enables Chrome to launch a web app to standalone mode without the homescreen intent. The semantics of WebappDataStorage have also changed. Now, the only correct way to access a WebappDataStorage is via the WebappRegistry. New methods to access storage objects have been added to the registry, and all clients should use these. The existing WebappDataStorage expiry mechanism is maintained in this CL, ensuring that web apps which have not been launched recently will have their stored data removed. Additionally, URLs, scopes, and last access times are purged when the user clears history. Additional and updated tests for this functionality are also added. BUG=594872 Committed: https://crrev.com/6509a4deca126b49eb9121fefedcfc092dee0631 Cr-Commit-Position: refs/heads/master@{#385402}

Patch Set 1 #

Patch Set 2 : Improve comments #

Total comments: 24

Patch Set 3 : Addressing reviewer comments #

Patch Set 4 : Fix test #

Patch Set 5 : Remove some thread asserts #

Total comments: 20

Patch Set 6 : Refactor. Adding scope computation. Addressing comments #

Patch Set 7 : Move scope calculation to Java. Fix test #

Patch Set 8 : Address strict mode violation #

Total comments: 9

Patch Set 9 : Final nit #

Unified diffs Side-by-side diffs Delta from patch set Stats (+834 lines, -328 lines) Patch
M chrome/android/BUILD.gn View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java View 1 2 3 4 5 6 9 chunks +117 lines, -23 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java View 1 2 3 4 5 1 chunk +20 lines, -12 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java View 1 2 3 4 5 6 7 8 10 chunks +157 lines, -64 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java View 1 2 3 4 5 6 3 chunks +60 lines, -11 lines 0 comments Download
M chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java View 1 2 3 4 5 10 chunks +48 lines, -43 lines 0 comments Download
M chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappActivityTestBase.java View 1 2 3 4 5 2 chunks +9 lines, -4 lines 0 comments Download
M chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappModeTest.java View 1 2 3 4 5 3 chunks +25 lines, -7 lines 0 comments Download
A chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java View 1 2 3 4 5 6 1 chunk +56 lines, -0 lines 0 comments Download
M chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java View 1 2 3 4 5 6 7 5 chunks +127 lines, -43 lines 0 comments Download
M chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java View 1 2 3 4 5 6 12 chunks +118 lines, -59 lines 0 comments Download
M chrome/browser/android/banners/app_banner_data_fetcher_android.h View 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/android/banners/app_banner_data_fetcher_android.cc View 3 chunks +6 lines, -8 lines 0 comments Download
M chrome/browser/android/banners/app_banner_infobar_delegate_android.cc View 1 chunk +4 lines, -7 lines 0 comments Download
M chrome/browser/android/shortcut_helper.h View 1 2 3 4 5 6 3 chunks +23 lines, -14 lines 0 comments Download
M chrome/browser/android/shortcut_helper.cc View 1 2 6 7 chunks +41 lines, -12 lines 0 comments Download
M chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h View 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc View 2 chunks +6 lines, -8 lines 0 comments Download
M chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc View 1 chunk +4 lines, -8 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 22 (8 generated)
dominickn
PTAL. This patch brings all of the necessary bits of the homescreen intent into WebappDataStorage. ...
4 years, 8 months ago (2016-03-31 12:59:36 UTC) #4
gone
Very cursory pass. https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java File chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java (right): https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java#newcode231 chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java:231: * @param id Id of the ...
4 years, 8 months ago (2016-04-01 23:44:49 UTC) #5
gone
https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java (right): https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java#newcode191 chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java:191: return context.getApplicationContext().getSharedPreferences( Ironically, this is probably the only call ...
4 years, 8 months ago (2016-04-01 23:54:31 UTC) #6
dominickn
Thanks! https://codereview.chromium.org/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java File chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java (right): https://codereview.chromium.org/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java#newcode231 chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java:231: * @param id Id of the webapp. On ...
4 years, 8 months ago (2016-04-04 07:26:24 UTC) #7
gone
lgtm https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java (right): https://chromiumcodereview.appspot.com/1845233002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java#newcode191 chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java:191: return context.getApplicationContext().getSharedPreferences( On 2016/04/04 07:26:24, dominickn wrote: > ...
4 years, 8 months ago (2016-04-04 19:04:03 UTC) #8
gone
Er, not lgtm? I don't know how to undo an accidental button click. Blarg.
4 years, 8 months ago (2016-04-04 19:04:30 UTC) #9
dominickn
Thanks! I think I've finally got the threading/strict mode correct in this patch. I've also ...
4 years, 8 months ago (2016-04-05 11:37:46 UTC) #11
gone
lgtm Not seeing anything obviously egregious here... https://codereview.chromium.org/1845233002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java (right): https://codereview.chromium.org/1845233002/diff/140001/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java#newcode59 chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java:59: * thread. ...
4 years, 8 months ago (2016-04-05 20:40:15 UTC) #12
gone
https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java File chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java (right): https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java#newcode1 chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java:1: // Copyright 2016 The Chromium Authors. All rights reserved. ...
4 years, 8 months ago (2016-04-05 20:45:42 UTC) #13
gone
https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java File chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java (right): https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java#newcode1 chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java:1: // Copyright 2016 The Chromium Authors. All rights reserved. ...
4 years, 8 months ago (2016-04-05 20:46:43 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1845233002/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1845233002/160001
4 years, 8 months ago (2016-04-06 07:32:49 UTC) #17
commit-bot: I haz the power
Committed patchset #9 (id:160001)
4 years, 8 months ago (2016-04-06 08:29:16 UTC) #19
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/6509a4deca126b49eb9121fefedcfc092dee0631 Cr-Commit-Position: refs/heads/master@{#385402}
4 years, 8 months ago (2016-04-06 08:30:19 UTC) #21
dominickn
4 years, 8 months ago (2016-04-06 09:23:44 UTC) #22
Message was sent while issue was closed.
https://codereview.chromium.org/1845233002/diff/140001/chrome/android/java/sr...
File
chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
(right):

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/java/sr...
chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java:59:
* thread.
On 2016/04/05 20:40:15, dfalcantara wrote:
> Might be worth just putting a !ThreadUtils.assertOnUiThread().

As discussed, some existing tests call this method on the UI thread. I'll follow
up with another patch to fix those since I don't want to bloat this one any
more.

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/java/sr...
chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java:221:
protected final Void doInBackground(Void... nothing) {
On 2016/04/05 20:40:14, dfalcantara wrote:
> nit: fix indentation with temporary storage?
> 
> String bitmapString = ShortcutHelper.encodeBitmapAsString(splashScreenImage);
> mPreferences.edit().putString(KEY_SPLASH_ICON, bitmapString).apply();

Done.

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/s...
File
chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java
(right):

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/s...
chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java:1:
// Copyright 2016 The Chromium Authors. All rights reserved.
On 2016/04/05 20:46:43, dfalcantara wrote:
> On 2016/04/05 20:45:42, dfalcantara wrote:
> > Was this added to java_sources.gni?
> 
> Bah, never mind.  Didn't realize this fell under a different target.

Acknowledged.

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/s...
File
chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java
(right):

https://codereview.chromium.org/1845233002/diff/140001/chrome/android/junit/s...
chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java:329:
assertTrue(mCallbackCalled);
On 2016/04/05 20:40:15, dfalcantara wrote:
> Little bit worried about the same mCallbackCalled being set by different bits
of
> code, but you're probably fine.  Way around it could to have each
> FetchStorageCallback store its own boolean, but it's probably alright.

Acknowledged.

Powered by Google App Engine
This is Rietveld 408576698