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

Issue 2290603005: Trigger app banner when add to homescreen is pressed and WebAPKs are enabled. (Closed)

Created:
4 years, 3 months ago by Xi Han
Modified:
4 years, 3 months ago
CC:
chromium-reviews, dominickn+watch_chromium.org, pkotwicz, Yaron
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Trigger app banner when add to homescreen is pressed and WebAPKs are enabled. When user clicks A2HS from the app menu, a A2HS dialog shows to add a shortcut. When WebAPK is enabled, an app banner info bar is expected to show for WebAPK-compatible site. This CL includes: - AddToHomeScreenManager creates an app banner to install WebAPKs. - Refactory in AppBannerInfobarDelegateAndroid that passes in a ShortcutInfo instead of Manifest file. - When installing WebAPK from the app menu, the app banner skips the state of showing "Add to Homescrenn" on its button but jumps to "Adding" state and starts the installation. UX review see https://docs.google.com/presentation/d/1QbHDigLFR1oucsnlXQ9f6AxQYYI6Ka0Gl0A_vWpFjSA/edit#slide=id.g1503c2082e_0_28. Committed: https://crrev.com/d256ebd2ba19a77c2c6d71f562f7db8b51254bc3 Cr-Commit-Position: refs/heads/master@{#417310}

Patch Set 1 #

Total comments: 14

Patch Set 2 : dfalcantara@'s comments. #

Patch Set 3 : Remove InstallWebApk from infobar. #

Total comments: 20

Patch Set 4 : dominickn@ and dfalcantara@'s comments. #

Total comments: 9

Patch Set 5 : Nits. #

Patch Set 6 : Remove the extra constructor in AppBannerInfoBarDelegateAndroid. #

Total comments: 2

Patch Set 7 : Nits. #

Total comments: 22

Patch Set 8 : pkasting@'s comments. #

Patch Set 9 : Try to fix test failures #

Total comments: 78

Patch Set 10 : Clean ups #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+248 lines, -188 lines) Patch
M chrome/browser/android/banners/app_banner_infobar_delegate_android.h View 1 2 3 4 5 6 7 8 9 5 chunks +41 lines, -15 lines 0 comments Download
M chrome/browser/android/banners/app_banner_infobar_delegate_android.cc View 1 2 3 4 5 6 7 8 9 11 chunks +140 lines, -121 lines 1 comment Download
M chrome/browser/android/banners/app_banner_manager_android.cc View 1 2 3 4 5 6 7 8 9 7 chunks +37 lines, -48 lines 0 comments Download
M chrome/browser/android/webapps/add_to_homescreen_manager.h View 1 2 3 4 5 2 chunks +7 lines, -0 lines 0 comments Download
M chrome/browser/android/webapps/add_to_homescreen_manager.cc View 1 2 3 4 5 6 7 8 9 5 chunks +23 lines, -4 lines 0 comments Download

Messages

