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 | |
94 const int kTextfieldLabelHorizontalSpacing = 4; | |
95 const int kProfileHorizontalSpacing = 16; | |
Evan Stade
2016/06/13 23:14:41
pretty sure you should use kMaterialMenuHorizontal
Jane
2016/06/14 14:47:21
Done. You have a point; I didn't think this way be
| |
96 | |
97 // Vertical spacing between the edge of the material design user menu and the | |
98 // top or bottom of the menu items. | |
99 const int kMaterialMenuVerticalEdgeMargin = 16; | |
100 // Horizontal spacing between the edge of the material design user menu and the | |
101 // left or right of the menu items. | |
102 const int kMaterialMenuHorizontalEdgeMargin = 16; | |
93 | 103 |
94 const int kVerticalSpacing = 16; | 104 const int kVerticalSpacing = 16; |
95 | 105 |
96 const int kTitleViewNativeWidgetOffset = 8; | 106 const int kTitleViewNativeWidgetOffset = 8; |
97 | 107 |
98 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 108 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 109 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 110 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
101 } | 111 } |
102 | 112 |
113 // DEPRECATED: New user menu components should use views::BoxLayout instead. | |
103 // Creates a GridLayout with a single column. This ensures that all the child | 114 // 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. | 115 // views added get auto-expanded to fill the full width of the bubble. |
105 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 116 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
106 views::GridLayout* layout = new views::GridLayout(view); | 117 views::GridLayout* layout = new views::GridLayout(view); |
107 view->SetLayoutManager(layout); | 118 view->SetLayoutManager(layout); |
108 | 119 |
109 views::ColumnSet* columns = layout->AddColumnSet(0); | 120 views::ColumnSet* columns = layout->AddColumnSet(0); |
110 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 121 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
111 views::GridLayout::FIXED, width, width); | 122 views::GridLayout::FIXED, width, width); |
112 return layout; | 123 return layout; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 gfx::Rect bounds(title_view_->GetPreferredSize()); | 267 gfx::Rect bounds(title_view_->GetPreferredSize()); |
257 title_view_->SetBoundsRect(bounds); | 268 title_view_->SetBoundsRect(bounds); |
258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 269 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
259 title_widget_->SetBounds(bounds); | 270 title_widget_->SetBounds(bounds); |
260 } | 271 } |
261 | 272 |
262 } // namespace | 273 } // namespace |
263 | 274 |
264 // RightAlignedIconLabelButton ------------------------------------------------- | 275 // RightAlignedIconLabelButton ------------------------------------------------- |
265 | 276 |
266 // A custom LabelButton that has a centered text and right aligned icon. | 277 // A custom LabelButton that has a left-aligned text and right aligned icon. |
278 // For non-material-design user menu, it has centered text instead. | |
267 class RightAlignedIconLabelButton : public views::LabelButton { | 279 class RightAlignedIconLabelButton : public views::LabelButton { |
268 public: | 280 public: |
269 RightAlignedIconLabelButton(views::ButtonListener* listener, | 281 RightAlignedIconLabelButton(views::ButtonListener* listener, |
270 const base::string16& text) | 282 const base::string16& text) |
271 : views::LabelButton(listener, text) { | 283 : views::LabelButton(listener, text) { |
272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 284 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 285 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
286 ? gfx::ALIGN_LEFT | |
287 : gfx::ALIGN_CENTER); | |
274 } | 288 } |
275 | 289 |
276 protected: | 290 protected: |
277 void Layout() override { | 291 void Layout() override { |
278 views::LabelButton::Layout(); | 292 views::LabelButton::Layout(); |
279 | 293 |
280 // Keep the text centered and the icon right-aligned by stretching the label | 294 // 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. | 295 // to take up more of the content area and centering its contents. |
282 gfx::Rect content_bounds = GetContentsBounds(); | 296 gfx::Rect content_bounds = GetContentsBounds(); |
283 gfx::Rect label_bounds = label()->bounds(); | 297 gfx::Rect label_bounds = label()->bounds(); |
(...skipping 17 matching lines...) Expand all Loading... | |
301 | 315 |
302 // A custom Image control that shows a "change" button when moused over. | 316 // A custom Image control that shows a "change" button when moused over. |
303 class EditableProfilePhoto : public views::LabelButton { | 317 class EditableProfilePhoto : public views::LabelButton { |
304 public: | 318 public: |
305 EditableProfilePhoto(views::ButtonListener* listener, | 319 EditableProfilePhoto(views::ButtonListener* listener, |
306 const gfx::Image& icon, | 320 const gfx::Image& icon, |
307 bool is_editing_allowed, | 321 bool is_editing_allowed, |
308 const gfx::Rect& bounds) | 322 const gfx::Rect& bounds) |
309 : views::LabelButton(listener, base::string16()), | 323 : views::LabelButton(listener, base::string16()), |
310 photo_overlay_(NULL) { | 324 photo_overlay_(NULL) { |
311 gfx::Image image = profiles::GetSizedAvatarIcon( | 325 const int icon_image_side = switches::IsMaterialDesignUserMenu() |
312 icon, true, kLargeImageSide, kLargeImageSide); | 326 ? kMediumImageSide |
327 : kLargeImageSide; | |
328 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side, | |
329 icon_image_side); | |
313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 330 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
314 SetBorder(views::Border::NullBorder()); | 331 SetBorder(views::Border::NullBorder()); |
315 SetBoundsRect(bounds); | 332 SetBoundsRect(bounds); |
316 | 333 |
317 // Calculate the circular mask that will be used to display the photo. | 334 // Calculate the circular mask that will be used to display the photo. |
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 335 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), |
319 SkIntToScalar(bounds.height() / 2), | 336 SkIntToScalar(bounds.height() / 2), |
320 SkIntToScalar(bounds.width() / 2)); | 337 SkIntToScalar(bounds.width() / 2)); |
321 | 338 |
322 if (!is_editing_allowed) { | 339 if (!is_editing_allowed) { |
323 SetEnabled(false); | 340 SetEnabled(false); |
324 return; | 341 return; |
325 } | 342 } |
326 | 343 |
327 set_notify_enter_exit_on_child(true); | 344 set_notify_enter_exit_on_child(true); |
328 | 345 |
329 // Photo overlay that appears when hovering over the button. | 346 // Photo overlay that appears when hovering over the button. |
330 photo_overlay_ = new views::ImageView(); | 347 photo_overlay_ = new views::ImageView(); |
331 | 348 |
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 349 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
333 photo_overlay_->set_background( | 350 photo_overlay_->set_background( |
334 views::Background::CreateSolidBackground(kBackgroundColor)); | 351 views::Background::CreateSolidBackground(kBackgroundColor)); |
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 352 photo_overlay_->SetImage( |
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 353 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA, |
354 switches::IsMaterialDesignUserMenu() ? 22u : 48u, | |
355 SkColorSetRGB(0x33, 0x33, 0x33))); | |
337 | 356 |
338 photo_overlay_->SetSize(bounds.size()); | 357 photo_overlay_->SetSize(bounds.size()); |
339 photo_overlay_->SetVisible(false); | 358 photo_overlay_->SetVisible(false); |
340 AddChildView(photo_overlay_); | 359 AddChildView(photo_overlay_); |
341 } | 360 } |
342 | 361 |
343 void OnPaint(gfx::Canvas* canvas) override { | 362 void OnPaint(gfx::Canvas* canvas) override { |
344 // Display the profile picture as a circle. | 363 // Display the profile picture as a circle. |
345 canvas->ClipPath(circular_mask_, true); | 364 canvas->ClipPath(circular_mask_, true); |
346 views::LabelButton::OnPaint(canvas); | 365 views::LabelButton::OnPaint(canvas); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 bool is_editing_allowed) | 414 bool is_editing_allowed) |
396 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { | 415 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { |
397 SetLayoutManager( | 416 SetLayoutManager( |
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 417 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
399 | 418 |
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 419 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
401 const gfx::FontList& medium_font_list = | 420 const gfx::FontList& medium_font_list = |
402 rb->GetFontList(ui::ResourceBundle::MediumFont); | 421 rb->GetFontList(ui::ResourceBundle::MediumFont); |
403 | 422 |
404 if (!is_editing_allowed) { | 423 if (!is_editing_allowed) { |
405 label_ = new views::Label(text); | 424 label_ = new views::Label(text); |
Evan Stade
2016/06/13 23:14:40
since you asked me to find other constants I don't
Jane
2016/06/14 14:47:21
Done.
I appreciate the close attention that you ar
| |
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 425 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); |
Evan Stade
2016/06/13 23:14:41
are these 2s distinct from the 2s below?
Jane
2016/06/14 14:47:21
I assume so, but then again, I'm not touching any
Evan Stade
2016/06/14 15:16:26
I'm a bit perplexed by your stance on pre-existing
Jane
2016/06/14 21:39:57
Done. Makes sense, I set 2 to be border_width.
| |
407 label_->SetFontList(medium_font_list); | 426 label_->SetFontList(medium_font_list); |
427 if (switches::IsMaterialDesignUserMenu()) | |
428 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
408 AddChildView(label_); | 429 AddChildView(label_); |
409 return; | 430 return; |
410 } | 431 } |
411 | 432 |
412 button_ = new RightAlignedIconLabelButton(this, text); | 433 button_ = new RightAlignedIconLabelButton(this, text); |
413 button_->SetFontList(medium_font_list); | 434 button_->SetFontList(medium_font_list); |
414 // Show an "edit" pencil icon when hovering over. In the default state, | 435 // 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 | 436 // 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. | 437 // the text doesn't jump around when the hovered icon appears. |
417 // TODO(estade): revisit colors and press effect. | 438 // TODO(estade): revisit colors and press effect. |
418 const int kIconSize = 16; | 439 const int kIconSize = 16; |
419 button_->SetImage(views::LabelButton::STATE_NORMAL, | 440 button_->SetImage(views::LabelButton::STATE_NORMAL, |
420 CreateSquarePlaceholderImage(kIconSize)); | 441 CreateSquarePlaceholderImage(kIconSize)); |
421 button_->SetImage(views::LabelButton::STATE_HOVERED, | 442 button_->SetImage(views::LabelButton::STATE_HOVERED, |
422 gfx::CreateVectorIcon( | 443 gfx::CreateVectorIcon( |
423 gfx::VectorIconId::MODE_EDIT, kIconSize, | 444 gfx::VectorIconId::MODE_EDIT, kIconSize, |
424 SkColorSetRGB(0x33, 0x33, 0x33))); | 445 SkColorSetRGB(0x33, 0x33, 0x33))); |
425 button_->SetImage(views::LabelButton::STATE_PRESSED, | 446 button_->SetImage(views::LabelButton::STATE_PRESSED, |
426 gfx::CreateVectorIcon( | 447 gfx::CreateVectorIcon( |
427 gfx::VectorIconId::MODE_EDIT, kIconSize, | 448 gfx::VectorIconId::MODE_EDIT, kIconSize, |
428 SkColorSetRGB(0x20, 0x20, 0x20))); | 449 SkColorSetRGB(0x20, 0x20, 0x20))); |
429 // To center the text, we need to offest it by the width of the icon we | 450 // 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 | 451 // to the text to account for the textfield's border. |
431 // padding to account for the textfield's border. | 452 if (switches::IsMaterialDesignUserMenu()) { |
432 const int kIconTextLabelButtonSpacing = 5; | 453 button_->SetBorder(views::Border::CreateEmptyBorder( |
Evan Stade
2016/06/13 23:14:40
OK, I may have misunderstood the purpose of kTextf
Jane
2016/06/14 14:47:21
Done. Thanks, didn't know this before.
(Although t
| |
433 button_->SetBorder(views::Border::CreateEmptyBorder( | 454 2, kTextfieldLabelHorizontalSpacing, 2, 0)); |
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 455 } else { |
456 const int kIconTextLabelButtonSpacing = 5; | |
457 button_->SetBorder(views::Border::CreateEmptyBorder( | |
458 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | |
459 } | |
435 AddChildView(button_); | 460 AddChildView(button_); |
436 | 461 |
437 profile_name_textfield_ = new views::Textfield(); | 462 profile_name_textfield_ = new views::Textfield(); |
438 // Textfield that overlaps the button. | 463 // Textfield that overlaps the button. |
439 profile_name_textfield_->set_controller(controller); | 464 profile_name_textfield_->set_controller(controller); |
440 profile_name_textfield_->SetFontList(medium_font_list); | 465 profile_name_textfield_->SetFontList(medium_font_list); |
441 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 466 profile_name_textfield_->SetHorizontalAlignment( |
467 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT | |
468 : gfx::ALIGN_CENTER); | |
442 profile_name_textfield_->SetVisible(false); | 469 profile_name_textfield_->SetVisible(false); |
443 AddChildView(profile_name_textfield_); | 470 AddChildView(profile_name_textfield_); |
444 } | 471 } |
445 | 472 |
446 views::Textfield* profile_name_textfield() { | 473 views::Textfield* profile_name_textfield() { |
447 return profile_name_textfield_; | 474 return profile_name_textfield_; |
448 } | 475 } |
449 | 476 |
450 // Hide the editable textfield to show the profile name button instead. | 477 // Hide the editable textfield to show the profile name button instead. |
451 void ShowReadOnlyView() { | 478 void ShowReadOnlyView() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 | 585 |
559 views::ImageButton* back_button_; | 586 views::ImageButton* back_button_; |
560 views::Label* title_label_; | 587 views::Label* title_label_; |
561 | 588 |
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 589 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
563 }; | 590 }; |
564 | 591 |
565 // ProfileBadge -------------------------------------------------------- | 592 // ProfileBadge -------------------------------------------------------- |
566 | 593 |
567 const size_t kProfileBadgeSize = 30; | 594 const size_t kProfileBadgeSize = 30; |
595 const size_t kSmallProfileBadgeSize = 24; | |
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(gfx::Size(switches::IsMaterialDesignUserMenu() |
603 ? kSmallProfileBadgeSize | |
604 : kProfileBadgeSize, | |
605 switches::IsMaterialDesignUserMenu() | |
606 ? kSmallProfileBadgeSize | |
607 : kProfileBadgeSize), | |
575 false), | 608 false), |
576 id_(id), | 609 id_(id), |
577 icon_size_(icon_size) {} | 610 icon_size_(icon_size) {} |
578 | 611 |
579 ~ProfileBadge() override {} | 612 ~ProfileBadge() override {} |
580 | 613 |
581 // CanvasImageSource: | 614 // CanvasImageSource: |
582 void Draw(gfx::Canvas* canvas) override { | 615 void Draw(gfx::Canvas* canvas) override { |
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | 616 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); |
584 gfx::Rect bounds(0, 0, size.width(), size.height()); | 617 gfx::Rect bounds(0, 0, size.width(), size.height()); |
585 | 618 |
586 SkPaint paint; | 619 SkPaint paint; |
587 paint.setAntiAlias(true); | 620 paint.setAntiAlias(true); |
588 paint.setColor(SK_ColorWHITE); | 621 paint.setColor(SK_ColorWHITE); |
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | 622 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); |
590 | 623 |
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | 624 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); |
592 canvas->DrawCircle(bounds.CenterPoint(), | 625 canvas->DrawCircle(bounds.CenterPoint(), |
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); | 626 size.width() / 2 - kProfileBadgeWhitePadding, paint); |
594 | 627 |
595 int offset = (kProfileBadgeSize - icon_size_) / 2; | 628 int offset = ((switches::IsMaterialDesignUserMenu() ? kSmallProfileBadgeSize |
Evan Stade
2016/06/13 23:14:40
this ternary appears 3 times
Jane
2016/06/14 14:47:21
I did realize this and I wanted to make it a const
Evan Stade
2016/06/14 15:16:26
I think that would be an improvement. The badge si
Jane
2016/06/14 21:39:56
Done.
| |
629 : kProfileBadgeSize) - | |
630 icon_size_) / 2; | |
596 canvas->Translate(gfx::Vector2d(offset, offset)); | 631 canvas->Translate(gfx::Vector2d(offset, offset)); |
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | 632 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
598 } | 633 } |
599 | 634 |
600 private: | 635 private: |
601 const gfx::VectorIconId id_; | 636 const gfx::VectorIconId id_; |
602 const size_t icon_size_; | 637 const size_t icon_size_; |
603 | 638 |
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | 639 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); |
605 }; | 640 }; |
606 | 641 |
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | 642 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
608 ProfileBadge* badge = | 643 ProfileBadge* badge = |
609 profile->IsChild() | 644 profile->IsChild() |
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 645 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 646 switches::IsMaterialDesignUserMenu() ? 21 : 26) |
612 | 647 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
648 switches::IsMaterialDesignUserMenu() ? 16 : 20); | |
613 return gfx::ImageSkia(badge, badge->size()); | 649 return gfx::ImageSkia(badge, badge->size()); |
614 } | 650 } |
615 | 651 |
616 // ProfileChooserView --------------------------------------------------------- | 652 // ProfileChooserView --------------------------------------------------------- |
617 | 653 |
618 // static | 654 // static |
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 655 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 656 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
621 | 657 |
622 // static | 658 // static |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 bool ProfileChooserView::IsShowing() { | 693 bool ProfileChooserView::IsShowing() { |
658 return profile_bubble_ != NULL; | 694 return profile_bubble_ != NULL; |
659 } | 695 } |
660 | 696 |
661 // static | 697 // static |
662 void ProfileChooserView::Hide() { | 698 void ProfileChooserView::Hide() { |
663 if (IsShowing()) | 699 if (IsShowing()) |
664 profile_bubble_->GetWidget()->Close(); | 700 profile_bubble_->GetWidget()->Close(); |
665 } | 701 } |
666 | 702 |
703 // static | |
704 int ProfileChooserView::GetFixedMenuWidth() { | |
705 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
706 } | |
707 | |
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 708 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
668 Browser* browser, | 709 Browser* browser, |
669 profiles::BubbleViewMode view_mode, | 710 profiles::BubbleViewMode view_mode, |
670 profiles::TutorialMode tutorial_mode, | 711 profiles::TutorialMode tutorial_mode, |
671 signin::GAIAServiceType service_type, | 712 signin::GAIAServiceType service_type, |
672 signin_metrics::AccessPoint access_point) | 713 signin_metrics::AccessPoint access_point) |
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 714 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
674 browser_(browser), | 715 browser_(browser), |
675 view_mode_(view_mode), | 716 view_mode_(view_mode), |
676 tutorial_mode_(tutorial_mode), | 717 tutorial_mode_(tutorial_mode), |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 break; | 873 break; |
833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 874 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 875 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
835 sub_view = CreateSwitchUserView(); | 876 sub_view = CreateSwitchUserView(); |
836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 877 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 878 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
838 break; | 879 break; |
839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 880 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 881 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 882 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 883 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
843 sub_view = CreateProfileChooserView(avatar_menu); | 884 sub_view = CreateProfileChooserView(avatar_menu); |
844 break; | 885 break; |
845 } | 886 } |
846 // Clears tutorial mode for all non-profile-chooser views. | 887 // Clears tutorial mode for all non-profile-chooser views. |
847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 888 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 889 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
849 | 890 |
850 layout->StartRow(1, 0); | 891 layout->StartRow(1, 0); |
851 layout->AddView(sub_view); | 892 layout->AddView(sub_view); |
852 Layout(); | 893 Layout(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 Indexes other_profiles; | 1123 Indexes other_profiles; |
1083 views::View* tutorial_view = NULL; | 1124 views::View* tutorial_view = NULL; |
1084 views::View* current_profile_view = NULL; | 1125 views::View* current_profile_view = NULL; |
1085 views::View* current_profile_accounts = NULL; | 1126 views::View* current_profile_accounts = NULL; |
1086 views::View* option_buttons_view = NULL; | 1127 views::View* option_buttons_view = NULL; |
1087 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1128 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1088 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1129 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1089 if (item.active) { | 1130 if (item.active) { |
1090 option_buttons_view = CreateOptionsView( | 1131 option_buttons_view = CreateOptionsView( |
1091 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1132 item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
1092 current_profile_view = CreateCurrentProfileView(item, false); | 1133 current_profile_view = |
1134 switches::IsMaterialDesignUserMenu() | |
1135 ? CreateMaterialDesignCurrentProfileView(item, false) | |
1136 : CreateCurrentProfileView(item, false); | |
1093 if (IsProfileChooser(view_mode_)) { | 1137 if (IsProfileChooser(view_mode_)) { |
1094 tutorial_view = CreateTutorialViewIfNeeded(item); | 1138 tutorial_view = CreateTutorialViewIfNeeded(item); |
1095 } else { | 1139 } else { |
1096 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1140 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1097 } | 1141 } |
1098 } else { | 1142 } else { |
1099 other_profiles.push_back(i); | 1143 other_profiles.push_back(i); |
1100 } | 1144 } |
1101 } | 1145 } |
1102 | 1146 |
(...skipping 16 matching lines...) Expand all Loading... | |
1119 | 1163 |
1120 if (!IsProfileChooser(view_mode_)) { | 1164 if (!IsProfileChooser(view_mode_)) { |
1121 DCHECK(current_profile_accounts); | 1165 DCHECK(current_profile_accounts); |
1122 layout->StartRow(0, 0); | 1166 layout->StartRow(0, 0); |
1123 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1167 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1124 layout->StartRow(1, 0); | 1168 layout->StartRow(1, 0); |
1125 layout->AddView(current_profile_accounts); | 1169 layout->AddView(current_profile_accounts); |
1126 } | 1170 } |
1127 | 1171 |
1128 if (browser_->profile()->IsSupervised()) { | 1172 if (browser_->profile()->IsSupervised()) { |
1129 layout->StartRow(0, 0); | 1173 if (!switches::IsMaterialDesignUserMenu()) { |
1130 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1174 layout->StartRow(0, 0); |
1175 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
1176 } | |
1131 layout->StartRow(1, 0); | 1177 layout->StartRow(1, 0); |
1132 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1178 layout->AddView(CreateSupervisedUserDisclaimerView()); |
1133 } | 1179 } |
1134 | 1180 |
1135 layout->StartRow(0, 0); | 1181 layout->StartRow(0, 0); |
1136 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1182 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1137 | 1183 |
1138 if (option_buttons_view) { | 1184 if (option_buttons_view) { |
1139 layout->StartRow(0, 0); | 1185 layout->StartRow(0, 0); |
1140 layout->AddView(option_buttons_view); | 1186 layout->AddView(option_buttons_view); |
(...skipping 11 matching lines...) Expand all Loading... | |
1152 } | 1198 } |
1153 } | 1199 } |
1154 | 1200 |
1155 layout->StartRow(1, 0); | 1201 layout->StartRow(1, 0); |
1156 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1202 layout->AddView(CreateOtherProfilesView(other_profiles)); |
1157 } | 1203 } |
1158 | 1204 |
1159 views::View* ProfileChooserView::CreateProfileChooserView( | 1205 views::View* ProfileChooserView::CreateProfileChooserView( |
1160 AvatarMenu* avatar_menu) { | 1206 AvatarMenu* avatar_menu) { |
1161 views::View* view = new views::View(); | 1207 views::View* view = new views::View(); |
1162 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1208 views::GridLayout* layout = |
1209 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1163 | 1210 |
1164 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1211 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
1165 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1212 PopulateMinimalProfileChooserView(layout, avatar_menu); |
1166 // The user is using right-click switching, no need to tell them about it. | 1213 // The user is using right-click switching, no need to tell them about it. |
1167 PrefService* local_state = g_browser_process->local_state(); | 1214 PrefService* local_state = g_browser_process->local_state(); |
1168 local_state->SetBoolean( | 1215 local_state->SetBoolean( |
1169 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1216 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1170 } else { | 1217 } else { |
1171 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1218 PopulateCompleteProfileChooserView(layout, avatar_menu); |
1172 } | 1219 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1227 const base::string16& button_text, | 1274 const base::string16& button_text, |
1228 bool stack_button, | 1275 bool stack_button, |
1229 views::Link** link, | 1276 views::Link** link, |
1230 views::LabelButton** button, | 1277 views::LabelButton** button, |
1231 views::ImageButton** close_button) { | 1278 views::ImageButton** close_button) { |
1232 tutorial_mode_ = tutorial_mode; | 1279 tutorial_mode_ = tutorial_mode; |
1233 | 1280 |
1234 views::View* view = new views::View(); | 1281 views::View* view = new views::View(); |
1235 view->set_background(views::Background::CreateSolidBackground( | 1282 view->set_background(views::Background::CreateSolidBackground( |
1236 profiles::kAvatarTutorialBackgroundColor)); | 1283 profiles::kAvatarTutorialBackgroundColor)); |
1237 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1284 views::GridLayout* layout = CreateSingleColumnLayout( |
1238 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1285 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1239 // Creates a second column set for buttons and links. | 1286 // Creates a second column set for buttons and links. |
1240 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1287 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
1241 button_columns->AddColumn(views::GridLayout::LEADING, | 1288 button_columns->AddColumn(views::GridLayout::LEADING, |
1242 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1289 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1243 button_columns->AddPaddingColumn( | 1290 button_columns->AddPaddingColumn( |
1244 1, views::kUnrelatedControlHorizontalSpacing); | 1291 1, views::kUnrelatedControlHorizontalSpacing); |
1245 button_columns->AddColumn(views::GridLayout::TRAILING, | 1292 button_columns->AddColumn(views::GridLayout::TRAILING, |
1246 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1293 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1247 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1294 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1248 views::kButtonHEdgeMarginNew, | 1295 views::kButtonHEdgeMarginNew, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 layout->SkipColumns(1); | 1377 layout->SkipColumns(1); |
1331 } | 1378 } |
1332 | 1379 |
1333 return view; | 1380 return view; |
1334 } | 1381 } |
1335 | 1382 |
1336 views::View* ProfileChooserView::CreateCurrentProfileView( | 1383 views::View* ProfileChooserView::CreateCurrentProfileView( |
1337 const AvatarMenu::Item& avatar_item, | 1384 const AvatarMenu::Item& avatar_item, |
1338 bool is_guest) { | 1385 bool is_guest) { |
1339 views::View* view = new views::View(); | 1386 views::View* view = new views::View(); |
1340 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1387 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
1341 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1388 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
1342 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1389 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1343 views::kButtonHEdgeMarginNew, | 1390 views::kButtonHEdgeMarginNew, |
1344 views::kUnrelatedControlVerticalSpacing, | 1391 views::kUnrelatedControlVerticalSpacing, |
1345 views::kButtonHEdgeMarginNew); | 1392 views::kButtonHEdgeMarginNew); |
1346 | 1393 |
1347 // Profile icon, centered. | 1394 // Profile icon, centered. |
1348 int x_offset = (column_width - kLargeImageSide) / 2; | 1395 int x_offset = (column_width - kLargeImageSide) / 2; |
1349 current_profile_photo_ = new EditableProfilePhoto( | 1396 current_profile_photo_ = new EditableProfilePhoto( |
1350 this, avatar_item.icon, !is_guest, | 1397 this, avatar_item.icon, !is_guest, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1443 layout->StartRow(1, 0); | 1490 layout->StartRow(1, 0); |
1444 layout->AddView(signin_current_profile_link_); | 1491 layout->AddView(signin_current_profile_link_); |
1445 content::RecordAction( | 1492 content::RecordAction( |
1446 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1493 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
1447 } | 1494 } |
1448 } | 1495 } |
1449 | 1496 |
1450 return view; | 1497 return view; |
1451 } | 1498 } |
1452 | 1499 |
1500 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
1501 const AvatarMenu::Item& avatar_item, | |
1502 bool is_guest) { | |
1503 views::View* view = new views::View(); | |
1504 int column_width = | |
Evan Stade
2016/06/13 23:14:41
are you sure the box layout can't grow wider than
Jane
2016/06/14 14:47:21
I'm only using column_width as the width for profi
Evan Stade
2016/06/14 15:16:26
what sets the width of the box layout then?
Jane
2016/06/14 21:39:57
I thought the width of the box layout would be det
Evan Stade
2016/06/16 21:56:34
Well, that would set its preferred size. But in th
Jane
2016/06/17 19:52:23
Done. Removed column_width.
| |
1505 GetFixedMenuWidth() - 2 * kMaterialMenuHorizontalEdgeMargin; | |
1506 view->SetLayoutManager(new views::BoxLayout( | |
1507 views::BoxLayout::kVertical, | |
1508 kMaterialMenuHorizontalEdgeMargin, | |
1509 views::kRelatedControlVerticalSpacing, | |
1510 views::kRelatedControlVerticalSpacing)); | |
1511 | |
1512 // Profile picture, left-aligned. | |
1513 const int profile_bar_height = 56; | |
1514 current_profile_photo_ = new EditableProfilePhoto( | |
1515 this, avatar_item.icon, !is_guest, | |
1516 gfx::Rect(0, (profile_bar_height - kMediumImageSide) / 2, | |
1517 kMediumImageSide, kMediumImageSide)); | |
Evan Stade
2016/06/13 23:14:40
Yyou're doing layout at construction time, which i
Jane
2016/06/14 14:47:21
This is a very good suggestion. I thought about us
Evan Stade
2016/06/14 15:16:26
When I said "or overriding Layout()", I guess I sh
Jane
2016/06/14 21:39:57
Done. I added a couple of containers to the view,
Evan Stade
2016/06/16 21:56:33
SizedContainers are just a different way of hardco
Jane
2016/06/17 19:52:23
Point taken. See edits/comments in the newest patc
| |
1518 SizedContainer* profile_container = | |
1519 new SizedContainer(gfx::Size(column_width, profile_bar_height)); | |
1520 profile_container->AddChildView(current_profile_photo_); | |
1521 | |
1522 // Add supervised badge for supervised profile. | |
1523 if (browser_->profile()->IsSupervised()) { | |
1524 const int badge_spacing = 4; | |
1525 views::ImageView* supervised_icon = new views::ImageView(); | |
1526 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); | |
1527 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | |
1528 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | |
1529 supervised_icon->SetBounds( | |
1530 parent_bounds.right() - preferred_size.width() + badge_spacing, | |
1531 parent_bounds.bottom() - preferred_size.height() + badge_spacing, | |
1532 preferred_size.width(), preferred_size.height()); | |
1533 profile_container->AddChildView(supervised_icon); | |
1534 } | |
1535 | |
1536 // Profile name, left-aligned to the right of profile icon. | |
1537 bool editing_allowed = | |
1538 !is_guest && !browser_->profile()->IsLegacySupervised(); | |
1539 current_profile_name_ = new EditableProfileName( | |
1540 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
1541 editing_allowed); | |
1542 gfx::Rect photo_bounds = current_profile_photo_->bounds(); | |
1543 const int textfield_left_margin = | |
1544 kProfileHorizontalSpacing - | |
1545 (editing_allowed ? kTextfieldLabelHorizontalSpacing : 0); | |
1546 current_profile_name_->SetBounds( | |
1547 photo_bounds.width() + textfield_left_margin, | |
1548 views::kRelatedControlVerticalSpacing, | |
1549 profile_container->GetPreferredSize().width() - photo_bounds.width() - | |
1550 textfield_left_margin, | |
1551 profile_container->GetPreferredSize().height() / 2 - | |
1552 views::kRelatedControlVerticalSpacing); | |
1553 profile_container->AddChildView(current_profile_name_); | |
1554 | |
1555 // Center-align the avatar name if the profile is not signed in. | |
1556 if (is_guest || !avatar_item.signed_in) { | |
1557 current_profile_name_->SetY( | |
1558 (profile_container->GetPreferredSize().height() - | |
1559 current_profile_name_->height()) / | |
1560 2); | |
1561 view->AddChildView(profile_container); | |
Evan Stade
2016/06/13 23:14:40
can't you do this unconditionally?
Jane
2016/06/14 14:47:21
No, because more child views will be added to prof
Evan Stade
2016/06/14 15:16:26
Not sure I understand. Why can't you add child vie
Jane
2016/06/14 21:39:56
Done.
What I meant was more along the line of how
| |
1562 } | |
1563 | |
1564 if (is_guest) | |
1565 return view; | |
1566 | |
1567 // The available links depend on the type of profile that is active. | |
1568 if (avatar_item.signed_in) { | |
1569 // Calculate the position and size for links available for signed-in | |
1570 // profiles. | |
1571 const int x_coordinate = photo_bounds.width() + kProfileHorizontalSpacing; | |
Evan Stade
2016/06/13 23:14:40
If profile_container had a layout manager this wou
Jane
2016/06/14 14:47:21
Same as above.
| |
1572 const int y_coordinate = profile_container->GetPreferredSize().height() / 2; | |
1573 const int width = profile_container->GetPreferredSize().width() - | |
1574 photo_bounds.width() - kProfileHorizontalSpacing; | |
1575 const int height = profile_container->GetPreferredSize().height() / 2 - | |
1576 views::kRelatedControlVerticalSpacing; | |
1577 | |
1578 if (switches::IsEnableAccountConsistency()) { | |
1579 base::string16 link_title = l10n_util::GetStringUTF16( | |
1580 IsProfileChooser(view_mode_) | |
1581 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON | |
1582 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
1583 manage_accounts_link_ = CreateLink(link_title, this); | |
1584 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1585 manage_accounts_link_->SetBounds(x_coordinate, y_coordinate, width, | |
1586 height); | |
1587 profile_container->AddChildView(manage_accounts_link_); | |
1588 } else if (HasAuthError(browser_->profile())) { | |
1589 // Badge the email address if there's an authentication error. | |
1590 auth_error_email_button_ = | |
1591 new RightAlignedIconLabelButton(this, avatar_item.username); | |
1592 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1593 auth_error_email_button_->SetImage( | |
1594 views::LabelButton::STATE_NORMAL, | |
1595 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 12, | |
1596 gfx::kChromeIconGrey)); | |
1597 auth_error_email_button_->SetFocusForPlatform(); | |
1598 auth_error_email_button_->set_request_focus_on_press(true); | |
Evan Stade
2016/06/13 23:14:40
why do you want this non-default behavior
Jane
2016/06/14 14:47:21
As mentioned before, this code is basically copied
Evan Stade
2016/06/14 15:16:26
If there are large blocks of code you're about to
Jane
2016/06/14 21:39:57
I just deleted this block instead, this is probabl
| |
1599 gfx::Insets insets = | |
1600 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | |
1601 views::Button::STYLE_TEXTBUTTON); | |
1602 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( | |
1603 insets.top(), insets.left(), insets.bottom(), insets.right())); | |
1604 auth_error_email_button_->SetBounds(x_coordinate - insets.left(), | |
1605 y_coordinate, width, height); | |
1606 profile_container->AddChildView(auth_error_email_button_); | |
1607 } else { | |
1608 views::Label* email_label = new views::Label(avatar_item.username); | |
1609 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1610 email_label->SetEnabled(false); | |
1611 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1612 email_label->SetBounds(x_coordinate, y_coordinate, width, height); | |
1613 profile_container->AddChildView(email_label); | |
1614 } | |
1615 view->AddChildView(profile_container); | |
1616 return view; | |
1617 } | |
1618 | |
1619 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
1620 browser_->profile()->GetOriginalProfile()); | |
1621 if (signin_manager->IsSigninAllowed()) { | |
1622 views::Label* promo = | |
1623 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
1624 promo->SetMultiLine(true); | |
1625 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1626 view->AddChildView(promo); | |
1627 | |
1628 signin_current_profile_link_ = | |
Evan Stade
2016/06/13 23:14:40
this is not really a link...
Jane
2016/06/14 14:47:21
Done.
Same as above, but since this code will live
| |
1629 views::MdTextButton::CreateSecondaryUiBlueButton( | |
1630 this, l10n_util::GetStringFUTF16( | |
1631 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
1632 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1633 signin_current_profile_link_->SetMinSize(gfx::Size(0, 36)); | |
Evan Stade
2016/06/13 23:14:41
here's a constant I don't understand the need for
Jane
2016/06/14 14:47:21
This was supposed to define the height of the butt
Evan Stade
2016/06/14 15:16:26
yes, i think the height should be the same as all
Jane
2016/06/14 21:39:57
I put it here because SetMinSize of LabelButton se
Evan Stade
2016/06/16 21:56:33
Yes, I do think you can/should. For example, there
Jane
2016/06/17 19:52:23
Done.
| |
1634 view->AddChildView(signin_current_profile_link_); | |
1635 content::RecordAction( | |
1636 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
1637 view->AddChildView(padding_view); | |
Evan Stade
2016/06/13 23:14:40
if you need padding under the md text button, perh
Jane
2016/06/14 14:47:21
I tried adding:
view->SetBorder(views::Border
Evan Stade
2016/06/14 15:16:26
I dunno, is there something else setting a border
Jane
2016/06/14 21:39:57
Done. It works now.
| |
1638 } | |
1639 | |
1640 return view; | |
1641 } | |
1642 | |
1453 views::View* ProfileChooserView::CreateGuestProfileView() { | 1643 views::View* ProfileChooserView::CreateGuestProfileView() { |
1454 gfx::Image guest_icon = | 1644 gfx::Image guest_icon = |
1455 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1645 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
1456 profiles::GetPlaceholderAvatarIconResourceID()); | 1646 profiles::GetPlaceholderAvatarIconResourceID()); |
1457 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1647 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
1458 guest_avatar_item.active = true; | 1648 guest_avatar_item.active = true; |
1459 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1649 guest_avatar_item.name = l10n_util::GetStringUTF16( |
1460 IDS_PROFILES_GUEST_PROFILE_NAME); | 1650 IDS_PROFILES_GUEST_PROFILE_NAME); |
1461 guest_avatar_item.signed_in = false; | 1651 guest_avatar_item.signed_in = false; |
1462 | 1652 |
1463 return CreateCurrentProfileView(guest_avatar_item, true); | 1653 return switches::IsMaterialDesignUserMenu() |
1654 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
1655 : CreateCurrentProfileView(guest_avatar_item, true); | |
1464 } | 1656 } |
1465 | 1657 |
1466 views::View* ProfileChooserView::CreateOtherProfilesView( | 1658 views::View* ProfileChooserView::CreateOtherProfilesView( |
1467 const Indexes& avatars_to_show) { | 1659 const Indexes& avatars_to_show) { |
1468 views::View* view = new views::View(); | 1660 views::View* view = new views::View(); |
1469 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1661 views::GridLayout* layout = |
1662 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1470 | 1663 |
1471 for (size_t index : avatars_to_show) { | 1664 for (size_t index : avatars_to_show) { |
1472 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1665 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
1473 const int kSmallImageSide = 32; | 1666 const int kSmallImageSide = 32; |
1474 | 1667 |
1475 // Use the low-res, small default avatars in the fast user switcher, like | 1668 // Use the low-res, small default avatars in the fast user switcher, like |
1476 // we do in the menu bar. | 1669 // we do in the menu bar. |
1477 gfx::Image item_icon; | 1670 gfx::Image item_icon; |
1478 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1671 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
1479 | 1672 |
(...skipping 10 matching lines...) Expand all Loading... | |
1490 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1683 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1491 layout->StartRow(1, 0); | 1684 layout->StartRow(1, 0); |
1492 layout->AddView(button); | 1685 layout->AddView(button); |
1493 } | 1686 } |
1494 | 1687 |
1495 return view; | 1688 return view; |
1496 } | 1689 } |
1497 | 1690 |
1498 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1691 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
1499 views::View* view = new views::View(); | 1692 views::View* view = new views::View(); |
1500 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1693 views::GridLayout* layout = |
1694 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1501 | 1695 |
1502 base::string16 text = browser_->profile()->IsGuestSession() ? | 1696 base::string16 text = browser_->profile()->IsGuestSession() ? |
1503 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1697 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1504 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1698 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
1505 if (!browser_->profile()->IsGuestSession() | 1699 if (!browser_->profile()->IsGuestSession() |
1506 && switches::IsMaterialDesignUserMenu()) { | 1700 && switches::IsMaterialDesignUserMenu()) { |
1507 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1701 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
1508 } | 1702 } |
1509 const int kIconSize = 16; | 1703 const int kIconSize = 16; |
1510 | 1704 |
(...skipping 29 matching lines...) Expand all Loading... | |
1540 gfx::kChromeIconGrey)); | 1734 gfx::kChromeIconGrey)); |
1541 layout->StartRow(1, 0); | 1735 layout->StartRow(1, 0); |
1542 layout->AddView(lock_button_); | 1736 layout->AddView(lock_button_); |
1543 } | 1737 } |
1544 return view; | 1738 return view; |
1545 } | 1739 } |
1546 | 1740 |
1547 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1741 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1548 views::View* view = new views::View(); | 1742 views::View* view = new views::View(); |
1549 views::GridLayout* layout = CreateSingleColumnLayout( | 1743 views::GridLayout* layout = CreateSingleColumnLayout( |
1550 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1744 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1551 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1745 if (switches::IsMaterialDesignUserMenu()) { |
1552 views::kButtonHEdgeMarginNew, | 1746 layout->SetInsets(0, |
1553 views::kRelatedControlVerticalSpacing, | 1747 kMaterialMenuHorizontalEdgeMargin, |
1554 views::kButtonHEdgeMarginNew); | 1748 kMaterialMenuVerticalEdgeMargin, |
1749 kMaterialMenuHorizontalEdgeMargin); | |
1750 } else { | |
1751 layout->SetInsets( | |
1752 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, | |
1753 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); | |
1754 } | |
1755 | |
1555 views::Label* disclaimer = new views::Label( | 1756 views::Label* disclaimer = new views::Label( |
1556 avatar_menu_->GetSupervisedUserInformation()); | 1757 avatar_menu_->GetSupervisedUserInformation()); |
1557 disclaimer->SetMultiLine(true); | 1758 disclaimer->SetMultiLine(true); |
1558 disclaimer->SetAllowCharacterBreak(true); | 1759 disclaimer->SetAllowCharacterBreak(true); |
1559 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1760 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1560 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1761 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1561 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1762 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
1562 layout->StartRow(1, 0); | 1763 layout->StartRow(1, 0); |
1563 layout->AddView(disclaimer); | 1764 layout->AddView(disclaimer); |
1564 | 1765 |
1565 return view; | 1766 return view; |
1566 } | 1767 } |
1567 | 1768 |
1568 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1769 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
1569 const AvatarMenu::Item& avatar_item) { | 1770 const AvatarMenu::Item& avatar_item) { |
1570 DCHECK(avatar_item.signed_in); | 1771 DCHECK(avatar_item.signed_in); |
1571 views::View* view = new views::View(); | 1772 views::View* view = new views::View(); |
1572 view->set_background(views::Background::CreateSolidBackground( | 1773 view->set_background(views::Background::CreateSolidBackground( |
1573 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1774 profiles::kAvatarBubbleAccountsBackgroundColor)); |
1574 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1775 views::GridLayout* layout = |
1776 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1575 | 1777 |
1576 Profile* profile = browser_->profile(); | 1778 Profile* profile = browser_->profile(); |
1577 std::string primary_account = | 1779 std::string primary_account = |
1578 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1780 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
1579 DCHECK(!primary_account.empty()); | 1781 DCHECK(!primary_account.empty()); |
1580 std::vector<std::string>accounts = | 1782 std::vector<std::string>accounts = |
1581 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1783 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
1582 | 1784 |
1583 // Get state of authentication error, if any. | 1785 // Get state of authentication error, if any. |
1584 std::string error_account_id = GetAuthErrorAccountId(profile); | 1786 std::string error_account_id = GetAuthErrorAccountId(profile); |
1585 | 1787 |
1586 // The primary account should always be listed first. | 1788 // The primary account should always be listed first. |
1587 // TODO(rogerta): we still need to further differentiate the primary account | 1789 // 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: | 1790 // from the others in the UI, so more work is likely required here: |
1589 // crbug.com/311124. | 1791 // crbug.com/311124. |
1590 CreateAccountButton(layout, primary_account, true, | 1792 CreateAccountButton(layout, primary_account, true, |
1591 error_account_id == primary_account, kFixedMenuWidth); | 1793 error_account_id == primary_account, GetFixedMenuWidth()); |
1592 for (size_t i = 0; i < accounts.size(); ++i) | 1794 for (size_t i = 0; i < accounts.size(); ++i) |
1593 CreateAccountButton(layout, accounts[i], false, | 1795 CreateAccountButton(layout, accounts[i], false, |
1594 error_account_id == accounts[i], kFixedMenuWidth); | 1796 error_account_id == accounts[i], GetFixedMenuWidth()); |
1595 | 1797 |
1596 if (!profile->IsSupervised()) { | 1798 if (!profile->IsSupervised()) { |
1597 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1799 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1598 | 1800 |
1599 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1801 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
1600 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1802 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
1601 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1803 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
1602 0, views::kButtonVEdgeMarginNew, | 1804 0, views::kButtonVEdgeMarginNew, |
1603 views::kRelatedControlVerticalSpacing, 0)); | 1805 views::kRelatedControlVerticalSpacing, 0)); |
1604 layout->StartRow(1, 0); | 1806 layout->StartRow(1, 0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2096 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1895 IncognitoModePrefs::DISABLED; | 2097 IncognitoModePrefs::DISABLED; |
1896 return incognito_available && !browser_->profile()->IsGuestSession(); | 2098 return incognito_available && !browser_->profile()->IsGuestSession(); |
1897 } | 2099 } |
1898 | 2100 |
1899 void ProfileChooserView::PostActionPerformed( | 2101 void ProfileChooserView::PostActionPerformed( |
1900 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2102 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1901 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2103 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1902 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2104 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1903 } | 2105 } |
OLD | NEW |