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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2023093002: Reflow of the profile items in desktop user menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-profile-icon
Patch Set: More comments x 2 Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "ui/views/layout/box_layout.h" 76 #include "ui/views/layout/box_layout.h"
77 #include "ui/views/layout/fill_layout.h" 77 #include "ui/views/layout/fill_layout.h"
78 #include "ui/views/layout/grid_layout.h" 78 #include "ui/views/layout/grid_layout.h"
79 #include "ui/views/layout/layout_constants.h" 79 #include "ui/views/layout/layout_constants.h"
80 #include "ui/views/widget/widget.h" 80 #include "ui/views/widget/widget.h"
81 81
82 namespace { 82 namespace {
83 83
84 // Helpers -------------------------------------------------------------------- 84 // Helpers --------------------------------------------------------------------
85 85
86 const int kFixedMenuWidth = 250;
87 const int kButtonHeight = 32; 86 const int kButtonHeight = 32;
88 const int kPasswordCombinedFixedGaiaViewWidth = 360; 87 const int kPasswordCombinedFixedGaiaViewWidth = 360;
89 const int kFixedGaiaViewWidth = 448; 88 const int kFixedGaiaViewWidth = 448;
90 const int kFixedAccountRemovalViewWidth = 280; 89 const int kFixedAccountRemovalViewWidth = 280;
91 const int kFixedSwitchUserViewWidth = 320; 90 const int kFixedSwitchUserViewWidth = 320;
92 const int kLargeImageSide = 88; 91 const int kLargeImageSide = 88;
92 const int kMediumImageSide = 40;
93
94 // Vertical spacing between the edge of the material design user menu and the
95 // top or bottom of the menu items.
96 const int kMaterialMenuVerticalEdgeMargin = 16;
97 // Horizontal spacing between the edge of the material design user menu and the
98 // left or right of the menu items.
99 const int kMaterialMenuHorizontalEdgeMargin = 16;
93 100
94 const int kVerticalSpacing = 16; 101 const int kVerticalSpacing = 16;
95 102
96 const int kTitleViewNativeWidgetOffset = 8; 103 const int kTitleViewNativeWidgetOffset = 8;
97 104
98 bool IsProfileChooser(profiles::BubbleViewMode mode) { 105 bool IsProfileChooser(profiles::BubbleViewMode mode) {
99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || 106 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; 107 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
101 } 108 }
102 109
110 int GetProfileBadgeSize() {
111 return switches::IsMaterialDesignUserMenu() ? 24 : 30;
112 }
113
114 // DEPRECATED: New user menu components should use views::BoxLayout instead.
103 // Creates a GridLayout with a single column. This ensures that all the child 115 // Creates a GridLayout with a single column. This ensures that all the child
104 // views added get auto-expanded to fill the full width of the bubble. 116 // views added get auto-expanded to fill the full width of the bubble.
105 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { 117 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) {
106 views::GridLayout* layout = new views::GridLayout(view); 118 views::GridLayout* layout = new views::GridLayout(view);
107 view->SetLayoutManager(layout); 119 view->SetLayoutManager(layout);
108 120
109 views::ColumnSet* columns = layout->AddColumnSet(0); 121 views::ColumnSet* columns = layout->AddColumnSet(0);
110 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 122 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
111 views::GridLayout::FIXED, width, width); 123 views::GridLayout::FIXED, width, width);
112 return layout; 124 return layout;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 gfx::Rect bounds(title_view_->GetPreferredSize()); 268 gfx::Rect bounds(title_view_->GetPreferredSize());
257 title_view_->SetBoundsRect(bounds); 269 title_view_->SetBoundsRect(bounds);
258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); 270 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset);
259 title_widget_->SetBounds(bounds); 271 title_widget_->SetBounds(bounds);
260 } 272 }
261 273
262 } // namespace 274 } // namespace
263 275
264 // RightAlignedIconLabelButton ------------------------------------------------- 276 // RightAlignedIconLabelButton -------------------------------------------------
265 277
266 // A custom LabelButton that has a centered text and right aligned icon. 278 // A custom LabelButton that has a left-aligned text and right aligned icon.
279 // For non-material-design user menu, it has centered text instead.
267 class RightAlignedIconLabelButton : public views::LabelButton { 280 class RightAlignedIconLabelButton : public views::LabelButton {
268 public: 281 public:
269 RightAlignedIconLabelButton(views::ButtonListener* listener, 282 RightAlignedIconLabelButton(views::ButtonListener* listener,
270 const base::string16& text) 283 const base::string16& text)
271 : views::LabelButton(listener, text) { 284 : views::LabelButton(listener, text) {
272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); 285 SetHorizontalAlignment(gfx::ALIGN_RIGHT);
273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); 286 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu()
287 ? gfx::ALIGN_LEFT
288 : gfx::ALIGN_CENTER);
274 } 289 }
275 290
276 protected: 291 protected:
277 void Layout() override { 292 void Layout() override {
278 views::LabelButton::Layout(); 293 views::LabelButton::Layout();
279 294
280 // Keep the text centered and the icon right-aligned by stretching the label 295 // Keep the text centered and the icon right-aligned by stretching the label
281 // to take up more of the content area and centering its contents. 296 // to take up more of the content area and centering its contents.
282 gfx::Rect content_bounds = GetContentsBounds(); 297 gfx::Rect content_bounds = GetContentsBounds();
283 gfx::Rect label_bounds = label()->bounds(); 298 gfx::Rect label_bounds = label()->bounds();
(...skipping 17 matching lines...) Expand all
301 316
302 // A custom Image control that shows a "change" button when moused over. 317 // A custom Image control that shows a "change" button when moused over.
303 class EditableProfilePhoto : public views::LabelButton { 318 class EditableProfilePhoto : public views::LabelButton {
304 public: 319 public:
305 EditableProfilePhoto(views::ButtonListener* listener, 320 EditableProfilePhoto(views::ButtonListener* listener,
306 const gfx::Image& icon, 321 const gfx::Image& icon,
307 bool is_editing_allowed, 322 bool is_editing_allowed,
308 const gfx::Rect& bounds) 323 const gfx::Rect& bounds)
309 : views::LabelButton(listener, base::string16()), 324 : views::LabelButton(listener, base::string16()),
310 photo_overlay_(NULL) { 325 photo_overlay_(NULL) {
311 gfx::Image image = profiles::GetSizedAvatarIcon( 326 const int icon_image_side = switches::IsMaterialDesignUserMenu()
312 icon, true, kLargeImageSide, kLargeImageSide); 327 ? kMediumImageSide
328 : kLargeImageSide;
329 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side,
330 icon_image_side);
313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); 331 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia());
314 SetBorder(views::Border::NullBorder()); 332 SetBorder(views::Border::NullBorder());
315 SetBoundsRect(bounds); 333 SetBoundsRect(bounds);
316 334
317 // Calculate the circular mask that will be used to display the photo. 335 // Calculate the circular mask that will be used to display the photo.
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), 336 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2),
319 SkIntToScalar(bounds.height() / 2), 337 SkIntToScalar(bounds.height() / 2),
320 SkIntToScalar(bounds.width() / 2)); 338 SkIntToScalar(bounds.width() / 2));
321 339
322 if (!is_editing_allowed) { 340 if (!is_editing_allowed) {
323 SetEnabled(false); 341 SetEnabled(false);
324 return; 342 return;
325 } 343 }
326 344
327 set_notify_enter_exit_on_child(true); 345 set_notify_enter_exit_on_child(true);
328 346
329 // Photo overlay that appears when hovering over the button. 347 // Photo overlay that appears when hovering over the button.
330 photo_overlay_ = new views::ImageView(); 348 photo_overlay_ = new views::ImageView();
331 349
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); 350 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255);
333 photo_overlay_->set_background( 351 photo_overlay_->set_background(
334 views::Background::CreateSolidBackground(kBackgroundColor)); 352 views::Background::CreateSolidBackground(kBackgroundColor));
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( 353 photo_overlay_->SetImage(
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); 354 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA,
355 switches::IsMaterialDesignUserMenu() ? 22u : 48u,
356 SkColorSetRGB(0x33, 0x33, 0x33)));
337 357
338 photo_overlay_->SetSize(bounds.size()); 358 photo_overlay_->SetSize(bounds.size());
339 photo_overlay_->SetVisible(false); 359 photo_overlay_->SetVisible(false);
340 AddChildView(photo_overlay_); 360 AddChildView(photo_overlay_);
341 } 361 }
342 362
343 void OnPaint(gfx::Canvas* canvas) override { 363 void OnPaint(gfx::Canvas* canvas) override {
344 // Display the profile picture as a circle. 364 // Display the profile picture as a circle.
345 canvas->ClipPath(circular_mask_, true); 365 canvas->ClipPath(circular_mask_, true);
346 views::LabelButton::OnPaint(canvas); 366 views::LabelButton::OnPaint(canvas);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 406
387 // EditableProfileName ------------------------------------------------- 407 // EditableProfileName -------------------------------------------------
388 408
389 // A custom text control that turns into a textfield for editing when clicked. 409 // A custom text control that turns into a textfield for editing when clicked.
390 class EditableProfileName : public views::View, 410 class EditableProfileName : public views::View,
391 public views::ButtonListener { 411 public views::ButtonListener {
392 public: 412 public:
393 EditableProfileName(views::TextfieldController* controller, 413 EditableProfileName(views::TextfieldController* controller,
394 const base::string16& text, 414 const base::string16& text,
395 bool is_editing_allowed) 415 bool is_editing_allowed)
396 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { 416 : button_(nullptr), profile_name_textfield_(nullptr) {
397 SetLayoutManager( 417 SetLayoutManager(
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 418 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
399 419
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 420 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
401 const gfx::FontList& medium_font_list = 421 const gfx::FontList& medium_font_list =
402 rb->GetFontList(ui::ResourceBundle::MediumFont); 422 rb->GetFontList(ui::ResourceBundle::MediumFont);
403 423
404 if (!is_editing_allowed) { 424 if (!is_editing_allowed) {
405 label_ = new views::Label(text); 425 views::Label* name_label = new views::Label(text);
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); 426 name_label->SetBorder(
407 label_->SetFontList(medium_font_list); 427 views::Border::CreateEmptyBorder(border_width, 0, border_width, 0));
408 AddChildView(label_); 428 name_label->SetFontList(medium_font_list);
429 if (switches::IsMaterialDesignUserMenu())
430 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
431 AddChildView(name_label);
409 return; 432 return;
410 } 433 }
411 434
435 profile_name_textfield_ = new views::Textfield();
436 // Textfield that overlaps the button.
437 profile_name_textfield_->set_controller(controller);
438 profile_name_textfield_->SetFontList(medium_font_list);
439 profile_name_textfield_->SetHorizontalAlignment(
440 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT
441 : gfx::ALIGN_CENTER);
442 profile_name_textfield_->SetVisible(false);
443 AddChildView(profile_name_textfield_);
444
412 button_ = new RightAlignedIconLabelButton(this, text); 445 button_ = new RightAlignedIconLabelButton(this, text);
413 button_->SetFontList(medium_font_list); 446 button_->SetFontList(medium_font_list);
414 // Show an "edit" pencil icon when hovering over. In the default state, 447 // Show an "edit" pencil icon when hovering over. In the default state,
415 // we need to create an empty placeholder of the correct size, so that 448 // we need to create an empty placeholder of the correct size, so that
416 // the text doesn't jump around when the hovered icon appears. 449 // the text doesn't jump around when the hovered icon appears.
417 // TODO(estade): revisit colors and press effect. 450 // TODO(estade): revisit colors and press effect.
418 const int kIconSize = 16; 451 const int kIconSize = 16;
419 button_->SetImage(views::LabelButton::STATE_NORMAL, 452 button_->SetImage(views::LabelButton::STATE_NORMAL,
420 CreateSquarePlaceholderImage(kIconSize)); 453 CreateSquarePlaceholderImage(kIconSize));
421 button_->SetImage(views::LabelButton::STATE_HOVERED, 454 button_->SetImage(views::LabelButton::STATE_HOVERED,
422 gfx::CreateVectorIcon( 455 gfx::CreateVectorIcon(
423 gfx::VectorIconId::MODE_EDIT, kIconSize, 456 gfx::VectorIconId::MODE_EDIT, kIconSize,
424 SkColorSetRGB(0x33, 0x33, 0x33))); 457 SkColorSetRGB(0x33, 0x33, 0x33)));
425 button_->SetImage(views::LabelButton::STATE_PRESSED, 458 button_->SetImage(views::LabelButton::STATE_PRESSED,
426 gfx::CreateVectorIcon( 459 gfx::CreateVectorIcon(
427 gfx::VectorIconId::MODE_EDIT, kIconSize, 460 gfx::VectorIconId::MODE_EDIT, kIconSize,
428 SkColorSetRGB(0x20, 0x20, 0x20))); 461 SkColorSetRGB(0x20, 0x20, 0x20)));
429 // To center the text, we need to offest it by the width of the icon we 462 // We need to add a left padding as well as a small top/bottom padding
430 // are adding and its padding. We need to also add a small top/bottom 463 // to the text to account for the textfield's border.
431 // padding to account for the textfield's border. 464 if (switches::IsMaterialDesignUserMenu()) {
432 const int kIconTextLabelButtonSpacing = 5; 465 button_->SetBorder(views::Border::CreateEmptyBorder(
433 button_->SetBorder(views::Border::CreateEmptyBorder( 466 border_width, profile_name_textfield_->GetInsets().left(),
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); 467 border_width, 0));
468 } else {
469 const int kIconTextLabelButtonSpacing = 5;
470 button_->SetBorder(views::Border::CreateEmptyBorder(
471 border_width, kIconSize + kIconTextLabelButtonSpacing, border_width,
472 0));
473 }
435 AddChildView(button_); 474 AddChildView(button_);
436
437 profile_name_textfield_ = new views::Textfield();
438 // Textfield that overlaps the button.
439 profile_name_textfield_->set_controller(controller);
440 profile_name_textfield_->SetFontList(medium_font_list);
441 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
442 profile_name_textfield_->SetVisible(false);
443 AddChildView(profile_name_textfield_);
444 } 475 }
445 476
446 views::Textfield* profile_name_textfield() { 477 views::Textfield* profile_name_textfield() {
447 return profile_name_textfield_; 478 return profile_name_textfield_;
448 } 479 }
449 480
450 // Hide the editable textfield to show the profile name button instead. 481 // Hide the editable textfield to show the profile name button instead.
451 void ShowReadOnlyView() { 482 void ShowReadOnlyView() {
452 button_->SetVisible(true); 483 button_->SetVisible(true);
453 profile_name_textfield_->SetVisible(false); 484 profile_name_textfield_->SetVisible(false);
454 } 485 }
455 486
487 static const int border_width = 2;
488
456 private: 489 private:
457 // views::ButtonListener: 490 // views::ButtonListener:
458 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 491 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
459 button_->SetVisible(false); 492 button_->SetVisible(false);
460 profile_name_textfield_->SetVisible(true); 493 profile_name_textfield_->SetVisible(true);
461 profile_name_textfield_->SetText(button_->GetText()); 494 profile_name_textfield_->SetText(button_->GetText());
462 profile_name_textfield_->SelectAll(false); 495 profile_name_textfield_->SelectAll(false);
463 profile_name_textfield_->RequestFocus(); 496 profile_name_textfield_->RequestFocus();
464 // Re-layouts the view after swaping the controls. 497 // Re-layouts the view after swaping the controls.
465 Layout(); 498 Layout();
466 } 499 }
467 500
468 // views::LabelButton: 501 // views::LabelButton:
469 bool OnKeyReleased(const ui::KeyEvent& event) override { 502 bool OnKeyReleased(const ui::KeyEvent& event) override {
470 // Override CustomButton's implementation, which presses the button when 503 // Override CustomButton's implementation, which presses the button when
471 // you press space and clicks it when you release space, as the space can be 504 // you press space and clicks it when you release space, as the space can be
472 // part of the new profile name typed in the textfield. 505 // part of the new profile name typed in the textfield.
473 return false; 506 return false;
474 } 507 }
475 508
476 // The label button which shows the profile name, and can handle the event to 509 // The label button which shows the profile name, and can handle the event to
477 // make it editable. Can be NULL if the profile name isn't allowed to be 510 // make it editable. Can be NULL if the profile name isn't allowed to be
478 // edited. 511 // edited.
479 RightAlignedIconLabelButton* button_; 512 RightAlignedIconLabelButton* button_;
480 513
481 // The label which shows when the profile name cannot be edited (e.g. for
482 // supervised user). Can be NULL if the profile name is allowed to be edited.
483 views::Label* label_;
484
485 // Textfield that is shown when editing the profile name. Can be NULL if 514 // Textfield that is shown when editing the profile name. Can be NULL if
486 // the profile name isn't allowed to be edited (e.g. for guest profiles). 515 // the profile name isn't allowed to be edited (e.g. for guest profiles).
487 views::Textfield* profile_name_textfield_; 516 views::Textfield* profile_name_textfield_;
488 517
489 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); 518 DISALLOW_COPY_AND_ASSIGN(EditableProfileName);
490 }; 519 };
491 520
492 // A title card with one back button right aligned and one label center aligned. 521 // A title card with one back button right aligned and one label center aligned.
493 class TitleCard : public views::View { 522 class TitleCard : public views::View {
494 public: 523 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 586 }
558 587
559 views::ImageButton* back_button_; 588 views::ImageButton* back_button_;
560 views::Label* title_label_; 589 views::Label* title_label_;
561 590
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); 591 DISALLOW_COPY_AND_ASSIGN(TitleCard);
563 }; 592 };
564 593
565 // ProfileBadge -------------------------------------------------------- 594 // ProfileBadge --------------------------------------------------------
566 595
567 const size_t kProfileBadgeSize = 30;
568 const size_t kProfileBadgeWhitePadding = 2; 596 const size_t kProfileBadgeWhitePadding = 2;
569 597
570 // Draws a white circle, then a light blue circle, then a dark blue icon. 598 // Draws a white circle, then a light blue circle, then a dark blue icon.
571 class ProfileBadge : public gfx::CanvasImageSource { 599 class ProfileBadge : public gfx::CanvasImageSource {
572 public: 600 public:
573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) 601 ProfileBadge(gfx::VectorIconId id, size_t icon_size)
574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), 602 : CanvasImageSource(
575 false), 603 gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()),
604 false),
576 id_(id), 605 id_(id),
577 icon_size_(icon_size) {} 606 icon_size_(icon_size) {}
578 607
579 ~ProfileBadge() override {} 608 ~ProfileBadge() override {}
580 609
581 // CanvasImageSource: 610 // CanvasImageSource:
582 void Draw(gfx::Canvas* canvas) override { 611 void Draw(gfx::Canvas* canvas) override {
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); 612 const SkISize size = canvas->sk_canvas()->getBaseLayerSize();
584 gfx::Rect bounds(0, 0, size.width(), size.height()); 613 gfx::Rect bounds(0, 0, size.width(), size.height());
585 614
586 SkPaint paint; 615 SkPaint paint;
587 paint.setAntiAlias(true); 616 paint.setAntiAlias(true);
588 paint.setColor(SK_ColorWHITE); 617 paint.setColor(SK_ColorWHITE);
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); 618 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint);
590 619
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); 620 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC));
592 canvas->DrawCircle(bounds.CenterPoint(), 621 canvas->DrawCircle(bounds.CenterPoint(),
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); 622 size.width() / 2 - kProfileBadgeWhitePadding, paint);
594 623
595 int offset = (kProfileBadgeSize - icon_size_) / 2; 624 int offset = (GetProfileBadgeSize() - icon_size_) / 2;
596 canvas->Translate(gfx::Vector2d(offset, offset)); 625 canvas->Translate(gfx::Vector2d(offset, offset));
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); 626 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff));
598 } 627 }
599 628
600 private: 629 private:
601 const gfx::VectorIconId id_; 630 const gfx::VectorIconId id_;
602 const size_t icon_size_; 631 const size_t icon_size_;
603 632
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); 633 DISALLOW_COPY_AND_ASSIGN(ProfileBadge);
605 }; 634 };
606 635
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { 636 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) {
608 ProfileBadge* badge = 637 ProfileBadge* badge =
609 profile->IsChild() 638 profile->IsChild()
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) 639 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT,
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); 640 switches::IsMaterialDesignUserMenu() ? 21 : 26)
612 641 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT,
642 switches::IsMaterialDesignUserMenu() ? 16 : 20);
613 return gfx::ImageSkia(badge, badge->size()); 643 return gfx::ImageSkia(badge, badge->size());
614 } 644 }
615 645
616 // ProfileChooserView --------------------------------------------------------- 646 // ProfileChooserView ---------------------------------------------------------
617 647
618 // static 648 // static
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 649 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 650 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
621 651
622 // static 652 // static
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 bool ProfileChooserView::IsShowing() { 687 bool ProfileChooserView::IsShowing() {
658 return profile_bubble_ != NULL; 688 return profile_bubble_ != NULL;
659 } 689 }
660 690
661 // static 691 // static
662 void ProfileChooserView::Hide() { 692 void ProfileChooserView::Hide() {
663 if (IsShowing()) 693 if (IsShowing())
664 profile_bubble_->GetWidget()->Close(); 694 profile_bubble_->GetWidget()->Close();
665 } 695 }
666 696
697 // static
698 int ProfileChooserView::GetFixedMenuWidth() {
699 return switches::IsMaterialDesignUserMenu() ? 240 : 250;
700 }
701
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 702 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
668 Browser* browser, 703 Browser* browser,
669 profiles::BubbleViewMode view_mode, 704 profiles::BubbleViewMode view_mode,
670 profiles::TutorialMode tutorial_mode, 705 profiles::TutorialMode tutorial_mode,
671 signin::GAIAServiceType service_type, 706 signin::GAIAServiceType service_type,
672 signin_metrics::AccessPoint access_point) 707 signin_metrics::AccessPoint access_point)
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 708 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
674 browser_(browser), 709 browser_(browser),
675 view_mode_(view_mode), 710 view_mode_(view_mode),
676 tutorial_mode_(tutorial_mode), 711 tutorial_mode_(tutorial_mode),
(...skipping 10 matching lines...) Expand all
687 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 722 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
688 if (oauth2_token_service) 723 if (oauth2_token_service)
689 oauth2_token_service->RemoveObserver(this); 724 oauth2_token_service->RemoveObserver(this);
690 } 725 }
691 726
692 void ProfileChooserView::ResetView() { 727 void ProfileChooserView::ResetView() {
693 open_other_profile_indexes_map_.clear(); 728 open_other_profile_indexes_map_.clear();
694 delete_account_button_map_.clear(); 729 delete_account_button_map_.clear();
695 reauth_account_button_map_.clear(); 730 reauth_account_button_map_.clear();
696 manage_accounts_link_ = NULL; 731 manage_accounts_link_ = NULL;
697 signin_current_profile_link_ = NULL; 732 signin_current_profile_button_ = NULL;
698 auth_error_email_button_ = NULL; 733 auth_error_email_button_ = NULL;
699 current_profile_photo_ = NULL; 734 current_profile_photo_ = NULL;
700 current_profile_name_ = NULL; 735 current_profile_name_ = NULL;
701 users_button_ = NULL; 736 users_button_ = NULL;
702 go_incognito_button_ = NULL; 737 go_incognito_button_ = NULL;
703 lock_button_ = NULL; 738 lock_button_ = NULL;
704 add_account_link_ = NULL; 739 add_account_link_ = NULL;
705 gaia_signin_cancel_button_ = NULL; 740 gaia_signin_cancel_button_ = NULL;
706 remove_account_button_ = NULL; 741 remove_account_button_ = NULL;
707 account_removal_cancel_button_ = NULL; 742 account_removal_cancel_button_ = NULL;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 break; 867 break;
833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 868 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 869 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
835 sub_view = CreateSwitchUserView(); 870 sub_view = CreateSwitchUserView();
836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 871 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); 872 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
838 break; 873 break;
839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: 874 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: 875 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: 876 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER:
842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 877 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth());
843 sub_view = CreateProfileChooserView(avatar_menu); 878 sub_view = CreateProfileChooserView(avatar_menu);
844 break; 879 break;
845 } 880 }
846 // Clears tutorial mode for all non-profile-chooser views. 881 // Clears tutorial mode for all non-profile-chooser views.
847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) 882 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 883 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
849 884
850 layout->StartRow(1, 0); 885 layout->StartRow(1, 0);
851 layout->AddView(sub_view); 886 layout->AddView(sub_view);
852 Layout(); 887 Layout();
(...skipping 26 matching lines...) Expand all
879 if (accelerator.key_code() != ui::VKEY_DOWN && 914 if (accelerator.key_code() != ui::VKEY_DOWN &&
880 accelerator.key_code() != ui::VKEY_UP) 915 accelerator.key_code() != ui::VKEY_UP)
881 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); 916 return BubbleDialogDelegateView::AcceleratorPressed(accelerator);
882 917
883 // Move the focus up or down. 918 // Move the focus up or down.
884 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); 919 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN);
885 return true; 920 return true;
886 } 921 }
887 922
888 views::View* ProfileChooserView::GetInitiallyFocusedView() { 923 views::View* ProfileChooserView::GetInitiallyFocusedView() {
889 return signin_current_profile_link_; 924 return signin_current_profile_button_;
890 } 925 }
891 926
892 int ProfileChooserView::GetDialogButtons() const { 927 int ProfileChooserView::GetDialogButtons() const {
893 return ui::DIALOG_BUTTON_NONE; 928 return ui::DIALOG_BUTTON_NONE;
894 } 929 }
895 930
896 bool ProfileChooserView::HandleContextMenu( 931 bool ProfileChooserView::HandleContextMenu(
897 const content::ContextMenuParams& params) { 932 const content::ContextMenuParams& params) {
898 // Suppresses the context menu because some features, such as inspecting 933 // Suppresses the context menu because some features, such as inspecting
899 // elements, are not appropriate in a bubble. 934 // elements, are not appropriate in a bubble.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 bool account_management_available = 983 bool account_management_available =
949 SigninManagerFactory::GetForProfile(browser_->profile())-> 984 SigninManagerFactory::GetForProfile(browser_->profile())->
950 IsAuthenticated() && 985 IsAuthenticated() &&
951 switches::IsEnableAccountConsistency(); 986 switches::IsEnableAccountConsistency();
952 ShowViewFromMode(account_management_available ? 987 ShowViewFromMode(account_management_available ?
953 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 988 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
954 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); 989 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
955 } else if (sender == current_profile_photo_) { 990 } else if (sender == current_profile_photo_) {
956 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 991 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
957 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); 992 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE);
958 } else if (sender == signin_current_profile_link_) { 993 } else if (sender == signin_current_profile_button_) {
959 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); 994 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
960 } else if (sender == add_person_button_) { 995 } else if (sender == add_person_button_) {
961 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 996 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
962 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 997 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
963 UserManager::Show(base::FilePath(), 998 UserManager::Show(base::FilePath(),
964 profiles::USER_MANAGER_NO_TUTORIAL, 999 profiles::USER_MANAGER_NO_TUTORIAL,
965 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 1000 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
966 } else if (sender == disconnect_button_) { 1001 } else if (sender == disconnect_button_) {
967 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 1002 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
968 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); 1003 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 Indexes other_profiles; 1117 Indexes other_profiles;
1083 views::View* tutorial_view = NULL; 1118 views::View* tutorial_view = NULL;
1084 views::View* current_profile_view = NULL; 1119 views::View* current_profile_view = NULL;
1085 views::View* current_profile_accounts = NULL; 1120 views::View* current_profile_accounts = NULL;
1086 views::View* option_buttons_view = NULL; 1121 views::View* option_buttons_view = NULL;
1087 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1122 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1088 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1123 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1089 if (item.active) { 1124 if (item.active) {
1090 option_buttons_view = CreateOptionsView( 1125 option_buttons_view = CreateOptionsView(
1091 item.signed_in && profiles::IsLockAvailable(browser_->profile())); 1126 item.signed_in && profiles::IsLockAvailable(browser_->profile()));
1092 current_profile_view = CreateCurrentProfileView(item, false); 1127 current_profile_view =
1128 switches::IsMaterialDesignUserMenu()
1129 ? CreateMaterialDesignCurrentProfileView(item, false)
1130 : CreateCurrentProfileView(item, false);
1093 if (IsProfileChooser(view_mode_)) { 1131 if (IsProfileChooser(view_mode_)) {
1094 tutorial_view = CreateTutorialViewIfNeeded(item); 1132 tutorial_view = CreateTutorialViewIfNeeded(item);
1095 } else { 1133 } else {
1096 current_profile_accounts = CreateCurrentProfileAccountsView(item); 1134 current_profile_accounts = CreateCurrentProfileAccountsView(item);
1097 } 1135 }
1098 } else { 1136 } else {
1099 other_profiles.push_back(i); 1137 other_profiles.push_back(i);
1100 } 1138 }
1101 } 1139 }
1102 1140
(...skipping 16 matching lines...) Expand all
1119 1157
1120 if (!IsProfileChooser(view_mode_)) { 1158 if (!IsProfileChooser(view_mode_)) {
1121 DCHECK(current_profile_accounts); 1159 DCHECK(current_profile_accounts);
1122 layout->StartRow(0, 0); 1160 layout->StartRow(0, 0);
1123 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1161 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1124 layout->StartRow(1, 0); 1162 layout->StartRow(1, 0);
1125 layout->AddView(current_profile_accounts); 1163 layout->AddView(current_profile_accounts);
1126 } 1164 }
1127 1165
1128 if (browser_->profile()->IsSupervised()) { 1166 if (browser_->profile()->IsSupervised()) {
1129 layout->StartRow(0, 0); 1167 if (!switches::IsMaterialDesignUserMenu()) {
1130 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1168 layout->StartRow(0, 0);
1169 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1170 }
1131 layout->StartRow(1, 0); 1171 layout->StartRow(1, 0);
1132 layout->AddView(CreateSupervisedUserDisclaimerView()); 1172 layout->AddView(CreateSupervisedUserDisclaimerView());
1133 } 1173 }
1134 1174
1135 layout->StartRow(0, 0); 1175 layout->StartRow(0, 0);
1136 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1176 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1137 1177
1138 if (option_buttons_view) { 1178 if (option_buttons_view) {
1139 layout->StartRow(0, 0); 1179 layout->StartRow(0, 0);
1140 layout->AddView(option_buttons_view); 1180 layout->AddView(option_buttons_view);
(...skipping 11 matching lines...) Expand all
1152 } 1192 }
1153 } 1193 }
1154 1194
1155 layout->StartRow(1, 0); 1195 layout->StartRow(1, 0);
1156 layout->AddView(CreateOtherProfilesView(other_profiles)); 1196 layout->AddView(CreateOtherProfilesView(other_profiles));
1157 } 1197 }
1158 1198
1159 views::View* ProfileChooserView::CreateProfileChooserView( 1199 views::View* ProfileChooserView::CreateProfileChooserView(
1160 AvatarMenu* avatar_menu) { 1200 AvatarMenu* avatar_menu) {
1161 views::View* view = new views::View(); 1201 views::View* view = new views::View();
1162 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1202 views::GridLayout* layout =
1203 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1163 1204
1164 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { 1205 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
1165 PopulateMinimalProfileChooserView(layout, avatar_menu); 1206 PopulateMinimalProfileChooserView(layout, avatar_menu);
1166 // The user is using right-click switching, no need to tell them about it. 1207 // The user is using right-click switching, no need to tell them about it.
1167 PrefService* local_state = g_browser_process->local_state(); 1208 PrefService* local_state = g_browser_process->local_state();
1168 local_state->SetBoolean( 1209 local_state->SetBoolean(
1169 prefs::kProfileAvatarRightClickTutorialDismissed, true); 1210 prefs::kProfileAvatarRightClickTutorialDismissed, true);
1170 } else { 1211 } else {
1171 PopulateCompleteProfileChooserView(layout, avatar_menu); 1212 PopulateCompleteProfileChooserView(layout, avatar_menu);
1172 } 1213 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 const base::string16& button_text, 1268 const base::string16& button_text,
1228 bool stack_button, 1269 bool stack_button,
1229 views::Link** link, 1270 views::Link** link,
1230 views::LabelButton** button, 1271 views::LabelButton** button,
1231 views::ImageButton** close_button) { 1272 views::ImageButton** close_button) {
1232 tutorial_mode_ = tutorial_mode; 1273 tutorial_mode_ = tutorial_mode;
1233 1274
1234 views::View* view = new views::View(); 1275 views::View* view = new views::View();
1235 view->set_background(views::Background::CreateSolidBackground( 1276 view->set_background(views::Background::CreateSolidBackground(
1236 profiles::kAvatarTutorialBackgroundColor)); 1277 profiles::kAvatarTutorialBackgroundColor));
1237 views::GridLayout* layout = CreateSingleColumnLayout(view, 1278 views::GridLayout* layout = CreateSingleColumnLayout(
1238 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1279 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1239 // Creates a second column set for buttons and links. 1280 // Creates a second column set for buttons and links.
1240 views::ColumnSet* button_columns = layout->AddColumnSet(1); 1281 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1241 button_columns->AddColumn(views::GridLayout::LEADING, 1282 button_columns->AddColumn(views::GridLayout::LEADING,
1242 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1283 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1243 button_columns->AddPaddingColumn( 1284 button_columns->AddPaddingColumn(
1244 1, views::kUnrelatedControlHorizontalSpacing); 1285 1, views::kUnrelatedControlHorizontalSpacing);
1245 button_columns->AddColumn(views::GridLayout::TRAILING, 1286 button_columns->AddColumn(views::GridLayout::TRAILING,
1246 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1287 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1247 layout->SetInsets(views::kButtonVEdgeMarginNew, 1288 layout->SetInsets(views::kButtonVEdgeMarginNew,
1248 views::kButtonHEdgeMarginNew, 1289 views::kButtonHEdgeMarginNew,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 layout->SkipColumns(1); 1371 layout->SkipColumns(1);
1331 } 1372 }
1332 1373
1333 return view; 1374 return view;
1334 } 1375 }
1335 1376
1336 views::View* ProfileChooserView::CreateCurrentProfileView( 1377 views::View* ProfileChooserView::CreateCurrentProfileView(
1337 const AvatarMenu::Item& avatar_item, 1378 const AvatarMenu::Item& avatar_item,
1338 bool is_guest) { 1379 bool is_guest) {
1339 views::View* view = new views::View(); 1380 views::View* view = new views::View();
1340 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; 1381 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew;
1341 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); 1382 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width);
1342 layout->SetInsets(views::kButtonVEdgeMarginNew, 1383 layout->SetInsets(views::kButtonVEdgeMarginNew,
1343 views::kButtonHEdgeMarginNew, 1384 views::kButtonHEdgeMarginNew,
1344 views::kUnrelatedControlVerticalSpacing, 1385 views::kUnrelatedControlVerticalSpacing,
1345 views::kButtonHEdgeMarginNew); 1386 views::kButtonHEdgeMarginNew);
1346 1387
1347 // Profile icon, centered. 1388 // Profile icon, centered.
1348 int x_offset = (column_width - kLargeImageSide) / 2; 1389 int x_offset = (column_width - kLargeImageSide) / 2;
1349 current_profile_photo_ = new EditableProfilePhoto( 1390 current_profile_photo_ = new EditableProfilePhoto(
1350 this, avatar_item.icon, !is_guest, 1391 this, avatar_item.icon, !is_guest,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 if (signin_manager->IsSigninAllowed()) { 1469 if (signin_manager->IsSigninAllowed()) {
1429 views::Label* promo = new views::Label( 1470 views::Label* promo = new views::Label(
1430 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); 1471 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1431 promo->SetMultiLine(true); 1472 promo->SetMultiLine(true);
1432 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1473 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1433 layout->StartRowWithPadding(1, 0, 0, 1474 layout->StartRowWithPadding(1, 0, 0,
1434 views::kRelatedControlSmallVerticalSpacing); 1475 views::kRelatedControlSmallVerticalSpacing);
1435 layout->StartRow(1, 0); 1476 layout->StartRow(1, 0);
1436 layout->AddView(promo); 1477 layout->AddView(promo);
1437 1478
1438 signin_current_profile_link_ = new views::BlueButton( 1479 signin_current_profile_button_ = new views::BlueButton(
1439 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, 1480 this, l10n_util::GetStringFUTF16(
1440 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 1481 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1482 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1441 layout->StartRowWithPadding(1, 0, 0, 1483 layout->StartRowWithPadding(1, 0, 0,
1442 views::kRelatedControlVerticalSpacing); 1484 views::kRelatedControlVerticalSpacing);
1443 layout->StartRow(1, 0); 1485 layout->StartRow(1, 0);
1444 layout->AddView(signin_current_profile_link_); 1486 layout->AddView(signin_current_profile_button_);
1445 content::RecordAction( 1487 content::RecordAction(
1446 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); 1488 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1447 } 1489 }
1448 } 1490 }
1449 1491
1450 return view; 1492 return view;
1451 } 1493 }
1452 1494
1495 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
1496 const AvatarMenu::Item& avatar_item,
1497 bool is_guest) {
1498 views::View* view = new views::View();
1499 int column_width =
1500 GetFixedMenuWidth() - 2 * kMaterialMenuHorizontalEdgeMargin;
1501 view->SetLayoutManager(new views::BoxLayout(
1502 views::BoxLayout::kVertical, kMaterialMenuHorizontalEdgeMargin,
1503 views::kRelatedControlVerticalSpacing,
1504 views::kRelatedControlVerticalSpacing));
1505
1506 // Profile container for the profile photo and avatar/user name.
1507 const int profile_bar_height = 56;
1508 const int badge_spacing = 4;
1509 bool editing_allowed =
1510 !is_guest && !browser_->profile()->IsLegacySupervised();
1511 SizedContainer* profile_container =
1512 new SizedContainer(gfx::Size(column_width, profile_bar_height));
Evan Stade 2016/06/16 21:56:34 I don't really like SizedContainer (and you use it
Jane 2016/06/17 19:52:23 I modified profile_name_container and profile_cont
1513
1514 // Profile picture, left-aligned.
1515 current_profile_photo_ = new EditableProfilePhoto(
1516 this, avatar_item.icon, !is_guest,
1517 gfx::Rect(0, views::kRelatedControlSmallVerticalSpacing, kMediumImageSide,
1518 kMediumImageSide));
1519 gfx::Rect photo_bounds = current_profile_photo_->bounds();
1520 SizedContainer* profile_photo_container = new SizedContainer(gfx::Size(
1521 kMediumImageSide + badge_spacing,
1522 profile_bar_height - 2 * views::kRelatedControlSmallVerticalSpacing));
1523 profile_photo_container->AddChildView(current_profile_photo_);
1524
1525 // Add supervised badge for supervised profile.
1526 if (browser_->profile()->IsSupervised()) {
1527 views::ImageView* supervised_icon = new views::ImageView();
1528 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile()));
1529 gfx::Size preferred_size = supervised_icon->GetPreferredSize();
1530 supervised_icon->SetBounds(
1531 photo_bounds.right() - preferred_size.width() + badge_spacing,
1532 photo_bounds.bottom() - preferred_size.height() + badge_spacing,
1533 preferred_size.width(), preferred_size.height());
1534 profile_photo_container->AddChildView(supervised_icon);
1535 }
1536
1537 // Profile name, left-aligned to the right of profile icon.
1538 current_profile_name_ = new EditableProfileName(
1539 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()),
1540 editing_allowed);
1541 const int between_child_spacing =
1542 kMaterialMenuHorizontalEdgeMargin - badge_spacing -
1543 (editing_allowed
1544 ? current_profile_name_->profile_name_textfield()->GetInsets().left()
1545 : 0);
1546 SizedContainer* profile_name_container = new SizedContainer(gfx::Size(
1547 profile_container->GetPreferredSize().width() - photo_bounds.width() -
1548 between_child_spacing,
1549 profile_bar_height - 2 * views::kRelatedControlSmallVerticalSpacing));
1550 int name_container_v_spacing = views::kRelatedControlVerticalSpacing;
1551 if (!avatar_item.signed_in) {
1552 name_container_v_spacing += views::kRelatedControlSmallVerticalSpacing +
1553 EditableProfileName::border_width;
1554 }
1555 profile_name_container->SetLayoutManager(new views::BoxLayout(
1556 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0));
1557 profile_name_container->AddChildView(current_profile_name_);
1558
1559 profile_container->SetLayoutManager(new views::BoxLayout(
1560 views::BoxLayout::kHorizontal, 0,
1561 views::kRelatedControlSmallVerticalSpacing, between_child_spacing));
1562 profile_container->AddChildView(profile_photo_container);
1563 profile_container->AddChildView(profile_name_container);
1564 view->AddChildView(profile_container);
1565
1566 if (is_guest)
1567 return view;
1568
1569 // The available links depend on the type of profile that is active.
1570 if (avatar_item.signed_in) {
1571 if (switches::IsEnableAccountConsistency()) {
1572 base::string16 link_title = l10n_util::GetStringUTF16(
1573 IsProfileChooser(view_mode_)
1574 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON
1575 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
1576 manage_accounts_link_ = CreateLink(link_title, this);
1577 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1578 profile_name_container->AddChildView(manage_accounts_link_);
1579 } else {
1580 views::Label* email_label = new views::Label(avatar_item.username);
1581 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1582 email_label->SetEnabled(false);
1583 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1584 profile_name_container->AddChildView(email_label);
1585 }
1586 return view;
1587 }
1588
1589 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
1590 browser_->profile()->GetOriginalProfile());
1591 if (signin_manager->IsSigninAllowed()) {
1592 views::Label* promo =
1593 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1594 promo->SetMultiLine(true);
1595 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1596 view->AddChildView(promo);
1597
1598 signin_current_profile_button_ =
1599 views::MdTextButton::CreateSecondaryUiBlueButton(
1600 this, l10n_util::GetStringFUTF16(
1601 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1602 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1603 signin_current_profile_button_->SetMinSize(gfx::Size(0, 36));
1604 view->AddChildView(signin_current_profile_button_);
1605 content::RecordAction(
1606 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1607 view->SetBorder(views::Border::CreateEmptyBorder(
1608 0, 0, views::kRelatedControlVerticalSpacing, 0));
1609 }
1610
1611 return view;
1612 }
1613
1453 views::View* ProfileChooserView::CreateGuestProfileView() { 1614 views::View* ProfileChooserView::CreateGuestProfileView() {
1454 gfx::Image guest_icon = 1615 gfx::Image guest_icon =
1455 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 1616 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
1456 profiles::GetPlaceholderAvatarIconResourceID()); 1617 profiles::GetPlaceholderAvatarIconResourceID());
1457 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); 1618 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon);
1458 guest_avatar_item.active = true; 1619 guest_avatar_item.active = true;
1459 guest_avatar_item.name = l10n_util::GetStringUTF16( 1620 guest_avatar_item.name = l10n_util::GetStringUTF16(
1460 IDS_PROFILES_GUEST_PROFILE_NAME); 1621 IDS_PROFILES_GUEST_PROFILE_NAME);
1461 guest_avatar_item.signed_in = false; 1622 guest_avatar_item.signed_in = false;
1462 1623
1463 return CreateCurrentProfileView(guest_avatar_item, true); 1624 return switches::IsMaterialDesignUserMenu()
1625 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true)
1626 : CreateCurrentProfileView(guest_avatar_item, true);
1464 } 1627 }
1465 1628
1466 views::View* ProfileChooserView::CreateOtherProfilesView( 1629 views::View* ProfileChooserView::CreateOtherProfilesView(
1467 const Indexes& avatars_to_show) { 1630 const Indexes& avatars_to_show) {
1468 views::View* view = new views::View(); 1631 views::View* view = new views::View();
1469 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1632 views::GridLayout* layout =
1633 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1470 1634
1471 for (size_t index : avatars_to_show) { 1635 for (size_t index : avatars_to_show) {
1472 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); 1636 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index);
1473 const int kSmallImageSide = 32; 1637 const int kSmallImageSide = 32;
1474 1638
1475 // Use the low-res, small default avatars in the fast user switcher, like 1639 // Use the low-res, small default avatars in the fast user switcher, like
1476 // we do in the menu bar. 1640 // we do in the menu bar.
1477 gfx::Image item_icon; 1641 gfx::Image item_icon;
1478 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); 1642 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon);
1479 1643
(...skipping 10 matching lines...) Expand all
1490 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1654 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1491 layout->StartRow(1, 0); 1655 layout->StartRow(1, 0);
1492 layout->AddView(button); 1656 layout->AddView(button);
1493 } 1657 }
1494 1658
1495 return view; 1659 return view;
1496 } 1660 }
1497 1661
1498 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { 1662 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
1499 views::View* view = new views::View(); 1663 views::View* view = new views::View();
1500 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1664 views::GridLayout* layout =
1665 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1501 1666
1502 base::string16 text = browser_->profile()->IsGuestSession() ? 1667 base::string16 text = browser_->profile()->IsGuestSession() ?
1503 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : 1668 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
1504 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); 1669 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
1505 if (!browser_->profile()->IsGuestSession() 1670 if (!browser_->profile()->IsGuestSession()
1506 && switches::IsMaterialDesignUserMenu()) { 1671 && switches::IsMaterialDesignUserMenu()) {
1507 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); 1672 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
1508 } 1673 }
1509 const int kIconSize = 16; 1674 const int kIconSize = 16;
1510 1675
(...skipping 29 matching lines...) Expand all
1540 gfx::kChromeIconGrey)); 1705 gfx::kChromeIconGrey));
1541 layout->StartRow(1, 0); 1706 layout->StartRow(1, 0);
1542 layout->AddView(lock_button_); 1707 layout->AddView(lock_button_);
1543 } 1708 }
1544 return view; 1709 return view;
1545 } 1710 }
1546 1711
1547 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { 1712 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
1548 views::View* view = new views::View(); 1713 views::View* view = new views::View();
1549 views::GridLayout* layout = CreateSingleColumnLayout( 1714 views::GridLayout* layout = CreateSingleColumnLayout(
1550 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1715 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1551 layout->SetInsets(views::kRelatedControlVerticalSpacing, 1716 if (switches::IsMaterialDesignUserMenu()) {
1552 views::kButtonHEdgeMarginNew, 1717 layout->SetInsets(0, kMaterialMenuHorizontalEdgeMargin,
1553 views::kRelatedControlVerticalSpacing, 1718 kMaterialMenuVerticalEdgeMargin,
1554 views::kButtonHEdgeMarginNew); 1719 kMaterialMenuHorizontalEdgeMargin);
1720 } else {
1721 layout->SetInsets(
1722 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew,
1723 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew);
1724 }
1725
1555 views::Label* disclaimer = new views::Label( 1726 views::Label* disclaimer = new views::Label(
1556 avatar_menu_->GetSupervisedUserInformation()); 1727 avatar_menu_->GetSupervisedUserInformation());
1557 disclaimer->SetMultiLine(true); 1728 disclaimer->SetMultiLine(true);
1558 disclaimer->SetAllowCharacterBreak(true); 1729 disclaimer->SetAllowCharacterBreak(true);
1559 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1730 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1560 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1731 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1561 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); 1732 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont));
1562 layout->StartRow(1, 0); 1733 layout->StartRow(1, 0);
1563 layout->AddView(disclaimer); 1734 layout->AddView(disclaimer);
1564 1735
1565 return view; 1736 return view;
1566 } 1737 }
1567 1738
1568 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( 1739 views::View* ProfileChooserView::CreateCurrentProfileAccountsView(
1569 const AvatarMenu::Item& avatar_item) { 1740 const AvatarMenu::Item& avatar_item) {
1570 DCHECK(avatar_item.signed_in); 1741 DCHECK(avatar_item.signed_in);
1571 views::View* view = new views::View(); 1742 views::View* view = new views::View();
1572 view->set_background(views::Background::CreateSolidBackground( 1743 view->set_background(views::Background::CreateSolidBackground(
1573 profiles::kAvatarBubbleAccountsBackgroundColor)); 1744 profiles::kAvatarBubbleAccountsBackgroundColor));
1574 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1745 views::GridLayout* layout =
1746 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1575 1747
1576 Profile* profile = browser_->profile(); 1748 Profile* profile = browser_->profile();
1577 std::string primary_account = 1749 std::string primary_account =
1578 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); 1750 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId();
1579 DCHECK(!primary_account.empty()); 1751 DCHECK(!primary_account.empty());
1580 std::vector<std::string>accounts = 1752 std::vector<std::string>accounts =
1581 profiles::GetSecondaryAccountsForProfile(profile, primary_account); 1753 profiles::GetSecondaryAccountsForProfile(profile, primary_account);
1582 1754
1583 // Get state of authentication error, if any. 1755 // Get state of authentication error, if any.
1584 std::string error_account_id = GetAuthErrorAccountId(profile); 1756 std::string error_account_id = GetAuthErrorAccountId(profile);
1585 1757
1586 // The primary account should always be listed first. 1758 // The primary account should always be listed first.
1587 // TODO(rogerta): we still need to further differentiate the primary account 1759 // TODO(rogerta): we still need to further differentiate the primary account
1588 // from the others in the UI, so more work is likely required here: 1760 // from the others in the UI, so more work is likely required here:
1589 // crbug.com/311124. 1761 // crbug.com/311124.
1590 CreateAccountButton(layout, primary_account, true, 1762 CreateAccountButton(layout, primary_account, true,
1591 error_account_id == primary_account, kFixedMenuWidth); 1763 error_account_id == primary_account, GetFixedMenuWidth());
1592 for (size_t i = 0; i < accounts.size(); ++i) 1764 for (size_t i = 0; i < accounts.size(); ++i)
1593 CreateAccountButton(layout, accounts[i], false, 1765 CreateAccountButton(layout, accounts[i], false,
1594 error_account_id == accounts[i], kFixedMenuWidth); 1766 error_account_id == accounts[i], GetFixedMenuWidth());
1595 1767
1596 if (!profile->IsSupervised()) { 1768 if (!profile->IsSupervised()) {
1597 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1769 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1598 1770
1599 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( 1771 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16(
1600 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); 1772 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this);
1601 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( 1773 add_account_link_->SetBorder(views::Border::CreateEmptyBorder(
1602 0, views::kButtonVEdgeMarginNew, 1774 0, views::kButtonVEdgeMarginNew,
1603 views::kRelatedControlVerticalSpacing, 0)); 1775 views::kRelatedControlVerticalSpacing, 0));
1604 layout->StartRow(1, 0); 1776 layout->StartRow(1, 0);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2066 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1895 IncognitoModePrefs::DISABLED; 2067 IncognitoModePrefs::DISABLED;
1896 return incognito_available && !browser_->profile()->IsGuestSession(); 2068 return incognito_available && !browser_->profile()->IsGuestSession();
1897 } 2069 }
1898 2070
1899 void ProfileChooserView::PostActionPerformed( 2071 void ProfileChooserView::PostActionPerformed(
1900 ProfileMetrics::ProfileDesktopMenu action_performed) { 2072 ProfileMetrics::ProfileDesktopMenu action_performed) {
1901 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2073 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1902 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2074 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1903 } 2075 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698