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

Issue 1743143002: Remove WebContents::Was{Hidden,Shown}() from the content public interface

Created:
4 years, 9 months ago by tapted
Modified:
4 years, 9 months ago
Reviewers:
jam
CC:
chromium-reviews, davidben+watch_chromium.org, extensions-reviews_chromium.org, cbentzel+watch_chromium.org, creis+watch_chromium.org, gavinp+prer_chromium.org, Peter Beverloo, mlamouri+watch-notifications_chromium.org, nasko+codewatch_chromium.org, tburkard+watch_chromium.org, darin-cc_chromium.org, mlamouri+watch-permissions_chromium.org, chromium-apps-reviews_chromium.org, android-webview-reviews_chromium.org, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@20160225-WebContents-DicardCursorRects
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove WebContents::Was{Hidden,Shown}() from the content public interface The WebContentsView typically knows best when this should be invoked. Excluding tests, Mac's TabStripController is currently the only place in Chrome that invokes WebContents::WasShown(). Tests use WasShown() and WasHidden() in simulations, so provide access for tests via content::WebContentsTester. Then, WebContents::WasHidden() otherwise seems to be misused by Chrome code, to move newly-created WebContents to a kind of "background" state. WebContents::CreateParams::initially_hidden should be used for this instead. BUG=590981 CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

Patch Set 1 #

Patch Set 2 : Fix androido #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+107 lines, -51 lines) Patch
M android_webview/native/aw_web_contents_delegate.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/engagement/site_engagement_helper_unittest.cc View 6 chunks +9 lines, -10 lines 0 comments Download
M chrome/browser/notifications/notification_permission_context_unittest.cc View 3 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer_unittest.cc View 5 chunks +9 lines, -9 lines 0 comments Download
M chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h View 1 chunk +0 lines, -1 line 0 comments Download
M chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/prerender/prerender_contents.cc View 1 chunk +4 lines, -1 line 0 comments Download
M chrome/browser/sessions/tab_loader.cc View 1 chunk +4 lines, -1 line 0 comments Download
M chrome/browser/ui/browser_commands.cc View 1 chunk +5 lines, -2 lines 0 comments Download
M chrome/browser/ui/browser_tabrestore.cc View 1 chunk +5 lines, -1 line 0 comments Download
M chrome/browser/ui/webui/print_preview/print_preview_distiller.cc View 2 chunks +2 lines, -1 line 0 comments Download
M chrome/test/base/chrome_render_view_host_test_harness.h View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/test/base/chrome_render_view_host_test_harness.cc View 3 chunks +10 lines, -0 lines 0 comments Download
M content/browser/frame_host/render_frame_host_impl_browsertest.cc View 2 chunks +4 lines, -2 lines 0 comments Download
M content/browser/web_contents/web_contents_android.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.h View 2 chunks +5 lines, -2 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M content/public/browser/web_contents.h View 1 chunk +3 lines, -3 lines 2 comments Download
M content/public/test/web_contents_tester.h View 4 chunks +14 lines, -0 lines 0 comments Download
M content/public/test/web_contents_tester.cc View 2 chunks +14 lines, -8 lines 0 comments Download
M extensions/browser/extension_host.cc View 1 chunk +1 line, -1 line 0 comments Download

Depends on Patchset:

Messages

Total messages: 8 (4 generated)
jam
https://codereview.chromium.org/1743143002/diff/20001/content/public/browser/web_contents.h File content/public/browser/web_contents.h (right): https://codereview.chromium.org/1743143002/diff/20001/content/public/browser/web_contents.h#newcode387 content/public/browser/web_contents.h:387: virtual void MarkBackgrounded() = 0; what's the other analogous ...
4 years, 9 months ago (2016-02-29 17:36:36 UTC) #4
tapted
This CL was a kind of exploration to scope out the problem. I think this ...
4 years, 9 months ago (2016-02-29 22:42:33 UTC) #5
tapted
On 2016/02/29 22:42:33, tapted wrote: > However, I think before this CL, we should act ...
4 years, 9 months ago (2016-03-01 08:36:33 UTC) #7
jam
4 years, 9 months ago (2016-03-14 16:06:29 UTC) #8
On 2016/02/29 22:42:33, tapted wrote:
> This CL was a kind of exploration to scope out the problem.  I think this
> comment will publish the CL out - it's not for a final review yet, but I'm
glad
> you saw this in its early stages :).
> 
> Please see my answer to your question below.
> 
> However, I think before this CL, we should act on those `TODOs` that the CL
adds
> as annotations. i.e. remove the call sites where Chrome calls `WasHidden` when
> it doesn't need to. Then `MarkBackgrounded` should become unnecessary to land
> this.
> 
>
https://codereview.chromium.org/1743143002/diff/20001/content/public/browser/...
> File content/public/browser/web_contents.h (right):
> 
>
https://codereview.chromium.org/1743143002/diff/20001/content/public/browser/...
> content/public/browser/web_contents.h:387: virtual void MarkBackgrounded() =
0;
> On 2016/02/29 17:36:36, jam wrote:
> > what's the other analogous method?
> > 
> > i.e. it seems this is for undoing a previous call.where is that call?
> > shouldn't they be together?
> 
> Ah, that's the thing :). `MarkBackgrounded` actually shouldn't exist, and
> embedders don't really need the analogous method. That's because they're
> currently using calls to WebContents::WasHidden() shortly after creating a
> WebContents, but with that WebContents created with
> WebContents::InitParams::initially_hidden set to false, rather than true. For
> Aura platforms, the `WasShown` call to balance a WasHidden is always made by
the
> content layer, by WebContentsView. (and http://crrev.com/1733173002 makes that
> true for Mac as well as Aura).
> 
> Exposing `WasHidden` can lead to bugs - e.g. http://crbug.com/590476 which
came
> up recently. Part of the issue is that calls to `WasHidden` (or
MarkBackgrounded
> which this CL renames it to) can be called on WebContents that are already
> hidden.
> 
> This CL annotates all the `WasHidden` calls that Chrome was making. I think
they
> can all be removed with appropriate use of
> WebContents::InitParams::initially_hidden . (Or perhaps
> `InitParams::initial_state = {BACKGROUND_PRELOAD, FOREGROUND}` if that's
> clearer. Maybe there's a use case for `UNLOADED` as well, but there doesn't
seem
> to be).

sounds good to me, thanks for the explanation
(Avi had pointed me to this cl, hence the comment on the unpublished review :) )

Powered by Google App Engine
This is Rietveld 408576698