Skip to content

Commit daf1680

Browse files
committed
Merge pull request #1035 from brave/maxk-no-singin-profile-chooser
Remove sync/sign in language from avatar menu.
1 parent 81df4b8 commit daf1680

5 files changed

+105
-3
lines changed

browser/ui/views/profiles/brave_profile_chooser_view.cc

+37
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
#include "brave/grit/brave_generated_resources.h"
1010
#include "chrome/app/vector_icons/vector_icons.h"
1111
#include "chrome/browser/profiles/profile_manager.h"
12+
#include "chrome/browser/profiles/profiles_state.h"
1213
#include "chrome/browser/profiles/profile_window.h"
14+
#include "chrome/browser/ui/views/chrome_layout_provider.h"
1315
#include "chrome/browser/ui/views/hover_button.h"
16+
#include "chrome/browser/ui/views/profiles/badged_profile_photo.h"
17+
#include "chrome/grit/generated_resources.h"
1418
#include "ui/base/l10n/l10n_util.h"
1519
#include "ui/gfx/paint_vector_icon.h"
1620
#include "ui/views/controls/button/label_button.h"
21+
#include "ui/views/layout/box_layout.h"
1722
#include "ui/views/layout/grid_layout.h"
1823

1924
namespace {
@@ -63,3 +68,35 @@ void BraveProfileChooserView::ResetView() {
6368
ProfileChooserView::ResetView();
6469
tor_profile_button_ = nullptr;
6570
}
71+
72+
views::View* BraveProfileChooserView::CreateDiceSyncErrorView(
73+
const AvatarMenu::Item& avatar_item,
74+
sync_ui_util::AvatarSyncErrorType error,
75+
int button_string_id) {
76+
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
77+
78+
views::View* view = new views::View();
79+
int content_list_vert_spacing =
80+
provider->GetDistanceMetric(DISTANCE_CONTENT_LIST_VERTICAL_SINGLE);
81+
view->SetLayoutManager(std::make_unique<views::BoxLayout>(
82+
views::BoxLayout::kVertical, gfx::Insets(content_list_vert_spacing, 0),
83+
0));
84+
85+
Profile* profile = browser_->profile();
86+
auto current_profile_photo = std::make_unique<BadgedProfilePhoto>(
87+
BadgedProfilePhoto::BADGE_TYPE_NONE, avatar_item.icon);
88+
base::string16 profile_name = avatar_item.name;
89+
if (profile_name.empty())
90+
profile_name = profiles::GetAvatarNameForProfile(profile->GetPath());
91+
92+
HoverButton* profile_card = new HoverButton(
93+
this, std::move(current_profile_photo), profile_name, base::string16());
94+
current_profile_card_ = profile_card;
95+
view->AddChildView(current_profile_card_);
96+
97+
current_profile_card_->SetAccessibleName(
98+
l10n_util::GetStringFUTF16(
99+
IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME, profile_name));
100+
101+
return view;
102+
}

browser/ui/views/profiles/brave_profile_chooser_view.h

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class BraveProfileChooserView : public ProfileChooserView {
2323

2424
void ResetView() override;
2525

26+
views::View* CreateDiceSyncErrorView(const AvatarMenu::Item& avatar_item,
27+
sync_ui_util::AvatarSyncErrorType error,
28+
int button_string_id) override;
29+
2630
void AddTorButton(views::GridLayout* layout);
2731

2832
views::LabelButton* tor_profile_button_;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
#include "brave/browser/ui/views/profiles/brave_profile_chooser_view.h"
6+
7+
#include "chrome/browser/profiles/avatar_menu.h"
8+
#include "chrome/browser/ui/views/frame/browser_view.h"
9+
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
10+
#include "chrome/test/base/in_process_browser_test.h"
11+
#include "ui/events/base_event_utils.h"
12+
#include "ui/events/event.h"
13+
#include "ui/gfx/geometry/point.h"
14+
#include "ui/views/controls/button/button.h"
15+
#include "ui/views/controls/button/label_button.h"
16+
17+
class BraveProfileChooserViewTest : public InProcessBrowserTest {
18+
public:
19+
BraveProfileChooserViewTest() = default;
20+
~BraveProfileChooserViewTest() override = default;
21+
22+
protected:
23+
void OpenProfileChooserView(Browser* browser) {
24+
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
25+
views::View* button = browser_view->toolbar()->avatar_button();
26+
DCHECK(button);
27+
28+
ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
29+
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
30+
button->OnMousePressed(e);
31+
}
32+
33+
AvatarMenu* avatar_menu() {
34+
return ProfileChooserView::profile_bubble_->avatar_menu_.get();
35+
}
36+
37+
views::LabelButton* current_profile_card() {
38+
return ProfileChooserView::profile_bubble_->current_profile_card_;
39+
}
40+
41+
private:
42+
DISALLOW_COPY_AND_ASSIGN(BraveProfileChooserViewTest);
43+
};
44+
45+
IN_PROC_BROWSER_TEST_F(BraveProfileChooserViewTest, TestCurrentProfileView) {
46+
OpenProfileChooserView(browser());
47+
48+
EXPECT_EQ(1u, avatar_menu()->GetNumberOfItems());
49+
ASSERT_EQ(avatar_menu()->GetItemAt(0).name,
50+
current_profile_card()->accessible_name());
51+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.h b/chrome/browser/ui/views/profiles/profile_chooser_view.h
2-
index 83709a31644e43fad0a3754a37db181d7ce7b9f6..e0bf4ca6d80713b5830fa0f0dd7d1080a849968f 100644
2+
index 83709a31644e43fad0a3754a37db181d7ce7b9f6..3f9b08b74a1a17c8e3bc4872b7069416f92d2cd8 100644
33
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.h
44
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.h
5-
@@ -71,6 +71,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
5+
@@ -71,6 +71,8 @@ class ProfileChooserView : public content::WebContentsDelegate,
66
const Browser* browser() const { return browser_; }
77

88
private:
99
+ friend class BraveProfileChooserView;
10+
+ friend class BraveProfileChooserViewTest;
1011
friend class ProfileChooserViewExtensionsTest;
1112

1213
typedef std::vector<size_t> Indexes;
13-
@@ -120,7 +121,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
14+
@@ -120,7 +122,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
1415
// Tests set this to "false" for more consistent operation.
1516
static bool close_on_deactivate_for_testing_;
1617

@@ -19,3 +20,11 @@ index 83709a31644e43fad0a3754a37db181d7ce7b9f6..e0bf4ca6d80713b5830fa0f0dd7d1080
1920

2021
// Shows the bubble with the |view_to_display|.
2122
void ShowView(profiles::BubbleViewMode view_to_display,
23+
@@ -168,6 +170,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
24+
25+
// Creates a view showing the profile associated with |avatar_item| and an
26+
// error button below.
27+
+ virtual
28+
views::View* CreateDiceSyncErrorView(const AvatarMenu::Item& avatar_item,
29+
sync_ui_util::AvatarSyncErrorType error,
30+
int button_string_id);

test/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ test("brave_browser_tests") {
247247
"//brave/browser/ui/content_settings/brave_autoplay_blocked_image_model_browsertest.cc",
248248
"//brave/browser/ui/webui/brave_new_tab_ui_browsertest.cc",
249249
"//brave/browser/ui/webui/brave_welcome_ui_browsertest.cc",
250+
"//brave/browser/ui/views/profiles/brave_profile_chooser_view_browsertest.cc",
250251
"//brave/common/brave_channel_info_browsertest.cc",
251252
"//brave/components/brave_shields/browser/ad_block_service_browsertest.cc",
252253
"//brave/components/brave_shields/browser/https_everywhere_service_browsertest.cc",

0 commit comments

Comments
 (0)