diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 507a6b6efb56..f021e6cc742c 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -323,7 +323,7 @@ void NativeWindowMac::SetContentView(views::View* view) { root_view->RemoveChildView(content_view()); set_content_view(view); - root_view->AddChildView(content_view()); + root_view->AddChildViewRaw(content_view()); root_view->DeprecatedLayoutImmediately(); } diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 130277a66d72..34ad9081c6d4 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -480,7 +480,7 @@ void NativeWindowViews::SetContentView(views::View* view) { } set_content_view(view); focused_view_ = view; - root_view_.GetMainView()->AddChildView(content_view()); + root_view_.GetMainView()->AddChildViewRaw(content_view()); root_view_.GetMainView()->DeprecatedLayoutImmediately(); } diff --git a/shell/browser/ui/inspectable_web_contents_view.cc b/shell/browser/ui/inspectable_web_contents_view.cc index e61f008414df..7389adbf3f9b 100644 --- a/shell/browser/ui/inspectable_web_contents_view.cc +++ b/shell/browser/ui/inspectable_web_contents_view.cc @@ -90,8 +90,8 @@ InspectableWebContentsView::InspectableWebContentsView( } devtools_web_view_->SetVisible(false); - AddChildView(devtools_web_view_.get()); - AddChildView(GetContentsView()); + AddChildViewRaw(devtools_web_view_.get()); + AddChildViewRaw(GetContentsView()); } InspectableWebContentsView::~InspectableWebContentsView() { diff --git a/shell/browser/ui/views/autofill_popup_view.cc b/shell/browser/ui/views/autofill_popup_view.cc index 289bba3f4c36..b5c8f03e005c 100644 --- a/shell/browser/ui/views/autofill_popup_view.cc +++ b/shell/browser/ui/views/autofill_popup_view.cc @@ -215,9 +215,10 @@ void AutofillPopupView::CreateChildViews() { RemoveAllChildViews(); for (int i = 0; i < popup_->line_count(); ++i) { - auto* child_view = new AutofillPopupChildView(popup_->value_at(i)); + auto child_view = + std::make_unique(popup_->value_at(i)); child_view->set_drag_controller(this); - AddChildView(child_view); + AddChildView(std::move(child_view)); } } diff --git a/shell/browser/ui/views/autofill_popup_view.h b/shell/browser/ui/views/autofill_popup_view.h index 2d312e0a6bd6..d27497013010 100644 --- a/shell/browser/ui/views/autofill_popup_view.h +++ b/shell/browser/ui/views/autofill_popup_view.h @@ -51,7 +51,6 @@ class AutofillPopupChildView : public views::View { AutofillPopupChildView(const AutofillPopupChildView&) = delete; AutofillPopupChildView& operator=(const AutofillPopupChildView&) = delete; - private: ~AutofillPopupChildView() override = default; std::u16string suggestion_; diff --git a/shell/browser/ui/views/client_frame_view_linux.cc b/shell/browser/ui/views/client_frame_view_linux.cc index d41a7d8d8fc7..316752492b4f 100644 --- a/shell/browser/ui/views/client_frame_view_linux.cc +++ b/shell/browser/ui/views/client_frame_view_linux.cc @@ -84,20 +84,20 @@ ClientFrameViewLinux::ClientFrameViewLinux() views::FrameButton::kMaximize, views::FrameButton::kClose} { for (auto& button : nav_buttons_) { - button.button = new views::ImageButton(); - button.button->SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE); - button.button->SetAccessibleName( + auto image_button = std::make_unique(); + image_button->SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE); + image_button->SetAccessibleName( l10n_util::GetStringUTF16(button.accessibility_id)); - AddChildView(button.button); + button.button = AddChildView(std::move(image_button)); } - title_ = new views::Label(); - title_->SetSubpixelRenderingEnabled(false); - title_->SetAutoColorReadabilityEnabled(false); - title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); - title_->SetVerticalAlignment(gfx::ALIGN_MIDDLE); - title_->SetTextStyle(views::style::STYLE_TAB_ACTIVE); - AddChildView(title_); + auto title = std::make_unique(); + title->SetSubpixelRenderingEnabled(false); + title->SetAutoColorReadabilityEnabled(false); + title->SetHorizontalAlignment(gfx::ALIGN_CENTER); + title->SetVerticalAlignment(gfx::ALIGN_MIDDLE); + title->SetTextStyle(views::style::STYLE_TAB_ACTIVE); + title_ = AddChildView(std::move(title)); native_theme_observer_.Observe(theme_); @@ -293,8 +293,7 @@ void ClientFrameViewLinux::Layout(PassKey) { title_bounds.Inset(theme_values_.title_padding); title_->SetVisible(true); - title_->SetBounds(title_bounds.x(), title_bounds.y(), title_bounds.width(), - title_bounds.height()); + title_->SetBoundsRect(title_bounds); } void ClientFrameViewLinux::OnPaint(gfx::Canvas* canvas) { diff --git a/shell/browser/ui/views/client_frame_view_linux.h b/shell/browser/ui/views/client_frame_view_linux.h index 9bb03a2472ba..0d8f4050b950 100644 --- a/shell/browser/ui/views/client_frame_view_linux.h +++ b/shell/browser/ui/views/client_frame_view_linux.h @@ -95,7 +95,7 @@ class ClientFrameViewLinux : public FramelessView, void (views::Widget::*callback)(); int accessibility_id; int hit_test_id; - RAW_PTR_EXCLUSION views::ImageButton* button{nullptr}; + raw_ptr button = {}; }; struct ThemeValues { @@ -132,7 +132,7 @@ class ClientFrameViewLinux : public FramelessView, raw_ptr theme_; ThemeValues theme_values_; - RAW_PTR_EXCLUSION views::Label* title_; + raw_ptr title_; std::unique_ptr nav_button_provider_; std::array nav_buttons_; diff --git a/shell/browser/ui/views/menu_bar.cc b/shell/browser/ui/views/menu_bar.cc index 28a19854fe69..d7a67317c6ee 100644 --- a/shell/browser/ui/views/menu_bar.cc +++ b/shell/browser/ui/views/menu_bar.cc @@ -229,11 +229,11 @@ void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) { void MenuBar::RebuildChildren() { RemoveAllChildViews(); for (size_t i = 0, n = GetItemCount(); i < n; ++i) { - auto* button = new SubmenuButton( + auto button = std::make_unique( base::BindRepeating(&MenuBar::ButtonPressed, base::Unretained(this), i), menu_model_->GetLabelAt(i), background_color_); button->SetID(i); - AddChildView(button); + AddChildView(std::move(button)); } UpdateViewColors(); } diff --git a/shell/browser/ui/views/opaque_frame_view.cc b/shell/browser/ui/views/opaque_frame_view.cc index 6aef44bdeedf..2639daba9d82 100644 --- a/shell/browser/ui/views/opaque_frame_view.cc +++ b/shell/browser/ui/views/opaque_frame_view.cc @@ -297,7 +297,7 @@ views::Button* OpaqueFrameView::CreateButton( int ht_component, const gfx::VectorIcon& icon_image, views::Button::PressedCallback callback) { - views::FrameCaptionButton* button = new views::FrameCaptionButton( + auto button = std::make_unique( views::Button::PressedCallback(), icon_type, ht_component); button->SetImage(button->GetIcon(), views::FrameCaptionButton::Animate::kNo, icon_image); @@ -306,12 +306,11 @@ views::Button* OpaqueFrameView::CreateButton( button->SetCallback(std::move(callback)); button->SetAccessibleName(l10n_util::GetStringUTF16(accessibility_string_id)); button->SetID(view_id); - AddChildView(button); button->SetPaintToLayer(); button->layer()->SetFillsBoundsOpaquely(false); - return button; + return AddChildView(std::move(button)); } gfx::Insets OpaqueFrameView::FrameBorderInsets(bool restored) const { diff --git a/shell/browser/ui/views/win_caption_button_container.h b/shell/browser/ui/views/win_caption_button_container.h index 7c2390b7da20..bef48521a094 100644 --- a/shell/browser/ui/views/win_caption_button_container.h +++ b/shell/browser/ui/views/win_caption_button_container.h @@ -67,11 +67,11 @@ class WinCaptionButtonContainer : public views::View, void OnWidgetBoundsChanged(views::Widget* widget, const gfx::Rect& new_bounds) override; - raw_ptr const frame_view_; - raw_ptr const minimize_button_; - raw_ptr const maximize_button_; - raw_ptr const restore_button_; - raw_ptr const close_button_; + const raw_ptr frame_view_; + const raw_ptr minimize_button_; + const raw_ptr maximize_button_; + const raw_ptr restore_button_; + const raw_ptr close_button_; base::ScopedObservation widget_observation_{this};