views: add WidgetDelegate::SetContentsView
This change adds two new methods to WidgetDelegate, both of which allow setting the WidgetDelegate's contents view, thus removing the need to override GetContentsView(). The two new methods are: * SetContentsView(unique_ptr<View>), which takes ownership of the given View * SetContentsView(View*), which doesn't Each method can only be used with the appropriate ownership protocol, so SetContentsView(unique_ptr<View>) will DCHECK if the provided view is owned_by_client(), and vice versa for SetContentsView(View*). This effectively forces clients into one of these two ownership protocols and away from the "sometimes owning" pointer semantics of overriding GetContentsView(). This is part 2 of the following plan: 1) Introduce WidgetDelegate::TransferOwnershipOfContentsView() and migrate to it in places that are trying to take ownership 2) Introduce WidgetDelegate::SetContentsView(), which will either: a. Store the provided view in a unique_ptr, if it is not owned by client, or b. Store the provided view in a raw pointer, if it is owned by client 3) Replace all existing overrides of GetContentsView() with uses of SetContentsView() 4) Require that !owned_by_client() in SetContentsView(), which will likely require intense surgery of client classes 5) Have SetContentsView() take and TransferOwnershipOfContentsView() return a unique_ptr<View> rather than a View* as laid out in 1206dbae. Bug: 1075649 Change-Id: Ifa35af1d87ad958a7d544ed74d6b1f980e416463 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2449919 Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org> Reviewed-by:Peter Boström <pbos@chromium.org> Cr-Commit-Position: refs/heads/master@{#814274}
Showing
Please register or sign in to comment