Commit cd984b40 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Refactor profile management separator

+ Add separator margins.
+ Only show separator when there is a profile
  management part. (Not the case in incognito.)

Bug: 1017241
Change-Id: I67f17905596915bb85b136cb262523560d15cb75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1876807Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708945}
parent 5595df4d
...@@ -437,6 +437,19 @@ void ProfileMenuViewBase::AddFeatureButton(const gfx::ImageSkia& icon, ...@@ -437,6 +437,19 @@ void ProfileMenuViewBase::AddFeatureButton(const gfx::ImageSkia& icon,
void ProfileMenuViewBase::SetProfileManagementHeading( void ProfileMenuViewBase::SetProfileManagementHeading(
const base::string16& heading) { const base::string16& heading) {
constexpr int kSeparatorMargins = 4;
// Add separator before heading.
profile_mgmt_separator_container_->RemoveAllChildViews(
/*delete_children=*/true);
profile_mgmt_separator_container_->SetLayoutManager(
std::make_unique<views::FillLayout>());
profile_mgmt_separator_container_->SetBorder(views::CreateEmptyBorder(
gfx::Insets(kSeparatorMargins, /*horizontal=*/0)));
profile_mgmt_separator_container_->AddChildView(
std::make_unique<views::Separator>());
// Initialize heading layout.
profile_mgmt_heading_container_->RemoveAllChildViews( profile_mgmt_heading_container_->RemoveAllChildViews(
/*delete_children=*/true); /*delete_children=*/true);
profile_mgmt_heading_container_->SetLayoutManager( profile_mgmt_heading_container_->SetLayoutManager(
...@@ -444,6 +457,7 @@ void ProfileMenuViewBase::SetProfileManagementHeading( ...@@ -444,6 +457,7 @@ void ProfileMenuViewBase::SetProfileManagementHeading(
profile_mgmt_heading_container_->SetBorder(views::CreateEmptyBorder( profile_mgmt_heading_container_->SetBorder(views::CreateEmptyBorder(
gfx::Insets(kDefaultVerticalMargin, kMenuEdgeMargin))); gfx::Insets(kDefaultVerticalMargin, kMenuEdgeMargin)));
// Add heading.
views::Label* label = profile_mgmt_heading_container_->AddChildView( views::Label* label = profile_mgmt_heading_container_->AddChildView(
std::make_unique<views::Label>(heading, views::style::CONTEXT_LABEL, std::make_unique<views::Label>(heading, views::style::CONTEXT_LABEL,
STYLE_HINT)); STYLE_HINT));
...@@ -629,20 +643,24 @@ void ProfileMenuViewBase::Reset() { ...@@ -629,20 +643,24 @@ void ProfileMenuViewBase::Reset() {
components->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
features_container_ = features_container_ =
components->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
// Second, add the profile management header. profile_mgmt_separator_container_ =
components->AddChildView(new views::Separator()); components->AddChildView(std::make_unique<views::View>());
auto profile_header = std::make_unique<views::View>(); // Second, add the profile management header. This includes the heading and
views::BoxLayout* profile_header_layout = profile_header->SetLayoutManager( // the shortcut feature(s) next to it.
CreateBoxLayout(views::BoxLayout::Orientation::kHorizontal, auto profile_mgmt_header = std::make_unique<views::View>();
views::BoxLayout::CrossAxisAlignment::kCenter)); views::BoxLayout* profile_mgmt_header_layout =
profile_mgmt_header->SetLayoutManager(
CreateBoxLayout(views::BoxLayout::Orientation::kHorizontal,
views::BoxLayout::CrossAxisAlignment::kCenter));
profile_mgmt_heading_container_ = profile_mgmt_heading_container_ =
profile_header->AddChildView(std::make_unique<views::View>()); profile_mgmt_header->AddChildView(std::make_unique<views::View>());
profile_header_layout->SetFlexForView(profile_mgmt_heading_container_, 1); profile_mgmt_header_layout->SetFlexForView(profile_mgmt_heading_container_,
1);
profile_mgmt_shortcut_features_container_ = profile_mgmt_shortcut_features_container_ =
profile_header->AddChildView(std::make_unique<views::View>()); profile_mgmt_header->AddChildView(std::make_unique<views::View>());
profile_header_layout->SetFlexForView( profile_mgmt_header_layout->SetFlexForView(
profile_mgmt_shortcut_features_container_, 0); profile_mgmt_shortcut_features_container_, 0);
components->AddChildView(std::move(profile_header)); components->AddChildView(std::move(profile_mgmt_header));
// Third, add the profile management buttons. // Third, add the profile management buttons.
selectable_profiles_container_ = selectable_profiles_container_ =
components->AddChildView(std::make_unique<views::View>()); components->AddChildView(std::make_unique<views::View>());
......
...@@ -263,6 +263,7 @@ class ProfileMenuViewBase : public content::WebContentsDelegate, ...@@ -263,6 +263,7 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
views::View* sync_info_container_ = nullptr; views::View* sync_info_container_ = nullptr;
views::View* shortcut_features_container_ = nullptr; views::View* shortcut_features_container_ = nullptr;
views::View* features_container_ = nullptr; views::View* features_container_ = nullptr;
views::View* profile_mgmt_separator_container_ = nullptr;
views::View* profile_mgmt_heading_container_ = nullptr; views::View* profile_mgmt_heading_container_ = nullptr;
views::View* selectable_profiles_container_ = nullptr; views::View* selectable_profiles_container_ = nullptr;
views::View* profile_mgmt_shortcut_features_container_ = nullptr; views::View* profile_mgmt_shortcut_features_container_ = nullptr;
......
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