Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move set_owned_by_client calls to base View #22739

Merged
merged 2 commits into from Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions shell/browser/api/electron_api_view.cc
Expand Up @@ -12,12 +12,12 @@ namespace electron {

namespace api {

View::View(views::View* view) : view_(view) {}

View::View() : view_(new views::View()) {
View::View(views::View* view) : view_(view) {
view_->set_owned_by_client();
}

View::View() : View(new views::View()) {}

View::~View() {
if (delete_view_)
delete view_;
Expand Down
10 changes: 4 additions & 6 deletions shell/browser/api/electron_api_web_contents_view.cc
Expand Up @@ -53,12 +53,10 @@ WebContentsView::WebContentsView(v8::Isolate* isolate,
#endif
web_contents_(isolate, web_contents->GetWrapper()),
api_web_contents_(web_contents.get()) {
#if defined(OS_MACOSX)
// On macOS a View is created to wrap the NSView, and its lifetime is managed
// by us.
view()->set_owned_by_client();
#else
// On other platforms the View is managed by InspectableWebContents.
#if !defined(OS_MACOSX)
// On macOS the View is a newly-created |DelayedNativeViewHost| and it is our
// responsibility to delete it. On other platforms the View is created and
// managed by InspectableWebContents.
set_delete_view(false);
#endif
WebContentsViewRelay::CreateForWebContents(web_contents->web_contents());
Expand Down
1 change: 0 additions & 1 deletion shell/browser/api/views/electron_api_button.cc
Expand Up @@ -13,7 +13,6 @@ namespace electron {
namespace api {

Button::Button(views::Button* impl) : View(impl) {
view()->set_owned_by_client();
// Make the button focusable as per the platform.
button()->SetFocusForPlatform();
}
Expand Down
4 changes: 1 addition & 3 deletions shell/browser/api/views/electron_api_resize_area.cc
Expand Up @@ -12,9 +12,7 @@ namespace electron {

namespace api {

ResizeArea::ResizeArea() : View(new views::ResizeArea(this)) {
view()->set_owned_by_client();
}
ResizeArea::ResizeArea() : View(new views::ResizeArea(this)) {}

ResizeArea::~ResizeArea() {}

Expand Down
4 changes: 1 addition & 3 deletions shell/browser/api/views/electron_api_text_field.cc
Expand Up @@ -13,9 +13,7 @@ namespace electron {

namespace api {

TextField::TextField() : View(new views::Textfield()) {
view()->set_owned_by_client();
}
TextField::TextField() : View(new views::Textfield()) {}

TextField::~TextField() {}

Expand Down
2 changes: 0 additions & 2 deletions shell/browser/ui/views/inspectable_web_contents_view_views.cc
Expand Up @@ -87,8 +87,6 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
devtools_visible_(false),
devtools_window_delegate_(nullptr),
title_(base::ASCIIToUTF16("Developer Tools")) {
set_owned_by_client();

if (!inspectable_web_contents_->IsGuest() &&
inspectable_web_contents_->GetWebContents()->GetNativeView()) {
views::WebView* contents_web_view = new views::WebView(nullptr);
Expand Down