Total messages: 66 (39 generated)
Xi Han
Hi Dominick and Dan, could you please take a look? Thanks!
4 years, 3 months ago (2016-08-30 21:33:29 UTC) #16
dominickn
On 2016/08/30 21:33:29, Xi Han wrote: > Hi Dominick and Dan, could you please take ...
4 years, 3 months ago (2016-08-31 14:51:54 UTC) #17
gone
https://chromiumcodereview.appspot.com/2290603005/diff/100001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://chromiumcodereview.appspot.com/2290603005/diff/100001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode45 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:45: return info->url.is_empty(); return !info || info->url.is_empty(); https://chromiumcodereview.appspot.com/2290603005/diff/100001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode171 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:171: << ...
4 years, 3 months ago (2016-08-31 18:12:46 UTC) #18
Xi Han
Hi Dan, PTAL, thanks! https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode45 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:45: return info->url.is_empty(); On 2016/08/31 18:12:45, ...
4 years, 3 months ago (2016-08-31 20:11:48 UTC) #20
gone
https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/ui/android/infobars/app_banner_infobar_android.h File chrome/browser/ui/android/infobars/app_banner_infobar_android.h (right): https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/ui/android/infobars/app_banner_infobar_android.h#newcode42 chrome/browser/ui/android/infobars/app_banner_infobar_android.h:42: void InstallWebApk(content::WebContents* web_contents); On 2016/08/31 20:11:48, Xi Han wrote: ...
4 years, 3 months ago (2016-08-31 20:24:23 UTC) #21
Xi Han
PTAL, thanks! https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/ui/android/infobars/app_banner_infobar_android.h File chrome/browser/ui/android/infobars/app_banner_infobar_android.h (right): https://codereview.chromium.org/2290603005/diff/100001/chrome/browser/ui/android/infobars/app_banner_infobar_android.h#newcode42 chrome/browser/ui/android/infobars/app_banner_infobar_android.h:42: void InstallWebApk(content::WebContents* web_contents); On 2016/08/31 20:24:22, dfalcantara ...
4 years, 3 months ago (2016-08-31 20:59:25 UTC) #23
gone
lgtm https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h File chrome/browser/android/banners/app_banner_infobar_delegate_android.h (right): https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h#newcode73 chrome/browser/android/banners/app_banner_infobar_delegate_android.h:73: // disables the button to avoid usr interaction. ...
4 years, 3 months ago (2016-08-31 21:07:39 UTC) #24
dominickn
https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode42 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:42: bool isShortcutInfoEmpty(ShortcutInfo* info) { Nit: IsInfoEmpty(), and it should ...
4 years, 3 months ago (2016-09-01 05:22:00 UTC) #25
dominickn
Also: change the title to be "Trigger app banner when add to homescreen is pressed ...
4 years, 3 months ago (2016-09-01 05:29:02 UTC) #26
Xi Han
PTAL, thanks! https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode42 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:42: bool isShortcutInfoEmpty(ShortcutInfo* info) { On 2016/09/01 05:22:00, ...
4 years, 3 months ago (2016-09-01 18:44:14 UTC) #31
dominickn
lgtm % nits. Thanks Xi. https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode54 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:54: std::unique_ptr<ShortcutInfo> info, On 2016/09/01 ...
4 years, 3 months ago (2016-09-02 01:00:58 UTC) #32
Xi Han
Hi Donminick, I am a little confused about the suggestion of a follow up CL ...
4 years, 3 months ago (2016-09-02 13:58:23 UTC) #33
dominickn
https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/180001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode54 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:54: std::unique_ptr<ShortcutInfo> info, On 2016/09/02 13:58:23, Xi Han wrote: > ...
4 years, 3 months ago (2016-09-02 14:30:48 UTC) #34
Xi Han
Hi Dominick, PTAL, thanks! +cpu@chromium.org: I need owners review for: -components/infobars/core/infobar_delegate.h -components/infobars/core/infobar_delegate.cc Could you please ...
4 years, 3 months ago (2016-09-02 15:01:50 UTC) #36
Xi Han
+ thestig@: I need owners review for: -components/infobars/core/infobar_delegate.h -components/infobars/core/infobar_delegate.cc Could you please take a look? ...
4 years, 3 months ago (2016-09-05 13:53:48 UTC) #38
dominickn
Still lgtm % nit. https://codereview.chromium.org/2290603005/diff/300001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h File chrome/browser/android/banners/app_banner_infobar_delegate_android.h (right): https://codereview.chromium.org/2290603005/diff/300001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h#newcode101 chrome/browser/android/banners/app_banner_infobar_delegate_android.h:101: GURL manifest_url_; Nit: manifest_url and ...
4 years, 3 months ago (2016-09-06 01:49:24 UTC) #39
Xi Han
thestig@ ping. https://codereview.chromium.org/2290603005/diff/300001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h File chrome/browser/android/banners/app_banner_infobar_delegate_android.h (right): https://codereview.chromium.org/2290603005/diff/300001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h#newcode101 chrome/browser/android/banners/app_banner_infobar_delegate_android.h:101: GURL manifest_url_; On 2016/09/06 01:49:23, dominickn wrote: ...
4 years, 3 months ago (2016-09-06 17:20:07 UTC) #40
Lei Zhang
On 2016/09/05 13:53:48, Xi Han wrote: > + thestig@: > I need owners review for: ...
4 years, 3 months ago (2016-09-06 18:49:28 UTC) #44
Xi Han
+pkasting@: Could you please review the followings files: -components/infobars/core/infobar_delegate.h -components/infobars/core/infobar_delegate.cc Thanks! thestig@: I don't know ...
4 years, 3 months ago (2016-09-06 18:55:22 UTC) #47
Peter Kasting
A number of comments in here request cleanups of stuff you weren't newly adding in ...
4 years, 3 months ago (2016-09-06 19:31:23 UTC) #48
Xi Han
pkasting@: I addressed all your comments except the one to split the delegate into two ...
4 years, 3 months ago (2016-09-07 15:53:17 UTC) #52
Peter Kasting
LGTM https://codereview.chromium.org/2290603005/diff/320001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h File chrome/browser/android/banners/app_banner_infobar_delegate_android.h (right): https://codereview.chromium.org/2290603005/diff/320001/chrome/browser/android/banners/app_banner_infobar_delegate_android.h#newcode37 chrome/browser/android/banners/app_banner_infobar_delegate_android.h:37: std::unique_ptr<ShortcutInfo> info, On 2016/09/07 15:53:17, Xi Han wrote: ...
4 years, 3 months ago (2016-09-08 04:56:58 UTC) #55
Xi Han
https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc (right): https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc#newcode38 chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:38: using base::android::ScopedJavaLocalRef; On 2016/09/08 04:56:57, Peter Kasting wrote: > ...
4 years, 3 months ago (2016-09-08 15:49:10 UTC) #58
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2290603005/480001
4 years, 3 months ago (2016-09-08 15:49:30 UTC) #61
commit-bot: I haz the power
Committed patchset #10 (id:480001)
4 years, 3 months ago (2016-09-08 16:39:24 UTC) #63
commit-bot: I haz the power
Patchset 10 (id:??) landed as https://crrev.com/d256ebd2ba19a77c2c6d71f562f7db8b51254bc3 Cr-Commit-Position: refs/heads/master@{#417310}
4 years, 3 months ago (2016-09-08 16:42:20 UTC) #65
Peter Kasting
4 years, 3 months ago (2016-09-08 20:57:05 UTC) #66
Message was sent while issue was closed.
https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
(right):

https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:42: bool
IsInfoEmpty(const ShortcutInfo* info) {
On 2016/09/08 15:49:10, Xi Han wrote:
> On 2016/09/08 04:56:57, Peter Kasting wrote:
> > Nit: Take a const unique_ptr& and you won't have to say .get() on all the
> > callers.
> 
> It can't be a unique_ptr since when this function is called, we need to pass
> std::move(shortcut_info_). 

I said "const unique_ptr&", not "unique_ptr".

https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:60: const
GURL& url = shortcut_info->url;
On 2016/09/08 15:49:09, Xi Han wrote:
> On 2016/09/08 04:56:57, Peter Kasting wrote:
> > Nit: Inline this into the caller below (even if you wanted a temp, you'd
want
> to
> > declare it down there where it's used anyway)
> 
> It has to be done before std::move(shortcut_info) is called, otherwise the
> pointer shortcut_info will be invalid.

Oh bah.

https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:383:
infobar()->RemoveSelf();
On 2016/09/08 15:49:09, Xi Han wrote:
> On 2016/09/08 04:56:57, Peter Kasting wrote:
> > Nit: Might be safer to do this after the next function call since this call
> can
> > delete |this|?  I don't know if that next call can reach back to anything in
> > this object.
> 
> In the UI, we would like to see a toast shown after the infobar disappears,
that
> is main reason the RemoveSelf is called earlier.

Are these orders perceptibly different to the user?  RemoveSelf() should start
the bar animating closed and return immediately.  It doesn't block.

https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
File chrome/browser/android/banners/app_banner_manager_android.cc (right):

https://codereview.chromium.org/2290603005/diff/420001/chrome/browser/android...
chrome/browser/android/banners/app_banner_manager_android.cc:39: const char
kPlayInlineReferrer[] = "playinline=chrome_inline";
On 2016/09/08 15:49:10, Xi Han wrote:
> On 2016/09/08 04:56:58, Peter Kasting wrote:
> > Nit: Each of these temps is used in only one function.  Define them in the
> > functions in which they're used.  Or just inline them where used, if the
> > variable names don't add much.
> 
> Personally I would prefer to declare them at the beginning of the class, in
case
> they will be used again in the future. Especially the fourth one is used
twice.

Twice yes, but in adjacent statements in the same function.

http://google.github.io/styleguide/cppguide.html#Local_Variables says
"...declare [variables] in as local a scope as possible, and as close to the
first use as possible."  While arguably constants are not the same as variables,
declaring them somewhere widely separate from their use means that code
referencing them now requires the reader to scan to a different place to see
what the constant value actually is.  It also makes it easier to have these left
around after their uses are deleted.  And if these are used in multiple places
in the future they can always be factored out then.

More directly in this case, I think kPlayInlineReferrer deserves a named
constant anyway, but the kXXXName ones don't -- those string constants should
just be inlined directly into the code that uses them, since the constant names
just add verbosity to the actual strings without adding any clarity or
explanation.  So I'd inline those two and then make a decision about how to
handle the last one based on how compelling you think my above arguments are :)

https://codereview.chromium.org/2290603005/diff/480001/chrome/browser/android...
File chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
(right):

https://codereview.chromium.org/2290603005/diff/480001/chrome/browser/android...
chrome/browser/android/banners/app_banner_infobar_delegate_android.cc:279: if
(!native_app_data_.is_null()) {
Nit: Reverse this condition and the arms, so the "else" isn't mentally a
double-negative

Powered by Google App Engine
This is Rietveld 408576698