Skip to content

Commit

Permalink
[DanglingPtr] Remove ProfileMenuViewBase patching (#26499)
Browse files Browse the repository at this point in the history
This patch was introduced as a temporary measure to allow switching on
the dangling pointer detector.

This PR fixes the two dangling pointers in `ProfileMenuViewBase` by
avoiding calling `SetProfileIdentityInfo` more than once, and actually
overriding it, so the first call to the `SetProfileIdentityInfo` can be
given the correct arguments.

One test had to be disabled, as it was not actually testing the way the
profile menu viewer was being instantiated. The way brave does it
requires to consult theme data, which is not available for this
particular test.

Resolves brave/brave-browser#42231
  • Loading branch information
cdesouza-chromium authored and emerick committed Dec 2, 2024
1 parent 28923ae commit d9d98f7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion browser/ui/views/profiles/brave_profile_menu_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void BraveProfileMenuView::SetProfileIdentityInfo(
.GetProfileAttributesWithPath(profile->GetPath());
// Reset IdentityInfo to get rid of the subtitle string
// IDS_PROFILES_LOCAL_PROFILE_STATE("Not signed in").
SetProfileIdentityInfo(
ProfileMenuView::SetProfileIdentityInfo(
/*profile_name=*/std::u16string(),
profile_attributes->GetProfileThemeColors().profile_highlight_color,
/*edit_button_params=*/std::nullopt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
friend class BraveProfileMenuViewTest; \
\
public:

// Overriding this function to avoid a second call to it.
#define SetProfileIdentityInfo(...) virtual SetProfileIdentityInfo(__VA_ARGS__)

#include "src/chrome/browser/ui/views/profiles/profile_menu_view_base.h" // IWYU pragma: export

#undef BRAVE_PROFILE_MENU_VIEW_BASE_H_
#undef SetProfileIdentityInfo

#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_MENU_VIEW_BASE_H_
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_base.h b/chrome/browser/ui/views/profiles/profile_menu_view_base.h
index 58cdfb2a74ae56bfa0b08f97215b3ffb5a752875..293c05b807a9fa77e37310049b0965bc15d1ae0b 100644
index 58cdfb2a74ae56bfa0b08f97215b3ffb5a752875..724d4804b3ac1f5a1ac898c8cf5eac5d18b8d246 100644
--- a/chrome/browser/ui/views/profiles/profile_menu_view_base.h
+++ b/chrome/browser/ui/views/profiles/profile_menu_view_base.h
@@ -198,6 +198,7 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
Expand All @@ -10,18 +10,3 @@ index 58cdfb2a74ae56bfa0b08f97215b3ffb5a752875..293c05b807a9fa77e37310049b0965bc

private:
class AXMenuWidgetObserver;
@@ -253,10 +254,10 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
raw_ptr<views::View> profile_mgmt_features_container_ = nullptr;

// Child components of `identity_info_container_`.
- raw_ptr<views::FlexLayoutView> profile_background_container_ = nullptr;
- raw_ptr<views::Label> heading_label_ = nullptr;
- raw_ptr<views::Label> title_label_ = nullptr;
- raw_ptr<views::Label> subtitle_label_ = nullptr;
+ raw_ptr<views::FlexLayoutView, DanglingUntriaged> profile_background_container_ = nullptr;
+ raw_ptr<views::Label, DanglingUntriaged> heading_label_ = nullptr;
+ raw_ptr<views::Label, DanglingUntriaged> title_label_ = nullptr;
+ raw_ptr<views::Label, DanglingUntriaged> subtitle_label_ = nullptr;

// The first profile button that should be focused when the menu is opened
// using a key accelerator.
1 change: 1 addition & 0 deletions test/filters/browser_tests.filter
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@
-NTPTilesForSupervisedUsersTest.LoadURL
-PasswordStatusCheckServiceBaseTest.CheckTimeUpdatedAfterRunScheduledInThePast
-PowerBookmarkBubbleViewBrowserTest.InvokeUi_bookmark_details_on_trackable_product
-ProfileMenuClickTest_GuestProfile.ProfileMenuClickTest_GuestProfile/*
-ProfileMenuClickTest_GuestProfileButtonAvailable_SignedInNotSupervised.*/*
-ProfileMenuClickTest_GuestProfileButtonNotAvailable_SignedInSupervised.*/*
-ProfileMenuClickTest_PasswordManagerWebApp.ProfileMenuClickTest_PasswordManagerWebApp/*
Expand Down

0 comments on commit d9d98f7

Please sign in to comment.