Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: ash/system/user/user_view.cc

Issue 2816193002: Introduce a type of View background that stays in sync with its host (Closed)
Patch Set: tdanderson review + rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/user/user_view.cc
diff --git a/ash/system/user/user_view.cc b/ash/system/user/user_view.cc
index fe2ff061c8ceb920ba8c8d8fb6ab226e587c99ae..fb96987cd927ad46fb9072484ed2716bab72ebdc 100644
--- a/ash/system/user/user_view.cc
+++ b/ash/system/user/user_view.cc
@@ -36,6 +36,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
+#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/separator.h"
@@ -72,8 +73,7 @@ bool IsMultiProfileSupportedAndUserActive() {
}
// Creates the view shown in the user switcher popup ("AddUserMenuOption").
-views::View* CreateAddUserView(AddUserSessionPolicy policy,
- views::ButtonListener* listener) {
+views::View* CreateAddUserView(AddUserSessionPolicy policy) {
auto* view = new views::View;
const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
auto* layout =
@@ -81,8 +81,8 @@ views::View* CreateAddUserView(AddUserSessionPolicy policy,
kTrayPopupLabelHorizontalPadding + icon_padding);
layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight);
view->SetLayoutManager(layout);
- view->set_background(
- views::Background::CreateSolidBackground(kBackgroundColor));
+ view->set_background(views::Background::CreateThemedSolidBackground(
+ view, ui::NativeTheme::kColorId_BubbleBackground));
int message_id = 0;
switch (policy) {
@@ -123,13 +123,6 @@ views::View* CreateAddUserView(AddUserSessionPolicy policy,
view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding,
vertical_padding,
kTrayPopupLabelHorizontalPadding));
- if (policy == AddUserSessionPolicy::ALLOWED) {
- auto* button =
- new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS);
- button->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
- return button;
- }
return view;
}
@@ -364,14 +357,23 @@ void UserView::ToggleAddUserMenuOption() {
views::View* container = new AddUserWidgetContents(
base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this)));
+ views::View* add_user_view = CreateAddUserView(add_user_policy);
+ const SkColor bg_color = add_user_view->background()->get_color();
container->SetBorder(views::CreatePaddedBorder(
- views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth, kBackgroundColor),
+ views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth, bg_color),
gfx::Insets(row_height, 0, 0, 0)));
views::View* add_user_padding = new views::View();
add_user_padding->SetBorder(views::CreateSolidSidedBorder(
- kMenuSeparatorVerticalPadding, 0, 0, 0, kBackgroundColor));
- views::View* add_user_view = CreateAddUserView(add_user_policy, this);
- add_user_padding->AddChildView(add_user_view);
+ kMenuSeparatorVerticalPadding, 0, 0, 0, bg_color));
+ if (add_user_enabled_) {
+ auto* button = new ButtonFromView(add_user_view, this,
+ TrayPopupInkDropStyle::INSET_BOUNDS);
+ button->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
+ add_user_padding->AddChildView(button);
Evan Stade 2017/04/19 18:49:07 oops, this will break the button pressed handler.
+ } else {
+ add_user_padding->AddChildView(add_user_view);
+ }
add_user_padding->SetLayoutManager(new views::FillLayout());
container->AddChildView(add_user_padding);
container->SetLayoutManager(new views::FillLayout());

Powered by Google App Engine
This is Rietveld 408576698