Commit d1495d15 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Removed set_owned_by_client() from SimpleWebViewDialog

Prior to this patch |web_view_| was owned by the
|web_view_container_| data member of the SimpleWebViewDialog class.

This patch has |web_view_container_| own the |web_view_| up until it
is added as a child to the SimpleWebViewDialog, at which point the
web dialog asserts ownership of the |web_view_|.

This eliminates the use of set_owned_by_client() which the Views team
is in the process of deprecating.

Bug: 1044687
Change-Id: I5bfc0f7f212d039b79565fa7b44298ea5dde8dbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199875Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770656}
parent 731ba29a
......@@ -142,9 +142,8 @@ SimpleWebViewDialog::~SimpleWebViewDialog() {
void SimpleWebViewDialog::StartLoad(const GURL& url) {
if (!web_view_container_)
web_view_container_.reset(new views::WebView(profile_));
web_view_container_ = std::make_unique<views::WebView>(profile_);
web_view_ = web_view_container_.get();
web_view_->set_owned_by_client();
web_view_->GetWebContents()->SetDelegate(this);
web_view_->LoadInitialURL(url);
......@@ -209,7 +208,9 @@ void SimpleWebViewDialog::Init() {
// Add the views as child views before the grid layout is installed. This
// ensures ownership is more clear.
ToolbarRowView* toolbar_row_ptr = AddChildView(std::move(toolbar_row));
AddChildView(web_view_);
// Transfer ownership of the |web_view_| from the |web_view_container_|
// created in StartLoad() to |this|.
AddChildView(std::move(web_view_container_));
// Layout.
GridLayout* layout = SetLayoutManager(std::make_unique<GridLayout>());
......
......@@ -103,7 +103,8 @@ class SimpleWebViewDialog : public views::ButtonListener,
LocationBarView* location_bar_ = nullptr;
views::WebView* web_view_ = nullptr;
// Contains |web_view_| while it isn't owned by the view.
// Will own the |web_view_| until it is added as a child to the to the simple
// web view dialog.
std::unique_ptr<views::WebView> web_view_container_;
std::unique_ptr<StubBubbleModelDelegate> bubble_model_delegate_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment