OLD | NEW |
---|---|
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 Loading... | |
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 | 93 |
94 const int kTextfieldLabelHorizontalSpacing = 4; | |
95 const int kProfileHorizontalSpacing = 16; | |
94 const int kVerticalSpacing = 16; | 96 const int kVerticalSpacing = 16; |
95 | 97 |
96 const int kTitleViewNativeWidgetOffset = 8; | 98 const int kTitleViewNativeWidgetOffset = 8; |
97 | 99 |
98 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 100 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 101 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 102 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
101 } | 103 } |
102 | 104 |
103 // Creates a GridLayout with a single column. This ensures that all the child | 105 // Creates a GridLayout with a single column. This ensures that all the child |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 gfx::Rect bounds(title_view_->GetPreferredSize()); | 258 gfx::Rect bounds(title_view_->GetPreferredSize()); |
257 title_view_->SetBoundsRect(bounds); | 259 title_view_->SetBoundsRect(bounds); |
258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 260 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
259 title_widget_->SetBounds(bounds); | 261 title_widget_->SetBounds(bounds); |
260 } | 262 } |
261 | 263 |
262 } // namespace | 264 } // namespace |
263 | 265 |
264 // RightAlignedIconLabelButton ------------------------------------------------- | 266 // RightAlignedIconLabelButton ------------------------------------------------- |
265 | 267 |
266 // A custom LabelButton that has a centered text and right aligned icon. | 268 // A custom LabelButton that has a left-aligned text and right aligned icon. |
269 // For non-material-design user menu, it has centered text instead. | |
267 class RightAlignedIconLabelButton : public views::LabelButton { | 270 class RightAlignedIconLabelButton : public views::LabelButton { |
268 public: | 271 public: |
269 RightAlignedIconLabelButton(views::ButtonListener* listener, | 272 RightAlignedIconLabelButton(views::ButtonListener* listener, |
270 const base::string16& text) | 273 const base::string16& text) |
271 : views::LabelButton(listener, text) { | 274 : views::LabelButton(listener, text) { |
272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 275 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 276 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
277 ? gfx::ALIGN_LEFT : gfx::ALIGN_CENTER); | |
274 } | 278 } |
275 | 279 |
276 protected: | 280 protected: |
277 void Layout() override { | 281 void Layout() override { |
278 views::LabelButton::Layout(); | 282 views::LabelButton::Layout(); |
279 | 283 |
280 // Keep the text centered and the icon right-aligned by stretching the label | 284 // 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. | 285 // to take up more of the content area and centering its contents. |
282 gfx::Rect content_bounds = GetContentsBounds(); | 286 gfx::Rect content_bounds = GetContentsBounds(); |
283 gfx::Rect label_bounds = label()->bounds(); | 287 gfx::Rect label_bounds = label()->bounds(); |
(...skipping 17 matching lines...) Expand all Loading... | |
301 | 305 |
302 // A custom Image control that shows a "change" button when moused over. | 306 // A custom Image control that shows a "change" button when moused over. |
303 class EditableProfilePhoto : public views::LabelButton { | 307 class EditableProfilePhoto : public views::LabelButton { |
304 public: | 308 public: |
305 EditableProfilePhoto(views::ButtonListener* listener, | 309 EditableProfilePhoto(views::ButtonListener* listener, |
306 const gfx::Image& icon, | 310 const gfx::Image& icon, |
307 bool is_editing_allowed, | 311 bool is_editing_allowed, |
308 const gfx::Rect& bounds) | 312 const gfx::Rect& bounds) |
309 : views::LabelButton(listener, base::string16()), | 313 : views::LabelButton(listener, base::string16()), |
310 photo_overlay_(NULL) { | 314 photo_overlay_(NULL) { |
315 const int kIconImageSide = switches::IsMaterialDesignUserMenu() | |
sky
2016/06/07 17:50:29
Don't use kFoo style for things that aren't compil
Jane
2016/06/07 18:37:37
Done. Seems like a couple of the existing non-comp
| |
316 ? kMediumImageSide : kLargeImageSide; | |
311 gfx::Image image = profiles::GetSizedAvatarIcon( | 317 gfx::Image image = profiles::GetSizedAvatarIcon( |
312 icon, true, kLargeImageSide, kLargeImageSide); | 318 icon, true, kIconImageSide, kIconImageSide); |
313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 319 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
314 SetBorder(views::Border::NullBorder()); | 320 SetBorder(views::Border::NullBorder()); |
315 SetBoundsRect(bounds); | 321 SetBoundsRect(bounds); |
316 | 322 |
317 // Calculate the circular mask that will be used to display the photo. | 323 // Calculate the circular mask that will be used to display the photo. |
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 324 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), |
319 SkIntToScalar(bounds.height() / 2), | 325 SkIntToScalar(bounds.height() / 2), |
320 SkIntToScalar(bounds.width() / 2)); | 326 SkIntToScalar(bounds.width() / 2)); |
321 | 327 |
322 if (!is_editing_allowed) { | 328 if (!is_editing_allowed) { |
323 SetEnabled(false); | 329 SetEnabled(false); |
324 return; | 330 return; |
325 } | 331 } |
326 | 332 |
327 set_notify_enter_exit_on_child(true); | 333 set_notify_enter_exit_on_child(true); |
328 | 334 |
329 // Photo overlay that appears when hovering over the button. | 335 // Photo overlay that appears when hovering over the button. |
330 photo_overlay_ = new views::ImageView(); | 336 photo_overlay_ = new views::ImageView(); |
331 | 337 |
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 338 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
333 photo_overlay_->set_background( | 339 photo_overlay_->set_background( |
334 views::Background::CreateSolidBackground(kBackgroundColor)); | 340 views::Background::CreateSolidBackground(kBackgroundColor)); |
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 341 photo_overlay_->SetImage(gfx::CreateVectorIcon( |
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 342 gfx::VectorIconId::PHOTO_CAMERA, |
343 switches::IsMaterialDesignUserMenu() ? 22u : 48u, | |
344 SkColorSetRGB(0x33, 0x33, 0x33))); | |
337 | 345 |
338 photo_overlay_->SetSize(bounds.size()); | 346 photo_overlay_->SetSize(bounds.size()); |
339 photo_overlay_->SetVisible(false); | 347 photo_overlay_->SetVisible(false); |
340 AddChildView(photo_overlay_); | 348 AddChildView(photo_overlay_); |
341 } | 349 } |
342 | 350 |
343 void OnPaint(gfx::Canvas* canvas) override { | 351 void OnPaint(gfx::Canvas* canvas) override { |
344 // Display the profile picture as a circle. | 352 // Display the profile picture as a circle. |
345 canvas->ClipPath(circular_mask_, true); | 353 canvas->ClipPath(circular_mask_, true); |
346 views::LabelButton::OnPaint(canvas); | 354 views::LabelButton::OnPaint(canvas); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 406 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
399 | 407 |
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 408 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
401 const gfx::FontList& medium_font_list = | 409 const gfx::FontList& medium_font_list = |
402 rb->GetFontList(ui::ResourceBundle::MediumFont); | 410 rb->GetFontList(ui::ResourceBundle::MediumFont); |
403 | 411 |
404 if (!is_editing_allowed) { | 412 if (!is_editing_allowed) { |
405 label_ = new views::Label(text); | 413 label_ = new views::Label(text); |
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 414 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); |
407 label_->SetFontList(medium_font_list); | 415 label_->SetFontList(medium_font_list); |
416 if (switches::IsMaterialDesignUserMenu()) { | |
sky
2016/06/07 17:50:29
nit: no {}
Jane
2016/06/07 18:37:36
Done.
| |
417 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
418 } | |
408 AddChildView(label_); | 419 AddChildView(label_); |
409 return; | 420 return; |
410 } | 421 } |
411 | 422 |
412 button_ = new RightAlignedIconLabelButton(this, text); | 423 button_ = new RightAlignedIconLabelButton(this, text); |
413 button_->SetFontList(medium_font_list); | 424 button_->SetFontList(medium_font_list); |
414 // Show an "edit" pencil icon when hovering over. In the default state, | 425 // 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 | 426 // 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. | 427 // the text doesn't jump around when the hovered icon appears. |
417 // TODO(estade): revisit colors and press effect. | 428 // TODO(estade): revisit colors and press effect. |
418 const int kIconSize = 16; | 429 const int kIconSize = 16; |
419 button_->SetImage(views::LabelButton::STATE_NORMAL, | 430 button_->SetImage(views::LabelButton::STATE_NORMAL, |
420 CreateSquarePlaceholderImage(kIconSize)); | 431 CreateSquarePlaceholderImage(kIconSize)); |
421 button_->SetImage(views::LabelButton::STATE_HOVERED, | 432 button_->SetImage(views::LabelButton::STATE_HOVERED, |
422 gfx::CreateVectorIcon( | 433 gfx::CreateVectorIcon( |
423 gfx::VectorIconId::MODE_EDIT, kIconSize, | 434 gfx::VectorIconId::MODE_EDIT, kIconSize, |
424 SkColorSetRGB(0x33, 0x33, 0x33))); | 435 SkColorSetRGB(0x33, 0x33, 0x33))); |
425 button_->SetImage(views::LabelButton::STATE_PRESSED, | 436 button_->SetImage(views::LabelButton::STATE_PRESSED, |
426 gfx::CreateVectorIcon( | 437 gfx::CreateVectorIcon( |
427 gfx::VectorIconId::MODE_EDIT, kIconSize, | 438 gfx::VectorIconId::MODE_EDIT, kIconSize, |
428 SkColorSetRGB(0x20, 0x20, 0x20))); | 439 SkColorSetRGB(0x20, 0x20, 0x20))); |
429 // To center the text, we need to offest it by the width of the icon we | 440 // 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 | 441 // to the text to account for the textfield's border. |
431 // padding to account for the textfield's border. | 442 if (switches::IsMaterialDesignUserMenu()) { |
432 const int kIconTextLabelButtonSpacing = 5; | 443 button_->SetBorder(views::Border::CreateEmptyBorder( |
433 button_->SetBorder(views::Border::CreateEmptyBorder( | 444 2, kTextfieldLabelHorizontalSpacing, 2, 0)); |
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 445 } else { |
446 const int kIconTextLabelButtonSpacing = 5; | |
447 button_->SetBorder(views::Border::CreateEmptyBorder( | |
448 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | |
449 } | |
435 AddChildView(button_); | 450 AddChildView(button_); |
436 | 451 |
437 profile_name_textfield_ = new views::Textfield(); | 452 profile_name_textfield_ = new views::Textfield(); |
438 // Textfield that overlaps the button. | 453 // Textfield that overlaps the button. |
439 profile_name_textfield_->set_controller(controller); | 454 profile_name_textfield_->set_controller(controller); |
440 profile_name_textfield_->SetFontList(medium_font_list); | 455 profile_name_textfield_->SetFontList(medium_font_list); |
441 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 456 profile_name_textfield_->SetHorizontalAlignment( |
457 switches::IsMaterialDesignUserMenu() | |
458 ? gfx::ALIGN_LEFT : gfx::ALIGN_CENTER); | |
442 profile_name_textfield_->SetVisible(false); | 459 profile_name_textfield_->SetVisible(false); |
443 AddChildView(profile_name_textfield_); | 460 AddChildView(profile_name_textfield_); |
444 } | 461 } |
445 | 462 |
446 views::Textfield* profile_name_textfield() { | 463 views::Textfield* profile_name_textfield() { |
447 return profile_name_textfield_; | 464 return profile_name_textfield_; |
448 } | 465 } |
449 | 466 |
450 // Hide the editable textfield to show the profile name button instead. | 467 // Hide the editable textfield to show the profile name button instead. |
451 void ShowReadOnlyView() { | 468 void ShowReadOnlyView() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 | 575 |
559 views::ImageButton* back_button_; | 576 views::ImageButton* back_button_; |
560 views::Label* title_label_; | 577 views::Label* title_label_; |
561 | 578 |
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 579 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
563 }; | 580 }; |
564 | 581 |
565 // ProfileBadge -------------------------------------------------------- | 582 // ProfileBadge -------------------------------------------------------- |
566 | 583 |
567 const size_t kProfileBadgeSize = 30; | 584 const size_t kProfileBadgeSize = 30; |
585 const size_t kSmallProfileBadgeSize = 24; | |
568 const size_t kProfileBadgeWhitePadding = 2; | 586 const size_t kProfileBadgeWhitePadding = 2; |
569 | 587 |
570 // Draws a white circle, then a light blue circle, then a dark blue icon. | 588 // Draws a white circle, then a light blue circle, then a dark blue icon. |
571 class ProfileBadge : public gfx::CanvasImageSource { | 589 class ProfileBadge : public gfx::CanvasImageSource { |
572 public: | 590 public: |
573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | 591 ProfileBadge(gfx::VectorIconId id, size_t icon_size) |
574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | 592 : CanvasImageSource(gfx::Size( |
575 false), | 593 switches::IsMaterialDesignUserMenu() |
594 ? kSmallProfileBadgeSize : kProfileBadgeSize, | |
595 switches::IsMaterialDesignUserMenu() | |
596 ? kSmallProfileBadgeSize : kProfileBadgeSize), | |
597 false), | |
576 id_(id), | 598 id_(id), |
577 icon_size_(icon_size) {} | 599 icon_size_(icon_size) {} |
578 | 600 |
579 ~ProfileBadge() override {} | 601 ~ProfileBadge() override {} |
580 | 602 |
581 // CanvasImageSource: | 603 // CanvasImageSource: |
582 void Draw(gfx::Canvas* canvas) override { | 604 void Draw(gfx::Canvas* canvas) override { |
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | 605 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); |
584 gfx::Rect bounds(0, 0, size.width(), size.height()); | 606 gfx::Rect bounds(0, 0, size.width(), size.height()); |
585 | 607 |
586 SkPaint paint; | 608 SkPaint paint; |
587 paint.setAntiAlias(true); | 609 paint.setAntiAlias(true); |
588 paint.setColor(SK_ColorWHITE); | 610 paint.setColor(SK_ColorWHITE); |
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | 611 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); |
590 | 612 |
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | 613 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); |
592 canvas->DrawCircle(bounds.CenterPoint(), | 614 canvas->DrawCircle(bounds.CenterPoint(), |
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); | 615 size.width() / 2 - kProfileBadgeWhitePadding, paint); |
594 | 616 |
595 int offset = (kProfileBadgeSize - icon_size_) / 2; | 617 int offset = ((switches::IsMaterialDesignUserMenu() |
618 ? kSmallProfileBadgeSize : kProfileBadgeSize) | |
619 - icon_size_) / 2; | |
596 canvas->Translate(gfx::Vector2d(offset, offset)); | 620 canvas->Translate(gfx::Vector2d(offset, offset)); |
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | 621 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
598 } | 622 } |
599 | 623 |
600 private: | 624 private: |
601 const gfx::VectorIconId id_; | 625 const gfx::VectorIconId id_; |
602 const size_t icon_size_; | 626 const size_t icon_size_; |
603 | 627 |
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | 628 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); |
605 }; | 629 }; |
606 | 630 |
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | 631 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
608 ProfileBadge* badge = | 632 ProfileBadge* badge = profile->IsChild() |
609 profile->IsChild() | 633 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 634 switches::IsMaterialDesignUserMenu() ? 21 : 26) |
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 635 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
612 | 636 switches::IsMaterialDesignUserMenu() ? 16 : 20); |
613 return gfx::ImageSkia(badge, badge->size()); | 637 return gfx::ImageSkia(badge, badge->size()); |
614 } | 638 } |
615 | 639 |
616 // ProfileChooserView --------------------------------------------------------- | 640 // ProfileChooserView --------------------------------------------------------- |
617 | 641 |
618 // static | 642 // static |
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 643 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 644 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
621 | 645 |
622 // static | 646 // static |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 bool ProfileChooserView::IsShowing() { | 681 bool ProfileChooserView::IsShowing() { |
658 return profile_bubble_ != NULL; | 682 return profile_bubble_ != NULL; |
659 } | 683 } |
660 | 684 |
661 // static | 685 // static |
662 void ProfileChooserView::Hide() { | 686 void ProfileChooserView::Hide() { |
663 if (IsShowing()) | 687 if (IsShowing()) |
664 profile_bubble_->GetWidget()->Close(); | 688 profile_bubble_->GetWidget()->Close(); |
665 } | 689 } |
666 | 690 |
691 // static | |
692 int ProfileChooserView::GetFixedMenuWidth() { | |
693 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
694 } | |
695 | |
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 696 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
668 Browser* browser, | 697 Browser* browser, |
669 profiles::BubbleViewMode view_mode, | 698 profiles::BubbleViewMode view_mode, |
670 profiles::TutorialMode tutorial_mode, | 699 profiles::TutorialMode tutorial_mode, |
671 signin::GAIAServiceType service_type, | 700 signin::GAIAServiceType service_type, |
672 signin_metrics::AccessPoint access_point) | 701 signin_metrics::AccessPoint access_point) |
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 702 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
674 browser_(browser), | 703 browser_(browser), |
675 view_mode_(view_mode), | 704 view_mode_(view_mode), |
676 tutorial_mode_(tutorial_mode), | 705 tutorial_mode_(tutorial_mode), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
831 break; | 860 break; |
832 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 861 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
833 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 862 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
834 sub_view = CreateSwitchUserView(); | 863 sub_view = CreateSwitchUserView(); |
835 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 864 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
836 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 865 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
837 break; | 866 break; |
838 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 867 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
839 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 868 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
840 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 869 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
841 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 870 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
842 sub_view = CreateProfileChooserView(avatar_menu); | 871 sub_view = CreateProfileChooserView(avatar_menu); |
843 break; | 872 break; |
844 } | 873 } |
845 // Clears tutorial mode for all non-profile-chooser views. | 874 // Clears tutorial mode for all non-profile-chooser views. |
846 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 875 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
847 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 876 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
848 | 877 |
849 layout->StartRow(1, 0); | 878 layout->StartRow(1, 0); |
850 layout->AddView(sub_view); | 879 layout->AddView(sub_view); |
851 Layout(); | 880 Layout(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 Indexes other_profiles; | 1106 Indexes other_profiles; |
1078 views::View* tutorial_view = NULL; | 1107 views::View* tutorial_view = NULL; |
1079 views::View* current_profile_view = NULL; | 1108 views::View* current_profile_view = NULL; |
1080 views::View* current_profile_accounts = NULL; | 1109 views::View* current_profile_accounts = NULL; |
1081 views::View* option_buttons_view = NULL; | 1110 views::View* option_buttons_view = NULL; |
1082 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1111 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1083 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1112 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1084 if (item.active) { | 1113 if (item.active) { |
1085 option_buttons_view = CreateOptionsView( | 1114 option_buttons_view = CreateOptionsView( |
1086 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1115 item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
1087 current_profile_view = CreateCurrentProfileView(item, false); | 1116 current_profile_view = switches::IsMaterialDesignUserMenu() ? |
1117 CreateMaterialDesignCurrentProfileView(item, false) : | |
1118 CreateCurrentProfileView(item, false); | |
1088 if (IsProfileChooser(view_mode_)) { | 1119 if (IsProfileChooser(view_mode_)) { |
1089 tutorial_view = CreateTutorialViewIfNeeded(item); | 1120 tutorial_view = CreateTutorialViewIfNeeded(item); |
1090 } else { | 1121 } else { |
1091 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1122 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1092 } | 1123 } |
1093 } else { | 1124 } else { |
1094 other_profiles.push_back(i); | 1125 other_profiles.push_back(i); |
1095 } | 1126 } |
1096 } | 1127 } |
1097 | 1128 |
(...skipping 16 matching lines...) Expand all Loading... | |
1114 | 1145 |
1115 if (!IsProfileChooser(view_mode_)) { | 1146 if (!IsProfileChooser(view_mode_)) { |
1116 DCHECK(current_profile_accounts); | 1147 DCHECK(current_profile_accounts); |
1117 layout->StartRow(0, 0); | 1148 layout->StartRow(0, 0); |
1118 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1149 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1119 layout->StartRow(1, 0); | 1150 layout->StartRow(1, 0); |
1120 layout->AddView(current_profile_accounts); | 1151 layout->AddView(current_profile_accounts); |
1121 } | 1152 } |
1122 | 1153 |
1123 if (browser_->profile()->IsSupervised()) { | 1154 if (browser_->profile()->IsSupervised()) { |
1124 layout->StartRow(0, 0); | 1155 if (!switches::IsMaterialDesignUserMenu()) { |
1125 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1156 layout->StartRow(0, 0); |
1157 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
1158 } | |
1126 layout->StartRow(1, 0); | 1159 layout->StartRow(1, 0); |
1127 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1160 layout->AddView(CreateSupervisedUserDisclaimerView()); |
1128 } | 1161 } |
1129 | 1162 |
1130 layout->StartRow(0, 0); | 1163 layout->StartRow(0, 0); |
1131 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1164 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1132 | 1165 |
1133 if (option_buttons_view) { | 1166 if (option_buttons_view) { |
1134 layout->StartRow(0, 0); | 1167 layout->StartRow(0, 0); |
1135 layout->AddView(option_buttons_view); | 1168 layout->AddView(option_buttons_view); |
(...skipping 11 matching lines...) Expand all Loading... | |
1147 } | 1180 } |
1148 } | 1181 } |
1149 | 1182 |
1150 layout->StartRow(1, 0); | 1183 layout->StartRow(1, 0); |
1151 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1184 layout->AddView(CreateOtherProfilesView(other_profiles)); |
1152 } | 1185 } |
1153 | 1186 |
1154 views::View* ProfileChooserView::CreateProfileChooserView( | 1187 views::View* ProfileChooserView::CreateProfileChooserView( |
1155 AvatarMenu* avatar_menu) { | 1188 AvatarMenu* avatar_menu) { |
1156 views::View* view = new views::View(); | 1189 views::View* view = new views::View(); |
1157 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1190 views::GridLayout* layout = CreateSingleColumnLayout(view, GetFixedMenuWidth() ); |
sky
2016/06/07 17:50:29
nit: > 80, run git cl format
Jane
2016/06/07 18:37:37
Done.
| |
1158 | 1191 |
1159 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1192 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
1160 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1193 PopulateMinimalProfileChooserView(layout, avatar_menu); |
1161 // The user is using right-click switching, no need to tell them about it. | 1194 // The user is using right-click switching, no need to tell them about it. |
1162 PrefService* local_state = g_browser_process->local_state(); | 1195 PrefService* local_state = g_browser_process->local_state(); |
1163 local_state->SetBoolean( | 1196 local_state->SetBoolean( |
1164 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1197 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1165 } else { | 1198 } else { |
1166 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1199 PopulateCompleteProfileChooserView(layout, avatar_menu); |
1167 } | 1200 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1223 bool stack_button, | 1256 bool stack_button, |
1224 views::Link** link, | 1257 views::Link** link, |
1225 views::LabelButton** button, | 1258 views::LabelButton** button, |
1226 views::ImageButton** close_button) { | 1259 views::ImageButton** close_button) { |
1227 tutorial_mode_ = tutorial_mode; | 1260 tutorial_mode_ = tutorial_mode; |
1228 | 1261 |
1229 views::View* view = new views::View(); | 1262 views::View* view = new views::View(); |
1230 view->set_background(views::Background::CreateSolidBackground( | 1263 view->set_background(views::Background::CreateSolidBackground( |
1231 profiles::kAvatarTutorialBackgroundColor)); | 1264 profiles::kAvatarTutorialBackgroundColor)); |
1232 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1265 views::GridLayout* layout = CreateSingleColumnLayout(view, |
1233 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1266 GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1234 // Creates a second column set for buttons and links. | 1267 // Creates a second column set for buttons and links. |
1235 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1268 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
1236 button_columns->AddColumn(views::GridLayout::LEADING, | 1269 button_columns->AddColumn(views::GridLayout::LEADING, |
1237 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1270 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1238 button_columns->AddPaddingColumn( | 1271 button_columns->AddPaddingColumn( |
1239 1, views::kUnrelatedControlHorizontalSpacing); | 1272 1, views::kUnrelatedControlHorizontalSpacing); |
1240 button_columns->AddColumn(views::GridLayout::TRAILING, | 1273 button_columns->AddColumn(views::GridLayout::TRAILING, |
1241 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1274 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1242 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1275 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1243 views::kButtonHEdgeMarginNew, | 1276 views::kButtonHEdgeMarginNew, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 layout->SkipColumns(1); | 1358 layout->SkipColumns(1); |
1326 } | 1359 } |
1327 | 1360 |
1328 return view; | 1361 return view; |
1329 } | 1362 } |
1330 | 1363 |
1331 views::View* ProfileChooserView::CreateCurrentProfileView( | 1364 views::View* ProfileChooserView::CreateCurrentProfileView( |
1332 const AvatarMenu::Item& avatar_item, | 1365 const AvatarMenu::Item& avatar_item, |
1333 bool is_guest) { | 1366 bool is_guest) { |
1334 views::View* view = new views::View(); | 1367 views::View* view = new views::View(); |
1335 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1368 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
1336 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1369 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
1337 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1370 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1338 views::kButtonHEdgeMarginNew, | 1371 views::kButtonHEdgeMarginNew, |
1339 views::kUnrelatedControlVerticalSpacing, | 1372 views::kUnrelatedControlVerticalSpacing, |
1340 views::kButtonHEdgeMarginNew); | 1373 views::kButtonHEdgeMarginNew); |
1341 | 1374 |
1342 // Profile icon, centered. | 1375 // Profile icon, centered. |
1343 int x_offset = (column_width - kLargeImageSide) / 2; | 1376 int x_offset = (column_width - kLargeImageSide) / 2; |
1344 current_profile_photo_ = new EditableProfilePhoto( | 1377 current_profile_photo_ = new EditableProfilePhoto( |
1345 this, avatar_item.icon, !is_guest, | 1378 this, avatar_item.icon, !is_guest, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1438 layout->StartRow(1, 0); | 1471 layout->StartRow(1, 0); |
1439 layout->AddView(signin_current_profile_link_); | 1472 layout->AddView(signin_current_profile_link_); |
1440 content::RecordAction( | 1473 content::RecordAction( |
1441 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1474 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
1442 } | 1475 } |
1443 } | 1476 } |
1444 | 1477 |
1445 return view; | 1478 return view; |
1446 } | 1479 } |
1447 | 1480 |
1481 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
1482 const AvatarMenu::Item& avatar_item, | |
1483 bool is_guest) { | |
1484 views::View* view = new views::View(); | |
1485 int column_width = GetFixedMenuWidth() - 2 * views::kMaterialHorizontalMargin; | |
1486 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | |
1487 layout->SetInsets(views::kRelatedControlVerticalSpacing, | |
1488 views::kMaterialHorizontalMargin, | |
1489 views::kRelatedControlVerticalSpacing, | |
1490 views::kMaterialHorizontalMargin); | |
1491 | |
1492 // Profile picture left aligned for material design user menu, | |
1493 // centered otherwise. | |
1494 const int kProfileRowHeight = 56; | |
1495 current_profile_photo_ = new EditableProfilePhoto( | |
1496 this, avatar_item.icon, !is_guest, | |
1497 gfx::Rect(0, (kProfileRowHeight - kMediumImageSide) / 2, | |
1498 kMediumImageSide, kMediumImageSide)); | |
1499 SizedContainer* profile_container = | |
1500 new SizedContainer(gfx::Size(column_width, kProfileRowHeight)); | |
1501 profile_container->AddChildView(current_profile_photo_); | |
1502 | |
1503 // Add supervised badge for supervised profile. | |
1504 if (browser_->profile()->IsSupervised()) { | |
1505 const int kBadgeSpacing = 4; | |
1506 views::ImageView* supervised_icon = new views::ImageView(); | |
1507 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); | |
1508 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | |
1509 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | |
1510 supervised_icon->SetBounds( | |
sky
2016/06/07 17:50:29
Is it expected that you're doing layout in this co
Jane
2016/06/07 18:37:37
This function is entirely based on the existing co
| |
1511 parent_bounds.right() - preferred_size.width() + kBadgeSpacing, | |
1512 parent_bounds.bottom() - preferred_size.height() + kBadgeSpacing, | |
1513 preferred_size.width(), | |
1514 preferred_size.height()); | |
1515 profile_container->AddChildView(supervised_icon); | |
1516 } | |
1517 | |
1518 // Profile name, left-aligned to the right of profile icon. | |
1519 bool editing_allowed = !is_guest && | |
1520 !browser_->profile()->IsLegacySupervised(); | |
1521 current_profile_name_ = new EditableProfileName( | |
1522 this, | |
1523 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
1524 editing_allowed); | |
1525 gfx::Rect photo_bounds = current_profile_photo_->bounds(); | |
1526 const int kTextfieldLeftMargin = | |
sky
2016/06/07 17:50:29
Again, don't use kFoo for non compile time constan
Jane
2016/06/07 18:37:37
Done.
| |
1527 kProfileHorizontalSpacing - | |
1528 (editing_allowed ? kTextfieldLabelHorizontalSpacing : 0); | |
1529 current_profile_name_->SetBounds( | |
1530 photo_bounds.width() + kTextfieldLeftMargin, | |
1531 views::kRelatedControlVerticalSpacing, | |
1532 profile_container->GetPreferredSize().width() - photo_bounds.width() | |
1533 - kTextfieldLeftMargin, | |
1534 profile_container->GetPreferredSize().height() / 2 | |
1535 - views::kRelatedControlVerticalSpacing); | |
1536 profile_container->AddChildView(current_profile_name_); | |
1537 | |
1538 // Center-align the avatar name if the profile is not signed in. | |
1539 if (is_guest || !avatar_item.signed_in) { | |
1540 current_profile_name_->SetY( | |
1541 (profile_container->GetPreferredSize().height() | |
1542 - current_profile_name_->height()) / 2); | |
1543 layout->StartRow(1, 0); | |
1544 layout->AddView(profile_container); | |
1545 } | |
1546 | |
1547 if (is_guest) | |
1548 return view; | |
1549 | |
1550 // The available links depend on the type of profile that is active. | |
1551 if (avatar_item.signed_in) { | |
1552 // Calculate the position and size for links available for signed-in | |
1553 // profiles. | |
1554 const int kXCoordinate = photo_bounds.width() + kProfileHorizontalSpacing; | |
sky
2016/06/07 17:50:29
Same comment for all variables.
Jane
2016/06/07 18:37:37
Done.
| |
1555 const int kYCoordinate = profile_container->GetPreferredSize().height() / 2; | |
1556 const int kWidth = profile_container->GetPreferredSize().width() | |
1557 - photo_bounds.width() - kProfileHorizontalSpacing; | |
1558 const int kHeight = profile_container->GetPreferredSize().height() / 2 | |
1559 - views::kRelatedControlVerticalSpacing; | |
1560 layout->StartRow(1, 0); | |
1561 | |
1562 if (switches::IsEnableAccountConsistency()) { | |
1563 base::string16 link_title = l10n_util::GetStringUTF16( | |
1564 IsProfileChooser(view_mode_) ? | |
1565 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : | |
1566 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
1567 manage_accounts_link_ = CreateLink(link_title, this); | |
1568 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1569 manage_accounts_link_->SetBounds( | |
1570 kXCoordinate, kYCoordinate, kWidth, kHeight); | |
1571 profile_container->AddChildView(manage_accounts_link_); | |
1572 } else { | |
1573 // Badge the email address if there's an authentication error. | |
1574 if (HasAuthError(browser_->profile())) { | |
1575 auth_error_email_button_ = | |
1576 new RightAlignedIconLabelButton(this, avatar_item.username); | |
1577 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1578 auth_error_email_button_->SetImage( | |
1579 views::LabelButton::STATE_NORMAL, | |
1580 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 12, | |
1581 gfx::kChromeIconGrey)); | |
1582 auth_error_email_button_->SetFocusForPlatform(); | |
1583 auth_error_email_button_->set_request_focus_on_press(true); | |
1584 gfx::Insets insets = | |
1585 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | |
1586 views::Button::STYLE_TEXTBUTTON); | |
1587 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( | |
1588 insets.top(), insets.left(), insets.bottom(), insets.right())); | |
1589 auth_error_email_button_->SetBounds( | |
1590 kXCoordinate - insets.left(), kYCoordinate, kWidth, kHeight); | |
1591 profile_container->AddChildView(auth_error_email_button_); | |
1592 } else { | |
1593 views::Label* email_label = new views::Label(avatar_item.username); | |
1594 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1595 email_label->SetEnabled(false); | |
1596 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1597 email_label->SetBounds( | |
1598 kXCoordinate, kYCoordinate, kWidth, kHeight); | |
1599 profile_container->AddChildView(email_label); | |
1600 } | |
1601 } | |
1602 layout->AddView(profile_container); | |
1603 } else { | |
1604 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
1605 browser_->profile()->GetOriginalProfile()); | |
1606 if (signin_manager->IsSigninAllowed()) { | |
1607 views::Label* promo = new views::Label( | |
1608 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
1609 promo->SetMultiLine(true); | |
1610 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1611 layout->StartRowWithPadding(1, 0, 0, | |
1612 views::kRelatedControlVerticalSpacing); | |
1613 layout->StartRow(1, 0); | |
1614 layout->AddView(promo); | |
1615 | |
1616 signin_current_profile_link_ = new views::BlueButton( | |
1617 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
1618 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1619 signin_current_profile_link_->SetMinSize(gfx::Size(0, 36)); | |
1620 layout->StartRowWithPadding(1, 0, 0, | |
1621 views::kRelatedControlVerticalSpacing); | |
1622 layout->StartRow(1, 0); | |
1623 layout->AddView(signin_current_profile_link_); | |
1624 content::RecordAction( | |
1625 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
1626 layout->StartRowWithPadding(1, 0, 0, | |
1627 views::kLabelToControlVerticalSpacing); | |
1628 } | |
1629 } | |
1630 | |
1631 return view; | |
1632 } | |
1633 | |
1448 views::View* ProfileChooserView::CreateGuestProfileView() { | 1634 views::View* ProfileChooserView::CreateGuestProfileView() { |
1449 gfx::Image guest_icon = | 1635 gfx::Image guest_icon = |
1450 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1636 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
1451 profiles::GetPlaceholderAvatarIconResourceID()); | 1637 profiles::GetPlaceholderAvatarIconResourceID()); |
1452 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1638 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
1453 guest_avatar_item.active = true; | 1639 guest_avatar_item.active = true; |
1454 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1640 guest_avatar_item.name = l10n_util::GetStringUTF16( |
1455 IDS_PROFILES_GUEST_PROFILE_NAME); | 1641 IDS_PROFILES_GUEST_PROFILE_NAME); |
1456 guest_avatar_item.signed_in = false; | 1642 guest_avatar_item.signed_in = false; |
1457 | 1643 |
1458 return CreateCurrentProfileView(guest_avatar_item, true); | 1644 return switches::IsMaterialDesignUserMenu() ? |
1645 CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) : | |
1646 CreateCurrentProfileView(guest_avatar_item, true); | |
1459 } | 1647 } |
1460 | 1648 |
1461 views::View* ProfileChooserView::CreateOtherProfilesView( | 1649 views::View* ProfileChooserView::CreateOtherProfilesView( |
1462 const Indexes& avatars_to_show) { | 1650 const Indexes& avatars_to_show) { |
1463 views::View* view = new views::View(); | 1651 views::View* view = new views::View(); |
1464 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1652 views::GridLayout* layout = CreateSingleColumnLayout(view, GetFixedMenuWidth() ); |
1465 | 1653 |
1466 for (size_t index : avatars_to_show) { | 1654 for (size_t index : avatars_to_show) { |
1467 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1655 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
1468 const int kSmallImageSide = 32; | 1656 const int kSmallImageSide = 32; |
1469 | 1657 |
1470 // Use the low-res, small default avatars in the fast user switcher, like | 1658 // Use the low-res, small default avatars in the fast user switcher, like |
1471 // we do in the menu bar. | 1659 // we do in the menu bar. |
1472 gfx::Image item_icon; | 1660 gfx::Image item_icon; |
1473 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1661 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
1474 | 1662 |
(...skipping 10 matching lines...) Expand all Loading... | |
1485 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1673 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1486 layout->StartRow(1, 0); | 1674 layout->StartRow(1, 0); |
1487 layout->AddView(button); | 1675 layout->AddView(button); |
1488 } | 1676 } |
1489 | 1677 |
1490 return view; | 1678 return view; |
1491 } | 1679 } |
1492 | 1680 |
1493 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1681 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
1494 views::View* view = new views::View(); | 1682 views::View* view = new views::View(); |
1495 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1683 views::GridLayout* layout = CreateSingleColumnLayout(view, GetFixedMenuWidth() ); |
1496 | 1684 |
1497 base::string16 text = browser_->profile()->IsGuestSession() ? | 1685 base::string16 text = browser_->profile()->IsGuestSession() ? |
1498 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1686 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1499 l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1687 l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
1500 const int kIconSize = 16; | 1688 const int kIconSize = 16; |
1501 users_button_ = new BackgroundColorHoverButton( | 1689 users_button_ = new BackgroundColorHoverButton( |
1502 this, text, gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, | 1690 this, text, gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, |
1503 kIconSize, gfx::kChromeIconGrey)); | 1691 kIconSize, gfx::kChromeIconGrey)); |
1504 layout->StartRow(1, 0); | 1692 layout->StartRow(1, 0); |
1505 layout->AddView(users_button_); | 1693 layout->AddView(users_button_); |
1506 | 1694 |
1507 if (display_lock) { | 1695 if (display_lock) { |
1508 layout->StartRow(1, 0); | 1696 layout->StartRow(1, 0); |
1509 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1697 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1510 | 1698 |
1511 lock_button_ = new BackgroundColorHoverButton( | 1699 lock_button_ = new BackgroundColorHoverButton( |
1512 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1700 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
1513 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | 1701 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
1514 gfx::kChromeIconGrey)); | 1702 gfx::kChromeIconGrey)); |
1515 layout->StartRow(1, 0); | 1703 layout->StartRow(1, 0); |
1516 layout->AddView(lock_button_); | 1704 layout->AddView(lock_button_); |
1517 } | 1705 } |
1518 return view; | 1706 return view; |
1519 } | 1707 } |
1520 | 1708 |
1521 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1709 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1522 views::View* view = new views::View(); | 1710 views::View* view = new views::View(); |
1523 views::GridLayout* layout = CreateSingleColumnLayout( | 1711 views::GridLayout* layout = CreateSingleColumnLayout( |
1524 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1712 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1525 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1713 if (switches::IsMaterialDesignUserMenu()) { |
1526 views::kButtonHEdgeMarginNew, | 1714 layout->SetInsets(0, |
1527 views::kRelatedControlVerticalSpacing, | 1715 views::kMaterialHorizontalMargin, |
1528 views::kButtonHEdgeMarginNew); | 1716 views::kMaterialVerticalMargin, |
1717 views::kMaterialHorizontalMargin); | |
1718 } else { | |
1719 layout->SetInsets(views::kRelatedControlVerticalSpacing, | |
1720 views::kButtonHEdgeMarginNew, | |
1721 views::kRelatedControlVerticalSpacing, | |
1722 views::kButtonHEdgeMarginNew); | |
1723 } | |
1724 | |
1529 views::Label* disclaimer = new views::Label( | 1725 views::Label* disclaimer = new views::Label( |
1530 avatar_menu_->GetSupervisedUserInformation()); | 1726 avatar_menu_->GetSupervisedUserInformation()); |
1531 disclaimer->SetMultiLine(true); | 1727 disclaimer->SetMultiLine(true); |
1532 disclaimer->SetAllowCharacterBreak(true); | 1728 disclaimer->SetAllowCharacterBreak(true); |
1533 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1729 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1534 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1730 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1535 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1731 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
1536 layout->StartRow(1, 0); | 1732 layout->StartRow(1, 0); |
1537 layout->AddView(disclaimer); | 1733 layout->AddView(disclaimer); |
1538 | 1734 |
1539 return view; | 1735 return view; |
1540 } | 1736 } |
1541 | 1737 |
1542 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1738 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
1543 const AvatarMenu::Item& avatar_item) { | 1739 const AvatarMenu::Item& avatar_item) { |
1544 DCHECK(avatar_item.signed_in); | 1740 DCHECK(avatar_item.signed_in); |
1545 views::View* view = new views::View(); | 1741 views::View* view = new views::View(); |
1546 view->set_background(views::Background::CreateSolidBackground( | 1742 view->set_background(views::Background::CreateSolidBackground( |
1547 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1743 profiles::kAvatarBubbleAccountsBackgroundColor)); |
1548 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1744 views::GridLayout* layout = CreateSingleColumnLayout(view, GetFixedMenuWidth() ); |
1549 | 1745 |
1550 Profile* profile = browser_->profile(); | 1746 Profile* profile = browser_->profile(); |
1551 std::string primary_account = | 1747 std::string primary_account = |
1552 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1748 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
1553 DCHECK(!primary_account.empty()); | 1749 DCHECK(!primary_account.empty()); |
1554 std::vector<std::string>accounts = | 1750 std::vector<std::string>accounts = |
1555 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1751 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
1556 | 1752 |
1557 // Get state of authentication error, if any. | 1753 // Get state of authentication error, if any. |
1558 std::string error_account_id = GetAuthErrorAccountId(profile); | 1754 std::string error_account_id = GetAuthErrorAccountId(profile); |
1559 | 1755 |
1560 // The primary account should always be listed first. | 1756 // The primary account should always be listed first. |
1561 // TODO(rogerta): we still need to further differentiate the primary account | 1757 // TODO(rogerta): we still need to further differentiate the primary account |
1562 // from the others in the UI, so more work is likely required here: | 1758 // from the others in the UI, so more work is likely required here: |
1563 // crbug.com/311124. | 1759 // crbug.com/311124. |
1564 CreateAccountButton(layout, primary_account, true, | 1760 CreateAccountButton(layout, primary_account, true, |
1565 error_account_id == primary_account, kFixedMenuWidth); | 1761 error_account_id == primary_account, GetFixedMenuWidth()); |
1566 for (size_t i = 0; i < accounts.size(); ++i) | 1762 for (size_t i = 0; i < accounts.size(); ++i) |
1567 CreateAccountButton(layout, accounts[i], false, | 1763 CreateAccountButton(layout, accounts[i], false, |
1568 error_account_id == accounts[i], kFixedMenuWidth); | 1764 error_account_id == accounts[i], GetFixedMenuWidth()); |
1569 | 1765 |
1570 if (!profile->IsSupervised()) { | 1766 if (!profile->IsSupervised()) { |
1571 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1767 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1572 | 1768 |
1573 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1769 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
1574 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1770 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
1575 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1771 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
1576 0, views::kButtonVEdgeMarginNew, | 1772 0, views::kButtonVEdgeMarginNew, |
1577 views::kRelatedControlVerticalSpacing, 0)); | 1773 views::kRelatedControlVerticalSpacing, 0)); |
1578 layout->StartRow(1, 0); | 1774 layout->StartRow(1, 0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1868 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2064 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1869 IncognitoModePrefs::DISABLED; | 2065 IncognitoModePrefs::DISABLED; |
1870 return incognito_available && !browser_->profile()->IsGuestSession(); | 2066 return incognito_available && !browser_->profile()->IsGuestSession(); |
1871 } | 2067 } |
1872 | 2068 |
1873 void ProfileChooserView::PostActionPerformed( | 2069 void ProfileChooserView::PostActionPerformed( |
1874 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2070 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1875 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2071 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1876 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2072 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1877 } | 2073 } |
OLD | NEW |