| 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/app/vector_icons/vector_icons.h" | 10 #include "chrome/app/vector_icons/vector_icons.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include "ui/views/controls/button/blue_button.h" | 74 #include "ui/views/controls/button/blue_button.h" |
| 75 #include "ui/views/controls/button/image_button.h" | 75 #include "ui/views/controls/button/image_button.h" |
| 76 #include "ui/views/controls/button/label_button.h" | 76 #include "ui/views/controls/button/label_button.h" |
| 77 #include "ui/views/controls/button/label_button_border.h" | 77 #include "ui/views/controls/button/label_button_border.h" |
| 78 #include "ui/views/controls/button/md_text_button.h" | 78 #include "ui/views/controls/button/md_text_button.h" |
| 79 #include "ui/views/controls/button/menu_button.h" | 79 #include "ui/views/controls/button/menu_button.h" |
| 80 #include "ui/views/controls/label.h" | 80 #include "ui/views/controls/label.h" |
| 81 #include "ui/views/controls/link.h" | 81 #include "ui/views/controls/link.h" |
| 82 #include "ui/views/controls/separator.h" | 82 #include "ui/views/controls/separator.h" |
| 83 #include "ui/views/controls/styled_label.h" | 83 #include "ui/views/controls/styled_label.h" |
| 84 #include "ui/views/controls/textfield/textfield.h" | |
| 85 #include "ui/views/controls/webview/webview.h" | 84 #include "ui/views/controls/webview/webview.h" |
| 86 #include "ui/views/layout/box_layout.h" | 85 #include "ui/views/layout/box_layout.h" |
| 87 #include "ui/views/layout/fill_layout.h" | 86 #include "ui/views/layout/fill_layout.h" |
| 88 #include "ui/views/layout/grid_layout.h" | 87 #include "ui/views/layout/grid_layout.h" |
| 89 #include "ui/views/layout/layout_constants.h" | 88 #include "ui/views/layout/layout_constants.h" |
| 90 #include "ui/views/widget/widget.h" | 89 #include "ui/views/widget/widget.h" |
| 91 | 90 |
| 92 namespace { | 91 namespace { |
| 93 | 92 |
| 94 // Helpers -------------------------------------------------------------------- | 93 // Helpers -------------------------------------------------------------------- |
| 95 | 94 |
| 96 const int kButtonHeight = 32; | 95 const int kButtonHeight = 32; |
| 97 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 96 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| 98 const int kFixedGaiaViewWidth = 448; | 97 const int kFixedGaiaViewWidth = 448; |
| 99 const int kFixedAccountRemovalViewWidth = 280; | 98 const int kFixedAccountRemovalViewWidth = 280; |
| 100 const int kFixedSwitchUserViewWidth = 320; | 99 const int kFixedSwitchUserViewWidth = 320; |
| 101 const int kLargeImageSide = 88; | 100 const int kImageSide = 40; |
| 102 const int kMdImageSide = 40; | 101 const int kProfileBadgeSize = 24; |
| 102 const int kFixedMenuWidth = 240; |
| 103 const int kSupervisedIconBadgeSize = 22; |
| 104 |
| 105 // The space between the right/bottom edge of the profile badge and the |
| 106 // right/bottom edge of the profile icon. |
| 107 const int kBadgeSpacing = 4; |
| 103 | 108 |
| 104 // Spacing between the edge of the material design user menu and the | 109 // Spacing between the edge of the material design user menu and the |
| 105 // top/bottom or left/right of the menu items. | 110 // top/bottom or left/right of the menu items. |
| 106 const int kMaterialMenuEdgeMargin = 16; | 111 const int kMenuEdgeMargin = 16; |
| 107 | 112 |
| 108 const int kVerticalSpacing = 16; | 113 const int kVerticalSpacing = 16; |
| 109 | 114 |
| 110 const int kTitleViewNativeWidgetOffset = 8; | 115 const int kTitleViewNativeWidgetOffset = 8; |
| 111 | 116 |
| 112 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 117 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| 113 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 118 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
| 114 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 119 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 115 } | 120 } |
| 116 | 121 |
| 117 int GetFixedMenuWidth() { | |
| 118 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
| 119 } | |
| 120 | |
| 121 int GetProfileBadgeSize() { | |
| 122 return switches::IsMaterialDesignUserMenu() ? 24 : 30; | |
| 123 } | |
| 124 | |
| 125 // DEPRECATED: New user menu components should use views::BoxLayout instead. | 122 // DEPRECATED: New user menu components should use views::BoxLayout instead. |
| 126 // Creates a GridLayout with a single column. This ensures that all the child | 123 // Creates a GridLayout with a single column. This ensures that all the child |
| 127 // views added get auto-expanded to fill the full width of the bubble. | 124 // views added get auto-expanded to fill the full width of the bubble. |
| 128 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 125 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
| 129 views::GridLayout* layout = new views::GridLayout(view); | 126 views::GridLayout* layout = new views::GridLayout(view); |
| 130 view->SetLayoutManager(layout); | 127 view->SetLayoutManager(layout); |
| 131 | 128 |
| 132 views::ColumnSet* columns = layout->AddColumnSet(0); | 129 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 133 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 130 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 134 views::GridLayout::FIXED, width, width); | 131 views::GridLayout::FIXED, width, width); |
| 135 return layout; | 132 return layout; |
| 136 } | 133 } |
| 137 | 134 |
| 138 views::Link* CreateLink(const base::string16& link_text, | 135 views::Link* CreateLink(const base::string16& link_text, |
| 139 views::LinkListener* listener) { | 136 views::LinkListener* listener) { |
| 140 views::Link* link_button = new views::Link(link_text); | 137 views::Link* link_button = new views::Link(link_text); |
| 141 link_button->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 138 link_button->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 142 link_button->SetUnderline(false); | 139 link_button->SetUnderline(false); |
| 143 link_button->set_listener(listener); | 140 link_button->set_listener(listener); |
| 144 return link_button; | 141 return link_button; |
| 145 } | 142 } |
| 146 | 143 |
| 147 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { | |
| 148 SkBitmap bitmap; | |
| 149 bitmap.allocPixels(SkImageInfo::MakeA8(size, size)); | |
| 150 bitmap.eraseARGB(0, 0, 0, 0); | |
| 151 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 152 } | |
| 153 | |
| 154 bool HasAuthError(Profile* profile) { | 144 bool HasAuthError(Profile* profile) { |
| 155 const SigninErrorController* error = | 145 const SigninErrorController* error = |
| 156 SigninErrorControllerFactory::GetForProfile(profile); | 146 SigninErrorControllerFactory::GetForProfile(profile); |
| 157 return error && error->HasError(); | 147 return error && error->HasError(); |
| 158 } | 148 } |
| 159 | 149 |
| 160 std::string GetAuthErrorAccountId(Profile* profile) { | 150 std::string GetAuthErrorAccountId(Profile* profile) { |
| 161 const SigninErrorController* error = | 151 const SigninErrorController* error = |
| 162 SigninErrorControllerFactory::GetForProfile(profile); | 152 SigninErrorControllerFactory::GetForProfile(profile); |
| 163 if (!error) | 153 if (!error) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 190 public: | 180 public: |
| 191 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, | 181 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, |
| 192 const base::string16& text) | 182 const base::string16& text) |
| 193 : views::LabelButton(profile_chooser_view, text), | 183 : views::LabelButton(profile_chooser_view, text), |
| 194 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 184 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 195 profile_chooser_view_(profile_chooser_view), | 185 profile_chooser_view_(profile_chooser_view), |
| 196 #endif | 186 #endif |
| 197 title_(nullptr), | 187 title_(nullptr), |
| 198 subtitle_(nullptr) { | 188 subtitle_(nullptr) { |
| 199 DCHECK(profile_chooser_view); | 189 DCHECK(profile_chooser_view); |
| 200 SetImageLabelSpacing(switches::IsMaterialDesignUserMenu() | 190 SetImageLabelSpacing(kMenuEdgeMargin - 2); |
| 201 ? (kMaterialMenuEdgeMargin - 2) | 191 SetBorder(views::CreateEmptyBorder(0, kMenuEdgeMargin, 0, kMenuEdgeMargin)); |
| 202 : views::kItemLabelSpacing); | |
| 203 const int button_margin = switches::IsMaterialDesignUserMenu() | |
| 204 ? kMaterialMenuEdgeMargin | |
| 205 : views::kButtonHEdgeMarginNew; | |
| 206 SetBorder(views::CreateEmptyBorder(0, button_margin, 0, button_margin)); | |
| 207 SetFocusForPlatform(); | 192 SetFocusForPlatform(); |
| 208 | 193 |
| 209 if (switches::IsMaterialDesignUserMenu()) { | 194 label()->SetHandlesTooltips(false); |
| 210 label()->SetHandlesTooltips(false); | |
| 211 } | |
| 212 } | 195 } |
| 213 | 196 |
| 214 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, | 197 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, |
| 215 const base::string16& text, | 198 const base::string16& text, |
| 216 const gfx::ImageSkia& icon) | 199 const gfx::ImageSkia& icon) |
| 217 : BackgroundColorHoverButton(profile_chooser_view, text) { | 200 : BackgroundColorHoverButton(profile_chooser_view, text) { |
| 218 SetMinSize(gfx::Size( | 201 SetMinSize(gfx::Size( |
| 219 icon.width(), kButtonHeight + views::kRelatedControlVerticalSpacing)); | 202 icon.width(), kButtonHeight + views::kRelatedControlVerticalSpacing)); |
| 220 SetImage(STATE_NORMAL, icon); | 203 SetImage(STATE_NORMAL, icon); |
| 221 } | 204 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 title_widget_->SetContentsView(title_view_); | 338 title_widget_->SetContentsView(title_view_); |
| 356 | 339 |
| 357 gfx::Rect bounds(title_view_->GetPreferredSize()); | 340 gfx::Rect bounds(title_view_->GetPreferredSize()); |
| 358 title_view_->SetBoundsRect(bounds); | 341 title_view_->SetBoundsRect(bounds); |
| 359 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 342 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
| 360 title_widget_->SetBounds(bounds); | 343 title_widget_->SetBounds(bounds); |
| 361 } | 344 } |
| 362 | 345 |
| 363 } // namespace | 346 } // namespace |
| 364 | 347 |
| 365 // RightAlignedIconLabelButton ------------------------------------------------- | |
| 366 | |
| 367 // A custom LabelButton that has a center-aligned text and right aligned icon. | |
| 368 // Only used in non-material-design user menu. | |
| 369 class RightAlignedIconLabelButton : public views::LabelButton { | |
| 370 public: | |
| 371 RightAlignedIconLabelButton(views::ButtonListener* listener, | |
| 372 const base::string16& text) | |
| 373 : views::LabelButton(listener, text) { | |
| 374 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | |
| 375 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 376 } | |
| 377 | |
| 378 protected: | |
| 379 void Layout() override { | |
| 380 views::LabelButton::Layout(); | |
| 381 | |
| 382 // Keep the text centered and the icon right-aligned by stretching the label | |
| 383 // to take up more of the content area and centering its contents. | |
| 384 gfx::Rect content_bounds = GetContentsBounds(); | |
| 385 gfx::Rect label_bounds = label()->bounds(); | |
| 386 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); | |
| 387 label()->SetBoundsRect(label_bounds); | |
| 388 } | |
| 389 | |
| 390 private: | |
| 391 void OnFocus() override { | |
| 392 SetState(STATE_HOVERED); | |
| 393 } | |
| 394 | |
| 395 void OnBlur() override { | |
| 396 SetState(STATE_NORMAL); | |
| 397 } | |
| 398 | |
| 399 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | |
| 400 }; | |
| 401 | |
| 402 // EditableProfilePhoto ------------------------------------------------- | 348 // EditableProfilePhoto ------------------------------------------------- |
| 403 | 349 |
| 404 const size_t kProfileBadgeWhitePadding = 2; | |
| 405 | |
| 406 // A custom Image control that shows a "change" button when moused over. | 350 // A custom Image control that shows a "change" button when moused over. |
| 407 class EditableProfilePhoto : public views::LabelButton { | 351 class EditableProfilePhoto : public views::LabelButton { |
| 408 public: | 352 public: |
| 409 EditableProfilePhoto(views::ButtonListener* listener, | 353 EditableProfilePhoto(views::ButtonListener* listener, |
| 410 const gfx::Image& icon, | 354 const gfx::Image& icon, |
| 411 bool is_editing_allowed, | 355 bool is_editing_allowed, |
| 412 Profile* profile) | 356 Profile* profile) |
| 413 : views::LabelButton(listener, base::string16()), | 357 : views::LabelButton(listener, base::string16()), |
| 414 interactive_(!switches::IsMaterialDesignUserMenu()), | |
| 415 photo_overlay_(nullptr), | 358 photo_overlay_(nullptr), |
| 416 profile_(profile) { | 359 profile_(profile) { |
| 417 gfx::Image image = profiles::GetSizedAvatarIcon( | 360 set_can_process_events_within_subtree(false); |
| 418 icon, true, icon_image_side(), icon_image_side()); | 361 gfx::Image image = |
| 362 profiles::GetSizedAvatarIcon(icon, true, kImageSide, kImageSide); |
| 419 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 363 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
| 420 SetBorder(views::NullBorder()); | 364 SetBorder(views::NullBorder()); |
| 421 if (switches::IsMaterialDesignUserMenu()) { | 365 SetMinSize(gfx::Size(GetPreferredSize().width() + kBadgeSpacing, |
| 422 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), | 366 GetPreferredSize().height() + kBadgeSpacing + |
| 423 GetPreferredSize().height() + badge_spacing() + | 367 views::kRelatedControlSmallVerticalSpacing)); |
| 424 views::kRelatedControlSmallVerticalSpacing)); | |
| 425 } else { | |
| 426 SetSize(GetPreferredSize()); | |
| 427 } | |
| 428 | 368 |
| 429 if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) { | 369 SetEnabled(false); |
| 430 SetEnabled(false); | |
| 431 return; | |
| 432 } | |
| 433 | |
| 434 set_notify_enter_exit_on_child(true); | |
| 435 | |
| 436 // Photo overlay that appears when hovering over the button. | |
| 437 photo_overlay_ = new views::ImageView(); | |
| 438 | |
| 439 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | |
| 440 photo_overlay_->set_background( | |
| 441 views::Background::CreateSolidBackground(kBackgroundColor)); | |
| 442 photo_overlay_->SetImage(gfx::CreateVectorIcon( | |
| 443 kPhotoCameraIcon, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 444 | |
| 445 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); | |
| 446 photo_overlay_->SetY(badge_spacing()); | |
| 447 photo_overlay_->SetVisible(false); | |
| 448 AddChildView(photo_overlay_); | |
| 449 } | 370 } |
| 450 | 371 |
| 451 void PaintChildren(const ui::PaintContext& context) override { | 372 void PaintChildren(const ui::PaintContext& context) override { |
| 452 { | 373 { |
| 453 // Display any children (the "change photo" overlay) as a circle. | 374 // Display any children (the "change photo" overlay) as a circle. |
| 454 ui::ClipRecorder clip_recorder(context); | 375 ui::ClipRecorder clip_recorder(context); |
| 455 gfx::Rect clip_bounds = image()->GetMirroredBounds(); | 376 gfx::Rect clip_bounds = image()->GetMirroredBounds(); |
| 456 gfx::Path clip_mask; | 377 gfx::Path clip_mask; |
| 457 clip_mask.addCircle( | 378 clip_mask.addCircle( |
| 458 clip_bounds.x() + clip_bounds.width() / 2, | 379 clip_bounds.x() + clip_bounds.width() / 2, |
| 459 clip_bounds.y() + clip_bounds.height() / 2, | 380 clip_bounds.y() + clip_bounds.height() / 2, |
| 460 clip_bounds.width() / 2); | 381 clip_bounds.width() / 2); |
| 461 clip_recorder.ClipPathWithAntiAliasing(clip_mask); | 382 clip_recorder.ClipPathWithAntiAliasing(clip_mask); |
| 462 View::PaintChildren(context); | 383 View::PaintChildren(context); |
| 463 } | 384 } |
| 464 | 385 |
| 465 ui::PaintRecorder paint_recorder( | 386 ui::PaintRecorder paint_recorder( |
| 466 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); | 387 context, gfx::Size(kProfileBadgeSize, kProfileBadgeSize)); |
| 467 gfx::Canvas* canvas = paint_recorder.canvas(); | 388 gfx::Canvas* canvas = paint_recorder.canvas(); |
| 468 if (profile_->IsSupervised()) { | 389 if (profile_->IsSupervised()) { |
| 469 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | 390 gfx::Rect bounds(0, 0, kProfileBadgeSize, kProfileBadgeSize); |
| 470 int badge_offset = | 391 int badge_offset = kImageSide + kBadgeSpacing - kProfileBadgeSize; |
| 471 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); | |
| 472 gfx::Vector2d badge_offset_vector = gfx::Vector2d( | 392 gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
| 473 GetMirroredXWithWidthInView(badge_offset, GetProfileBadgeSize()), | 393 GetMirroredXWithWidthInView(badge_offset, kProfileBadgeSize), |
| 474 badge_offset + (switches::IsMaterialDesignUserMenu() | 394 badge_offset + views::kRelatedControlSmallVerticalSpacing); |
| 475 ? views::kRelatedControlSmallVerticalSpacing | |
| 476 : 0)); | |
| 477 | 395 |
| 478 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | 396 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| 479 | 397 |
| 480 // Paint the circular background. | 398 // Paint the circular background. |
| 481 cc::PaintFlags flags; | 399 cc::PaintFlags flags; |
| 482 flags.setAntiAlias(true); | 400 flags.setAntiAlias(true); |
| 483 flags.setColor(GetNativeTheme()->GetSystemColor( | 401 flags.setColor(GetNativeTheme()->GetSystemColor( |
| 484 ui::NativeTheme::kColorId_BubbleBackground)); | 402 ui::NativeTheme::kColorId_BubbleBackground)); |
| 485 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); | 403 canvas->DrawCircle(center_point, kProfileBadgeSize / 2, flags); |
| 486 | 404 |
| 487 const gfx::VectorIcon* icon; | 405 const gfx::VectorIcon* icon = profile_->IsChild() |
| 488 int icon_size; | 406 ? &kAccountChildCircleIcon |
| 489 SkColor icon_color; | 407 : &kSupervisorAccountCircleIcon; |
| 490 if (switches::IsMaterialDesignUserMenu()) { | |
| 491 icon = profile_->IsChild() ? &kAccountChildCircleIcon | |
| 492 : &kSupervisorAccountCircleIcon; | |
| 493 icon_size = 22; | |
| 494 icon_color = gfx::kChromeIconGrey; | |
| 495 } else { | |
| 496 // Paint the light blue circle. | |
| 497 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); | |
| 498 canvas->DrawCircle( | |
| 499 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | |
| 500 flags); | |
| 501 | |
| 502 icon = | |
| 503 profile_->IsChild() ? &kAccountChildIcon : &kSupervisorAccountIcon; | |
| 504 icon_size = profile_->IsChild() ? 26 : 20; | |
| 505 icon_color = SkColorSetRGB(0, 0x66, 0xff); | |
| 506 } | |
| 507 | 408 |
| 508 // Paint the badge icon. | 409 // Paint the badge icon. |
| 509 int offset = (GetProfileBadgeSize() - icon_size) / 2; | 410 int offset = (kProfileBadgeSize - kSupervisedIconBadgeSize) / 2; |
| 510 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); | 411 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); |
| 511 gfx::PaintVectorIcon(canvas, *icon, icon_size, icon_color); | 412 gfx::PaintVectorIcon(canvas, *icon, kSupervisedIconBadgeSize, |
| 413 gfx::kChromeIconGrey); |
| 512 } | 414 } |
| 513 } | 415 } |
| 514 | 416 |
| 515 static int icon_image_side() { | |
| 516 return switches::IsMaterialDesignUserMenu() ? kMdImageSide | |
| 517 : kLargeImageSide; | |
| 518 } | |
| 519 | |
| 520 static int badge_spacing() { | |
| 521 // The space between the right/bottom edge of the profile badge and the | |
| 522 // right/bottom edge of the profile icon. | |
| 523 return switches::IsMaterialDesignUserMenu() ? 4 : 0; | |
| 524 } | |
| 525 | |
| 526 bool CanProcessEventsWithinSubtree() const override { return interactive_; } | |
| 527 | |
| 528 private: | 417 private: |
| 529 // views::CustomButton: | 418 // views::CustomButton: |
| 530 void StateChanged(ButtonState old_state) override { | 419 void StateChanged(ButtonState old_state) override { |
| 531 if (photo_overlay_) { | 420 if (photo_overlay_) { |
| 532 photo_overlay_->SetVisible( | 421 photo_overlay_->SetVisible( |
| 533 state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); | 422 state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); |
| 534 } | 423 } |
| 535 } | 424 } |
| 536 | 425 |
| 537 void OnFocus() override { | 426 void OnFocus() override { |
| 538 views::LabelButton::OnFocus(); | 427 views::LabelButton::OnFocus(); |
| 539 if (photo_overlay_) | 428 if (photo_overlay_) |
| 540 photo_overlay_->SetVisible(true); | 429 photo_overlay_->SetVisible(true); |
| 541 } | 430 } |
| 542 | 431 |
| 543 void OnBlur() override { | 432 void OnBlur() override { |
| 544 views::LabelButton::OnBlur(); | 433 views::LabelButton::OnBlur(); |
| 545 // Don't hide the overlay if it's being shown as a result of a mouseover. | 434 // Don't hide the overlay if it's being shown as a result of a mouseover. |
| 546 if (photo_overlay_ && state() != STATE_HOVERED) | 435 if (photo_overlay_ && state() != STATE_HOVERED) |
| 547 photo_overlay_->SetVisible(false); | 436 photo_overlay_->SetVisible(false); |
| 548 } | 437 } |
| 549 | 438 |
| 550 bool interactive_; | |
| 551 | |
| 552 // Image that is shown when hovering over the image button. Can be NULL if | 439 // Image that is shown when hovering over the image button. Can be NULL if |
| 553 // the photo isn't allowed to be edited (e.g. for guest profiles). | 440 // the photo isn't allowed to be edited (e.g. for guest profiles). |
| 554 views::ImageView* photo_overlay_; | 441 views::ImageView* photo_overlay_; |
| 555 | 442 |
| 556 Profile* profile_; | 443 Profile* profile_; |
| 557 | 444 |
| 558 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 445 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
| 559 }; | 446 }; |
| 560 | 447 |
| 561 // EditableProfileName ------------------------------------------------- | |
| 562 | |
| 563 // A custom text control that turns into a textfield for editing when clicked. | |
| 564 // Only used in non-material-design user menu. | |
| 565 class EditableProfileName : public views::View, | |
| 566 public views::ButtonListener { | |
| 567 public: | |
| 568 EditableProfileName(views::TextfieldController* controller, | |
| 569 const base::string16& text, | |
| 570 bool is_editing_allowed) | |
| 571 : button_(nullptr), profile_name_textfield_(nullptr) { | |
| 572 SetLayoutManager( | |
| 573 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | |
| 574 | |
| 575 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
| 576 const gfx::FontList& medium_font_list = | |
| 577 rb->GetFontList(ui::ResourceBundle::MediumFont); | |
| 578 const gfx::Insets textfield_border_insets = | |
| 579 views::Textfield().border()->GetInsets(); | |
| 580 | |
| 581 if (!is_editing_allowed) { | |
| 582 views::Label* name_label = new views::Label(text); | |
| 583 name_label->SetBorder(views::CreateEmptyBorder(textfield_border_insets)); | |
| 584 name_label->SetFontList(medium_font_list); | |
| 585 AddChildView(name_label); | |
| 586 return; | |
| 587 } | |
| 588 | |
| 589 profile_name_textfield_ = new views::Textfield(); | |
| 590 // Textfield that overlaps the button. | |
| 591 profile_name_textfield_->set_controller(controller); | |
| 592 profile_name_textfield_->SetFontList(medium_font_list); | |
| 593 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 594 profile_name_textfield_->SetVisible(false); | |
| 595 AddChildView(profile_name_textfield_); | |
| 596 | |
| 597 button_ = new RightAlignedIconLabelButton(this, text); | |
| 598 button_->SetFontListDeprecated(medium_font_list); | |
| 599 // Show an "edit" pencil icon when hovering over. In the default state, | |
| 600 // we need to create an empty placeholder of the correct size, so that | |
| 601 // the text doesn't jump around when the hovered icon appears. | |
| 602 // TODO(estade): revisit colors and press effect. | |
| 603 const int kIconSize = 16; | |
| 604 button_->SetImage(views::LabelButton::STATE_NORMAL, | |
| 605 CreateSquarePlaceholderImage(kIconSize)); | |
| 606 button_->SetImage(views::LabelButton::STATE_HOVERED, | |
| 607 gfx::CreateVectorIcon(kModeEditIcon, kIconSize, | |
| 608 SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 609 button_->SetImage(views::LabelButton::STATE_PRESSED, | |
| 610 gfx::CreateVectorIcon(kModeEditIcon, kIconSize, | |
| 611 SkColorSetRGB(0x20, 0x20, 0x20))); | |
| 612 // We need to add a left padding as well as a small top/bottom padding | |
| 613 // to the text to account for the textfield's border. | |
| 614 const int kIconTextLabelButtonSpacing = 5; | |
| 615 button_->SetBorder(views::CreateEmptyBorder( | |
| 616 textfield_border_insets + | |
| 617 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); | |
| 618 AddChildView(button_); | |
| 619 } | |
| 620 | |
| 621 views::Textfield* profile_name_textfield() { | |
| 622 return profile_name_textfield_; | |
| 623 } | |
| 624 | |
| 625 // Hide the editable textfield to show the profile name button instead. | |
| 626 void ShowReadOnlyView() { | |
| 627 button_->SetVisible(true); | |
| 628 profile_name_textfield_->SetVisible(false); | |
| 629 } | |
| 630 | |
| 631 private: | |
| 632 // views::ButtonListener: | |
| 633 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | |
| 634 button_->SetVisible(false); | |
| 635 profile_name_textfield_->SetVisible(true); | |
| 636 profile_name_textfield_->SetText(button_->GetText()); | |
| 637 profile_name_textfield_->SelectAll(false); | |
| 638 profile_name_textfield_->RequestFocus(); | |
| 639 // Re-layouts the view after swaping the controls. | |
| 640 Layout(); | |
| 641 } | |
| 642 | |
| 643 // views::LabelButton: | |
| 644 bool OnKeyReleased(const ui::KeyEvent& event) override { | |
| 645 // Override CustomButton's implementation, which presses the button when | |
| 646 // you press space and clicks it when you release space, as the space can be | |
| 647 // part of the new profile name typed in the textfield. | |
| 648 return false; | |
| 649 } | |
| 650 | |
| 651 // The label button which shows the profile name, and can handle the event to | |
| 652 // make it editable. Can be NULL if the profile name isn't allowed to be | |
| 653 // edited. | |
| 654 RightAlignedIconLabelButton* button_; | |
| 655 | |
| 656 // Textfield that is shown when editing the profile name. Can be NULL if | |
| 657 // the profile name isn't allowed to be edited (e.g. for guest profiles). | |
| 658 views::Textfield* profile_name_textfield_; | |
| 659 | |
| 660 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | |
| 661 }; | |
| 662 | |
| 663 // A title card with one back button right aligned and one label center aligned. | 448 // A title card with one back button right aligned and one label center aligned. |
| 664 class TitleCard : public views::View { | 449 class TitleCard : public views::View { |
| 665 public: | 450 public: |
| 666 TitleCard(const base::string16& message, views::ButtonListener* listener, | 451 TitleCard(const base::string16& message, views::ButtonListener* listener, |
| 667 views::ImageButton** back_button) { | 452 views::ImageButton** back_button) { |
| 668 back_button_ = CreateBackButton(listener); | 453 back_button_ = CreateBackButton(listener); |
| 669 *back_button = back_button_; | 454 *back_button = back_button_; |
| 670 | 455 |
| 671 title_label_ = new views::Label(message); | 456 title_label_ = new views::Label(message); |
| 672 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 457 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 const signin::ManageAccountsParams& manage_accounts_params, | 531 const signin::ManageAccountsParams& manage_accounts_params, |
| 747 signin_metrics::AccessPoint access_point, | 532 signin_metrics::AccessPoint access_point, |
| 748 views::View* anchor_view, | 533 views::View* anchor_view, |
| 749 Browser* browser, | 534 Browser* browser, |
| 750 bool is_source_keyboard) { | 535 bool is_source_keyboard) { |
| 751 // Don't start creating the view if it would be an empty fast user switcher. | 536 // Don't start creating the view if it would be an empty fast user switcher. |
| 752 // It has to happen here to prevent the view system from creating an empty | 537 // It has to happen here to prevent the view system from creating an empty |
| 753 // container. | 538 // container. |
| 754 // Same for material design user menu since fast profile switcher will be | 539 // Same for material design user menu since fast profile switcher will be |
| 755 // migrated to the left-click menu. | 540 // migrated to the left-click menu. |
| 756 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | 541 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) |
| 757 (!profiles::HasProfileSwitchTargets(browser->profile()) || | |
| 758 switches::IsMaterialDesignUserMenu())) { | |
| 759 return; | 542 return; |
| 760 } | |
| 761 | 543 |
| 762 if (IsShowing()) { | 544 if (IsShowing()) { |
| 763 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 545 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
| 764 profile_bubble_->tutorial_mode_ = tutorial_mode; | 546 profile_bubble_->tutorial_mode_ = tutorial_mode; |
| 765 profile_bubble_->ShowViewFromMode(view_mode); | 547 profile_bubble_->ShowViewFromMode(view_mode); |
| 766 } | 548 } |
| 767 return; | 549 return; |
| 768 } | 550 } |
| 769 | 551 |
| 770 profile_bubble_ = | 552 profile_bubble_ = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 tutorial_learn_more_link_ = nullptr; | 609 tutorial_learn_more_link_ = nullptr; |
| 828 sync_error_signin_button_ = nullptr; | 610 sync_error_signin_button_ = nullptr; |
| 829 sync_error_passphrase_button_ = nullptr; | 611 sync_error_passphrase_button_ = nullptr; |
| 830 sync_error_upgrade_button_ = nullptr; | 612 sync_error_upgrade_button_ = nullptr; |
| 831 sync_error_signin_again_button_ = nullptr; | 613 sync_error_signin_again_button_ = nullptr; |
| 832 sync_error_signout_button_ = nullptr; | 614 sync_error_signout_button_ = nullptr; |
| 833 manage_accounts_link_ = nullptr; | 615 manage_accounts_link_ = nullptr; |
| 834 manage_accounts_button_ = nullptr; | 616 manage_accounts_button_ = nullptr; |
| 835 signin_current_profile_button_ = nullptr; | 617 signin_current_profile_button_ = nullptr; |
| 836 auth_error_email_button_ = nullptr; | 618 auth_error_email_button_ = nullptr; |
| 837 current_profile_photo_ = nullptr; | |
| 838 current_profile_name_ = nullptr; | |
| 839 current_profile_card_ = nullptr; | 619 current_profile_card_ = nullptr; |
| 840 first_profile_button_ = nullptr; | 620 first_profile_button_ = nullptr; |
| 841 guest_profile_button_ = nullptr; | 621 guest_profile_button_ = nullptr; |
| 842 users_button_ = nullptr; | 622 users_button_ = nullptr; |
| 843 go_incognito_button_ = nullptr; | 623 go_incognito_button_ = nullptr; |
| 844 lock_button_ = nullptr; | 624 lock_button_ = nullptr; |
| 845 close_all_windows_button_ = nullptr; | 625 close_all_windows_button_ = nullptr; |
| 846 add_account_link_ = nullptr; | 626 add_account_link_ = nullptr; |
| 847 gaia_signin_cancel_button_ = nullptr; | 627 gaia_signin_cancel_button_ = nullptr; |
| 848 remove_account_button_ = nullptr; | 628 remove_account_button_ = nullptr; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 break; | 753 break; |
| 974 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 754 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
| 975 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 755 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
| 976 sub_view = CreateSwitchUserView(); | 756 sub_view = CreateSwitchUserView(); |
| 977 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 757 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 978 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 758 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
| 979 break; | 759 break; |
| 980 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 760 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
| 981 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 761 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
| 982 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 762 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
| 983 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); | 763 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
| 984 sub_view = CreateProfileChooserView(avatar_menu); | 764 sub_view = CreateProfileChooserView(avatar_menu); |
| 985 break; | 765 break; |
| 986 } | 766 } |
| 987 // Clears tutorial mode for all non-profile-chooser views. | 767 // Clears tutorial mode for all non-profile-chooser views. |
| 988 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 768 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
| 989 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 769 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
| 990 | 770 |
| 991 layout->StartRow(1, 0); | 771 layout->StartRow(1, 0); |
| 992 layout->AddView(sub_view); | 772 layout->AddView(sub_view); |
| 993 Layout(); | 773 Layout(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 } else if (sender == gaia_signin_cancel_button_) { | 897 } else if (sender == gaia_signin_cancel_button_) { |
| 1118 // The account management view is only available with the | 898 // The account management view is only available with the |
| 1119 // --enable-account-consistency flag. | 899 // --enable-account-consistency flag. |
| 1120 bool account_management_available = | 900 bool account_management_available = |
| 1121 SigninManagerFactory::GetForProfile(browser_->profile())-> | 901 SigninManagerFactory::GetForProfile(browser_->profile())-> |
| 1122 IsAuthenticated() && | 902 IsAuthenticated() && |
| 1123 switches::IsEnableAccountConsistency(); | 903 switches::IsEnableAccountConsistency(); |
| 1124 ShowViewFromMode(account_management_available ? | 904 ShowViewFromMode(account_management_available ? |
| 1125 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 905 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
| 1126 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 906 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
| 1127 } else if (sender == current_profile_photo_) { | |
| 1128 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | |
| 1129 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | |
| 1130 } else if (sender == current_profile_card_) { | 907 } else if (sender == current_profile_card_) { |
| 1131 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 908 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| 1132 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 909 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| 1133 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); | 910 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); |
| 1134 } else if (sender == manage_accounts_button_) { | 911 } else if (sender == manage_accounts_button_) { |
| 1135 // This button can either mean show/hide the account management view, | 912 // This button can either mean show/hide the account management view, |
| 1136 // depending on which view it is displayed. | 913 // depending on which view it is displayed. |
| 1137 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT | 914 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT |
| 1138 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER | 915 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER |
| 1139 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | 916 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | 996 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
| 1220 } | 997 } |
| 1221 } | 998 } |
| 1222 | 999 |
| 1223 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, | 1000 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, |
| 1224 const gfx::Range& range, | 1001 const gfx::Range& range, |
| 1225 int event_flags) { | 1002 int event_flags) { |
| 1226 chrome::ShowSettings(browser_); | 1003 chrome::ShowSettings(browser_); |
| 1227 } | 1004 } |
| 1228 | 1005 |
| 1229 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, | |
| 1230 const ui::KeyEvent& key_event) { | |
| 1231 if (key_event.type() != ui::ET_KEY_PRESSED) | |
| 1232 return false; | |
| 1233 | |
| 1234 views::Textfield* name_textfield = | |
| 1235 current_profile_name_->profile_name_textfield(); | |
| 1236 DCHECK(sender == name_textfield); | |
| 1237 | |
| 1238 if (key_event.key_code() == ui::VKEY_RETURN || | |
| 1239 key_event.key_code() == ui::VKEY_TAB) { | |
| 1240 // Pressing Tab/Enter commits the new profile name, unless it's empty. | |
| 1241 base::string16 new_profile_name = name_textfield->text(); | |
| 1242 base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name); | |
| 1243 if (new_profile_name.empty()) | |
| 1244 return true; | |
| 1245 | |
| 1246 const AvatarMenu::Item& active_item = avatar_menu_->GetItemAt( | |
| 1247 avatar_menu_->GetActiveProfileIndex()); | |
| 1248 Profile* profile = g_browser_process->profile_manager()->GetProfile( | |
| 1249 active_item.profile_path); | |
| 1250 DCHECK(profile); | |
| 1251 | |
| 1252 if (profile->IsLegacySupervised()) | |
| 1253 return true; | |
| 1254 | |
| 1255 profiles::UpdateProfileName(profile, new_profile_name); | |
| 1256 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); | |
| 1257 current_profile_name_->ShowReadOnlyView(); | |
| 1258 return true; | |
| 1259 } | |
| 1260 return false; | |
| 1261 } | |
| 1262 | |
| 1263 void ProfileChooserView::PopulateCompleteProfileChooserView( | 1006 void ProfileChooserView::PopulateCompleteProfileChooserView( |
| 1264 views::GridLayout* layout, | 1007 views::GridLayout* layout, |
| 1265 AvatarMenu* avatar_menu) { | 1008 AvatarMenu* avatar_menu) { |
| 1266 // Separate items into active and alternatives. | 1009 // Separate items into active and alternatives. |
| 1267 Indexes other_profiles; | 1010 Indexes other_profiles; |
| 1268 views::View* tutorial_view = NULL; | 1011 views::View* tutorial_view = NULL; |
| 1269 views::View* sync_error_view = NULL; | 1012 views::View* sync_error_view = NULL; |
| 1270 views::View* current_profile_view = NULL; | 1013 views::View* current_profile_view = NULL; |
| 1271 views::View* current_profile_accounts = NULL; | 1014 views::View* current_profile_accounts = NULL; |
| 1272 views::View* option_buttons_view = NULL; | 1015 views::View* option_buttons_view = NULL; |
| 1273 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1016 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1274 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1017 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1275 if (item.active) { | 1018 if (item.active) { |
| 1276 option_buttons_view = CreateOptionsView( | 1019 option_buttons_view = CreateOptionsView( |
| 1277 item.signed_in && profiles::IsLockAvailable(browser_->profile()), | 1020 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
| 1278 avatar_menu); | 1021 avatar_menu); |
| 1279 current_profile_view = | 1022 current_profile_view = CreateCurrentProfileView(item, false); |
| 1280 switches::IsMaterialDesignUserMenu() | 1023 if (!IsProfileChooser(view_mode_)) |
| 1281 ? CreateMaterialDesignCurrentProfileView(item, false) | |
| 1282 : CreateCurrentProfileView(item, false); | |
| 1283 if (IsProfileChooser(view_mode_)) { | |
| 1284 if (!switches::IsMaterialDesignUserMenu()) | |
| 1285 tutorial_view = CreateTutorialViewIfNeeded(item); | |
| 1286 } else { | |
| 1287 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1024 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
| 1288 } | 1025 sync_error_view = CreateSyncErrorViewIfNeeded(); |
| 1289 if (switches::IsMaterialDesignUserMenu()) | |
| 1290 sync_error_view = CreateSyncErrorViewIfNeeded(); | |
| 1291 } else { | 1026 } else { |
| 1292 other_profiles.push_back(i); | 1027 other_profiles.push_back(i); |
| 1293 } | 1028 } |
| 1294 } | 1029 } |
| 1295 | 1030 |
| 1296 if (tutorial_view) { | 1031 if (tutorial_view) { |
| 1297 // TODO(mlerman): update UMA stats for the new tutorial. | 1032 // TODO(mlerman): update UMA stats for the new tutorial. |
| 1298 layout->StartRow(1, 0); | 1033 layout->StartRow(1, 0); |
| 1299 layout->AddView(tutorial_view); | 1034 layout->AddView(tutorial_view); |
| 1300 } else { | 1035 } else { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1319 | 1054 |
| 1320 if (!IsProfileChooser(view_mode_)) { | 1055 if (!IsProfileChooser(view_mode_)) { |
| 1321 DCHECK(current_profile_accounts); | 1056 DCHECK(current_profile_accounts); |
| 1322 layout->StartRow(0, 0); | 1057 layout->StartRow(0, 0); |
| 1323 layout->AddView(new views::Separator()); | 1058 layout->AddView(new views::Separator()); |
| 1324 layout->StartRow(1, 0); | 1059 layout->StartRow(1, 0); |
| 1325 layout->AddView(current_profile_accounts); | 1060 layout->AddView(current_profile_accounts); |
| 1326 } | 1061 } |
| 1327 | 1062 |
| 1328 if (browser_->profile()->IsSupervised()) { | 1063 if (browser_->profile()->IsSupervised()) { |
| 1329 if (!switches::IsMaterialDesignUserMenu()) { | |
| 1330 layout->StartRow(0, 0); | |
| 1331 layout->AddView(new views::Separator()); | |
| 1332 } | |
| 1333 layout->StartRow(1, 0); | 1064 layout->StartRow(1, 0); |
| 1334 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1065 layout->AddView(CreateSupervisedUserDisclaimerView()); |
| 1335 } | 1066 } |
| 1336 | 1067 |
| 1337 layout->StartRow(0, 0); | 1068 layout->StartRow(0, 0); |
| 1338 layout->AddView(new views::Separator()); | 1069 layout->AddView(new views::Separator()); |
| 1339 | 1070 |
| 1340 if (option_buttons_view) { | 1071 if (option_buttons_view) { |
| 1341 layout->StartRow(0, 0); | 1072 layout->StartRow(0, 0); |
| 1342 layout->AddView(option_buttons_view); | 1073 layout->AddView(option_buttons_view); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1354 } | 1085 } |
| 1355 } | 1086 } |
| 1356 | 1087 |
| 1357 layout->StartRow(1, 0); | 1088 layout->StartRow(1, 0); |
| 1358 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1089 layout->AddView(CreateOtherProfilesView(other_profiles)); |
| 1359 } | 1090 } |
| 1360 | 1091 |
| 1361 views::View* ProfileChooserView::CreateProfileChooserView( | 1092 views::View* ProfileChooserView::CreateProfileChooserView( |
| 1362 AvatarMenu* avatar_menu) { | 1093 AvatarMenu* avatar_menu) { |
| 1363 views::View* view = new views::View(); | 1094 views::View* view = new views::View(); |
| 1364 views::GridLayout* layout = | 1095 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 1365 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1366 | 1096 |
| 1367 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1097 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
| 1368 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1098 PopulateMinimalProfileChooserView(layout, avatar_menu); |
| 1369 // The user is using right-click switching, no need to tell them about it. | 1099 // The user is using right-click switching, no need to tell them about it. |
| 1370 PrefService* local_state = g_browser_process->local_state(); | 1100 PrefService* local_state = g_browser_process->local_state(); |
| 1371 local_state->SetBoolean( | 1101 local_state->SetBoolean( |
| 1372 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1102 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
| 1373 } else { | 1103 } else { |
| 1374 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1104 PopulateCompleteProfileChooserView(layout, avatar_menu); |
| 1375 } | 1105 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 bool stack_button, | 1161 bool stack_button, |
| 1432 views::Link** link, | 1162 views::Link** link, |
| 1433 views::LabelButton** button, | 1163 views::LabelButton** button, |
| 1434 views::ImageButton** close_button) { | 1164 views::ImageButton** close_button) { |
| 1435 tutorial_mode_ = tutorial_mode; | 1165 tutorial_mode_ = tutorial_mode; |
| 1436 | 1166 |
| 1437 views::View* view = new views::View(); | 1167 views::View* view = new views::View(); |
| 1438 view->set_background(views::Background::CreateSolidBackground( | 1168 view->set_background(views::Background::CreateSolidBackground( |
| 1439 profiles::kAvatarTutorialBackgroundColor)); | 1169 profiles::kAvatarTutorialBackgroundColor)); |
| 1440 views::GridLayout* layout = CreateSingleColumnLayout( | 1170 views::GridLayout* layout = CreateSingleColumnLayout( |
| 1441 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); | 1171 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
| 1442 // Creates a second column set for buttons and links. | 1172 // Creates a second column set for buttons and links. |
| 1443 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1173 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
| 1444 button_columns->AddColumn(views::GridLayout::LEADING, | 1174 button_columns->AddColumn(views::GridLayout::LEADING, |
| 1445 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1175 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 1446 button_columns->AddPaddingColumn( | 1176 button_columns->AddPaddingColumn( |
| 1447 1, views::kUnrelatedControlHorizontalSpacing); | 1177 1, views::kUnrelatedControlHorizontalSpacing); |
| 1448 button_columns->AddColumn(views::GridLayout::TRAILING, | 1178 button_columns->AddColumn(views::GridLayout::TRAILING, |
| 1449 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1179 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 1450 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1180 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 1451 views::kButtonHEdgeMarginNew, | 1181 views::kButtonHEdgeMarginNew, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 break; | 1293 break; |
| 1564 case sync_ui_util::NO_SYNC_ERROR: | 1294 case sync_ui_util::NO_SYNC_ERROR: |
| 1565 return nullptr; | 1295 return nullptr; |
| 1566 default: | 1296 default: |
| 1567 NOTREACHED(); | 1297 NOTREACHED(); |
| 1568 } | 1298 } |
| 1569 | 1299 |
| 1570 // Sets an overall horizontal layout. | 1300 // Sets an overall horizontal layout. |
| 1571 views::View* view = new views::View(); | 1301 views::View* view = new views::View(); |
| 1572 views::BoxLayout* layout = new views::BoxLayout( | 1302 views::BoxLayout* layout = new views::BoxLayout( |
| 1573 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, | 1303 views::BoxLayout::kHorizontal, kMenuEdgeMargin, kMenuEdgeMargin, |
| 1574 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); | 1304 views::kUnrelatedControlHorizontalSpacing); |
| 1575 layout->set_cross_axis_alignment( | 1305 layout->set_cross_axis_alignment( |
| 1576 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 1306 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 1577 view->SetLayoutManager(layout); | 1307 view->SetLayoutManager(layout); |
| 1578 | 1308 |
| 1579 // Adds the sync problem icon. | 1309 // Adds the sync problem icon. |
| 1580 views::ImageView* sync_problem_icon = new views::ImageView(); | 1310 views::ImageView* sync_problem_icon = new views::ImageView(); |
| 1581 sync_problem_icon->SetImage( | 1311 sync_problem_icon->SetImage( |
| 1582 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700)); | 1312 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700)); |
| 1583 view->AddChildView(sync_problem_icon); | 1313 view->AddChildView(sync_problem_icon); |
| 1584 | 1314 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 } | 1353 } |
| 1624 | 1354 |
| 1625 view->AddChildView(vertical_view); | 1355 view->AddChildView(vertical_view); |
| 1626 return view; | 1356 return view; |
| 1627 } | 1357 } |
| 1628 | 1358 |
| 1629 views::View* ProfileChooserView::CreateCurrentProfileView( | 1359 views::View* ProfileChooserView::CreateCurrentProfileView( |
| 1630 const AvatarMenu::Item& avatar_item, | 1360 const AvatarMenu::Item& avatar_item, |
| 1631 bool is_guest) { | 1361 bool is_guest) { |
| 1632 views::View* view = new views::View(); | 1362 views::View* view = new views::View(); |
| 1633 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; | |
| 1634 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | |
| 1635 layout->SetInsets(views::kButtonVEdgeMarginNew, | |
| 1636 views::kButtonHEdgeMarginNew, | |
| 1637 views::kUnrelatedControlVerticalSpacing, | |
| 1638 views::kButtonHEdgeMarginNew); | |
| 1639 | |
| 1640 // Profile icon, centered. | |
| 1641 int x_offset = (column_width - kLargeImageSide) / 2; | |
| 1642 current_profile_photo_ = new EditableProfilePhoto( | |
| 1643 this, avatar_item.icon, !is_guest, browser_->profile()); | |
| 1644 current_profile_photo_->SetX(x_offset); | |
| 1645 SizedContainer* profile_icon_container = | |
| 1646 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | |
| 1647 profile_icon_container->AddChildView(current_profile_photo_); | |
| 1648 | |
| 1649 | |
| 1650 layout->StartRow(1, 0); | |
| 1651 layout->AddView(profile_icon_container); | |
| 1652 | |
| 1653 // Profile name, centered. | |
| 1654 bool editing_allowed = !is_guest && | |
| 1655 !browser_->profile()->IsLegacySupervised(); | |
| 1656 current_profile_name_ = new EditableProfileName( | |
| 1657 this, | |
| 1658 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
| 1659 editing_allowed); | |
| 1660 layout->StartRowWithPadding(1, 0, 0, | |
| 1661 views::kRelatedControlSmallVerticalSpacing); | |
| 1662 layout->StartRow(1, 0); | |
| 1663 layout->AddView(current_profile_name_); | |
| 1664 | |
| 1665 if (is_guest) | |
| 1666 return view; | |
| 1667 | |
| 1668 // The available links depend on the type of profile that is active. | |
| 1669 if (avatar_item.signed_in) { | |
| 1670 layout->StartRow(1, 0); | |
| 1671 if (switches::IsEnableAccountConsistency()) { | |
| 1672 base::string16 link_title = l10n_util::GetStringUTF16( | |
| 1673 IsProfileChooser(view_mode_) ? | |
| 1674 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : | |
| 1675 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
| 1676 manage_accounts_link_ = CreateLink(link_title, this); | |
| 1677 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 1678 layout->AddView(manage_accounts_link_); | |
| 1679 } else { | |
| 1680 // Badge the email address if there's an authentication error. | |
| 1681 if (HasAuthError(browser_->profile())) { | |
| 1682 auth_error_email_button_ = | |
| 1683 new RightAlignedIconLabelButton(this, avatar_item.username); | |
| 1684 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | |
| 1685 auth_error_email_button_->SetImage( | |
| 1686 views::LabelButton::STATE_NORMAL, | |
| 1687 gfx::CreateVectorIcon(ui::kWarningIcon, 18, gfx::kChromeIconGrey)); | |
| 1688 auth_error_email_button_->SetFocusForPlatform(); | |
| 1689 gfx::Insets insets = | |
| 1690 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | |
| 1691 views::Button::STYLE_TEXTBUTTON); | |
| 1692 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( | |
| 1693 insets.top(), insets.left(), insets.bottom(), insets.right())); | |
| 1694 layout->AddView(auth_error_email_button_); | |
| 1695 } else { | |
| 1696 // Add a small padding between the email button and the profile name. | |
| 1697 layout->StartRowWithPadding(1, 0, 0, 2); | |
| 1698 views::Label* email_label = new views::Label(avatar_item.username); | |
| 1699 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
| 1700 email_label->SetEnabled(false); | |
| 1701 layout->AddView(email_label); | |
| 1702 } | |
| 1703 } | |
| 1704 } else { | |
| 1705 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
| 1706 browser_->profile()->GetOriginalProfile()); | |
| 1707 if (signin_manager->IsSigninAllowed()) { | |
| 1708 views::Label* promo = new views::Label( | |
| 1709 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
| 1710 promo->SetMultiLine(true); | |
| 1711 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 1712 layout->StartRowWithPadding(1, 0, 0, | |
| 1713 views::kRelatedControlSmallVerticalSpacing); | |
| 1714 layout->StartRow(1, 0); | |
| 1715 layout->AddView(promo); | |
| 1716 | |
| 1717 signin_current_profile_button_ = | |
| 1718 views::MdTextButton::CreateSecondaryUiBlueButton( | |
| 1719 this, l10n_util::GetStringFUTF16( | |
| 1720 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
| 1721 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
| 1722 layout->StartRowWithPadding(1, 0, 0, | |
| 1723 views::kRelatedControlVerticalSpacing); | |
| 1724 layout->StartRow(1, 0); | |
| 1725 layout->AddView(signin_current_profile_button_); | |
| 1726 content::RecordAction( | |
| 1727 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
| 1728 } | |
| 1729 } | |
| 1730 | |
| 1731 return view; | |
| 1732 } | |
| 1733 | |
| 1734 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
| 1735 const AvatarMenu::Item& avatar_item, | |
| 1736 bool is_guest) { | |
| 1737 views::View* view = new views::View(); | |
| 1738 view->SetLayoutManager( | 1363 view->SetLayoutManager( |
| 1739 new views::BoxLayout(views::BoxLayout::kVertical, 0, | 1364 new views::BoxLayout(views::BoxLayout::kVertical, 0, |
| 1740 views::kRelatedControlVerticalSpacing, 0)); | 1365 views::kRelatedControlVerticalSpacing, 0)); |
| 1741 | 1366 |
| 1742 // Container for the profile photo and avatar/user name. | 1367 // Container for the profile photo and avatar/user name. |
| 1743 BackgroundColorHoverButton* current_profile_card = | 1368 BackgroundColorHoverButton* current_profile_card = |
| 1744 new BackgroundColorHoverButton(this, base::string16()); | 1369 new BackgroundColorHoverButton(this, base::string16()); |
| 1745 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card); | 1370 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card); |
| 1746 current_profile_card->SetLayoutManager(grid_layout); | 1371 current_profile_card->SetLayoutManager(grid_layout); |
| 1747 views::ColumnSet* columns = grid_layout->AddColumnSet(0); | 1372 views::ColumnSet* columns = grid_layout->AddColumnSet(0); |
| 1748 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin); | 1373 columns->AddPaddingColumn(0, kMenuEdgeMargin); |
| 1749 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 1374 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 1750 views::GridLayout::USE_PREF, 0, 0); | 1375 views::GridLayout::USE_PREF, 0, 0); |
| 1751 columns->AddPaddingColumn( | 1376 columns->AddPaddingColumn(0, kMenuEdgeMargin - kBadgeSpacing); |
| 1752 0, kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing()); | |
| 1753 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 1377 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 1754 views::GridLayout::USE_PREF, 0, 0); | 1378 views::GridLayout::USE_PREF, 0, 0); |
| 1755 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin); | 1379 columns->AddPaddingColumn(0, kMenuEdgeMargin); |
| 1756 grid_layout->AddPaddingRow(0, 0); | 1380 grid_layout->AddPaddingRow(0, 0); |
| 1757 const int num_labels = | 1381 const int num_labels = |
| 1758 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2 | 1382 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2 |
| 1759 : 1; | 1383 : 1; |
| 1760 int profile_card_height = EditableProfilePhoto::icon_image_side() + | 1384 int profile_card_height = |
| 1761 2 * | 1385 kImageSide + |
| 1762 (EditableProfilePhoto::badge_spacing() + | 1386 2 * (kBadgeSpacing + views::kRelatedControlSmallVerticalSpacing); |
| 1763 views::kRelatedControlSmallVerticalSpacing); | |
| 1764 const int line_height = profile_card_height / num_labels; | 1387 const int line_height = profile_card_height / num_labels; |
| 1765 grid_layout->StartRow(0, 0, line_height); | 1388 grid_layout->StartRow(0, 0, line_height); |
| 1766 current_profile_card_ = current_profile_card; | 1389 current_profile_card_ = current_profile_card; |
| 1767 | 1390 |
| 1768 // Profile picture, left-aligned. | 1391 // Profile picture, left-aligned. |
| 1769 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( | 1392 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( |
| 1770 this, avatar_item.icon, !is_guest, browser_->profile()); | 1393 this, avatar_item.icon, !is_guest, browser_->profile()); |
| 1771 | 1394 |
| 1772 // Profile name, left-aligned to the right of profile icon. | 1395 // Profile name, left-aligned to the right of profile icon. |
| 1773 views::Label* current_profile_name = new views::Label( | 1396 views::Label* current_profile_name = new views::Label( |
| 1774 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); | 1397 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); |
| 1775 current_profile_card->set_title(current_profile_name); | 1398 current_profile_card->set_title(current_profile_name); |
| 1776 current_profile_name->SetAutoColorReadabilityEnabled(false); | 1399 current_profile_name->SetAutoColorReadabilityEnabled(false); |
| 1777 current_profile_name->SetFontList( | 1400 current_profile_name->SetFontList( |
| 1778 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | 1401 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| 1779 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); | 1402 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); |
| 1780 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1403 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1781 | 1404 |
| 1782 // The grid layout contains one row if not signed in or account consistency is | 1405 // The grid layout contains one row if not signed in or account consistency is |
| 1783 // enabled. It contains 2 rows if signed in and account consistency is | 1406 // enabled. It contains 2 rows if signed in and account consistency is |
| 1784 // disabled (the second row is for the email label). For the second case the | 1407 // disabled (the second row is for the email label). For the second case the |
| 1785 // profile photo has to be over 2 rows. | 1408 // profile photo has to be over 2 rows. |
| 1786 grid_layout->AddView(current_profile_photo, 1, num_labels); | 1409 grid_layout->AddView(current_profile_photo, 1, num_labels); |
| 1787 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING, | 1410 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING, |
| 1788 (num_labels == 2) ? views::GridLayout::TRAILING | 1411 (num_labels == 2) ? views::GridLayout::TRAILING |
| 1789 : views::GridLayout::CENTER); | 1412 : views::GridLayout::CENTER); |
| 1790 current_profile_card_->SetMinSize(gfx::Size( | 1413 current_profile_card_->SetMinSize(gfx::Size( |
| 1791 GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() + | 1414 kFixedMenuWidth, current_profile_photo->GetPreferredSize().height() + |
| 1792 2 * views::kRelatedControlSmallVerticalSpacing)); | 1415 2 * views::kRelatedControlSmallVerticalSpacing)); |
| 1793 view->AddChildView(current_profile_card_); | 1416 view->AddChildView(current_profile_card_); |
| 1794 | 1417 |
| 1795 if (is_guest) { | 1418 if (is_guest) { |
| 1796 current_profile_card_->SetEnabled(false); | 1419 current_profile_card_->SetEnabled(false); |
| 1797 return view; | 1420 return view; |
| 1798 } | 1421 } |
| 1799 | 1422 |
| 1800 const base::string16 profile_name = | 1423 const base::string16 profile_name = |
| 1801 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()); | 1424 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()); |
| 1802 | 1425 |
| 1803 // The available links depend on the type of profile that is active. | 1426 // The available links depend on the type of profile that is active. |
| 1804 if (avatar_item.signed_in) { | 1427 if (avatar_item.signed_in) { |
| 1805 if (switches::IsEnableAccountConsistency()) { | 1428 if (switches::IsEnableAccountConsistency()) { |
| 1806 base::string16 button_text = l10n_util::GetStringUTF16( | 1429 base::string16 button_text = l10n_util::GetStringUTF16( |
| 1807 IsProfileChooser(view_mode_) | 1430 IsProfileChooser(view_mode_) |
| 1808 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON | 1431 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON |
| 1809 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | 1432 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); |
| 1810 manage_accounts_button_ = | 1433 manage_accounts_button_ = |
| 1811 new BackgroundColorHoverButton(this, button_text); | 1434 new BackgroundColorHoverButton(this, button_text); |
| 1812 manage_accounts_button_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1435 manage_accounts_button_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1813 manage_accounts_button_->SetMinSize( | 1436 manage_accounts_button_->SetMinSize( |
| 1814 gfx::Size(GetFixedMenuWidth(), kButtonHeight)); | 1437 gfx::Size(kFixedMenuWidth, kButtonHeight)); |
| 1815 view->AddChildView(manage_accounts_button_); | 1438 view->AddChildView(manage_accounts_button_); |
| 1816 } else { | 1439 } else { |
| 1817 views::Label* email_label = new views::Label(avatar_item.username); | 1440 views::Label* email_label = new views::Label(avatar_item.username); |
| 1818 current_profile_card->set_subtitle(email_label); | 1441 current_profile_card->set_subtitle(email_label); |
| 1819 email_label->SetAutoColorReadabilityEnabled(false); | 1442 email_label->SetAutoColorReadabilityEnabled(false); |
| 1820 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | 1443 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); |
| 1821 email_label->SetEnabled(false); | 1444 email_label->SetEnabled(false); |
| 1822 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1445 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1823 grid_layout->StartRow(1, 0); | 1446 grid_layout->StartRow(1, 0); |
| 1824 // Skip first column for the profile icon. | 1447 // Skip first column for the profile icon. |
| 1825 grid_layout->SkipColumns(1); | 1448 grid_layout->SkipColumns(1); |
| 1826 grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING, | 1449 grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING, |
| 1827 views::GridLayout::LEADING); | 1450 views::GridLayout::LEADING); |
| 1828 } | 1451 } |
| 1829 | 1452 |
| 1830 current_profile_card_->SetAccessibleName( | 1453 current_profile_card_->SetAccessibleName( |
| 1831 l10n_util::GetStringFUTF16( | 1454 l10n_util::GetStringFUTF16( |
| 1832 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, | 1455 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, |
| 1833 profile_name, | 1456 profile_name, |
| 1834 avatar_item.username)); | 1457 avatar_item.username)); |
| 1835 return view; | 1458 return view; |
| 1836 } | 1459 } |
| 1837 | 1460 |
| 1838 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | 1461 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( |
| 1839 browser_->profile()->GetOriginalProfile()); | 1462 browser_->profile()->GetOriginalProfile()); |
| 1840 if (signin_manager->IsSigninAllowed()) { | 1463 if (signin_manager->IsSigninAllowed()) { |
| 1841 views::View* extra_links_view = new views::View(); | 1464 views::View* extra_links_view = new views::View(); |
| 1842 views::BoxLayout* extra_links_layout = new views::BoxLayout( | 1465 views::BoxLayout* extra_links_layout = new views::BoxLayout( |
| 1843 views::BoxLayout::kVertical, kMaterialMenuEdgeMargin, | 1466 views::BoxLayout::kVertical, kMenuEdgeMargin, |
| 1844 views::kRelatedControlVerticalSpacing, kMaterialMenuEdgeMargin); | 1467 views::kRelatedControlVerticalSpacing, kMenuEdgeMargin); |
| 1845 extra_links_layout->set_cross_axis_alignment( | 1468 extra_links_layout->set_cross_axis_alignment( |
| 1846 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 1469 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 1847 extra_links_view->SetLayoutManager(extra_links_layout); | 1470 extra_links_view->SetLayoutManager(extra_links_layout); |
| 1848 views::Label* promo = | 1471 views::Label* promo = |
| 1849 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | 1472 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
| 1850 promo->SetMultiLine(true); | 1473 promo->SetMultiLine(true); |
| 1851 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1474 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1852 extra_links_view->AddChildView(promo); | 1475 extra_links_view->AddChildView(promo); |
| 1853 | 1476 |
| 1854 signin_current_profile_button_ = | 1477 signin_current_profile_button_ = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1873 views::View* ProfileChooserView::CreateGuestProfileView() { | 1496 views::View* ProfileChooserView::CreateGuestProfileView() { |
| 1874 gfx::Image guest_icon = | 1497 gfx::Image guest_icon = |
| 1875 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1498 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 1876 profiles::GetPlaceholderAvatarIconResourceID()); | 1499 profiles::GetPlaceholderAvatarIconResourceID()); |
| 1877 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1500 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
| 1878 guest_avatar_item.active = true; | 1501 guest_avatar_item.active = true; |
| 1879 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1502 guest_avatar_item.name = l10n_util::GetStringUTF16( |
| 1880 IDS_PROFILES_GUEST_PROFILE_NAME); | 1503 IDS_PROFILES_GUEST_PROFILE_NAME); |
| 1881 guest_avatar_item.signed_in = false; | 1504 guest_avatar_item.signed_in = false; |
| 1882 | 1505 |
| 1883 return switches::IsMaterialDesignUserMenu() | 1506 return CreateCurrentProfileView(guest_avatar_item, true); |
| 1884 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
| 1885 : CreateCurrentProfileView(guest_avatar_item, true); | |
| 1886 } | 1507 } |
| 1887 | 1508 |
| 1888 views::View* ProfileChooserView::CreateOtherProfilesView( | 1509 views::View* ProfileChooserView::CreateOtherProfilesView( |
| 1889 const Indexes& avatars_to_show) { | 1510 const Indexes& avatars_to_show) { |
| 1890 views::View* view = new views::View(); | 1511 views::View* view = new views::View(); |
| 1891 views::GridLayout* layout = | 1512 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 1892 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1893 | 1513 |
| 1894 for (size_t index : avatars_to_show) { | 1514 for (size_t index : avatars_to_show) { |
| 1895 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1515 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
| 1896 const int kSmallImageSide = 32; | 1516 const int kSmallImageSide = 32; |
| 1897 | 1517 |
| 1898 // Use the low-res, small default avatars in the fast user switcher, like | 1518 // Use the low-res, small default avatars in the fast user switcher, like |
| 1899 // we do in the menu bar. | 1519 // we do in the menu bar. |
| 1900 gfx::Image item_icon; | 1520 gfx::Image item_icon; |
| 1901 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1521 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
| 1902 | 1522 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1914 layout->StartRow(1, 0); | 1534 layout->StartRow(1, 0); |
| 1915 layout->AddView(button); | 1535 layout->AddView(button); |
| 1916 } | 1536 } |
| 1917 | 1537 |
| 1918 return view; | 1538 return view; |
| 1919 } | 1539 } |
| 1920 | 1540 |
| 1921 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, | 1541 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| 1922 AvatarMenu* avatar_menu) { | 1542 AvatarMenu* avatar_menu) { |
| 1923 views::View* view = new views::View(); | 1543 views::View* view = new views::View(); |
| 1924 views::GridLayout* layout = | 1544 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 1925 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1926 | 1545 |
| 1927 const bool is_guest = browser_->profile()->IsGuestSession(); | 1546 const bool is_guest = browser_->profile()->IsGuestSession(); |
| 1928 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; | 1547 const int kIconSize = 20; |
| 1929 if (switches::IsMaterialDesignUserMenu()) { | 1548 // Add the user switching buttons |
| 1930 // Add the user switching buttons | 1549 const int kProfileIconSize = 18; |
| 1931 const int kProfileIconSize = 18; | 1550 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 1932 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1551 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1933 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1552 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1934 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1553 if (!item.active) { |
| 1935 if (!item.active) { | 1554 gfx::Image image = profiles::GetSizedAvatarIcon( |
| 1936 gfx::Image image = profiles::GetSizedAvatarIcon( | 1555 item.icon, true, kProfileIconSize, kProfileIconSize, |
| 1937 item.icon, true, kProfileIconSize, kProfileIconSize, | 1556 profiles::SHAPE_CIRCLE); |
| 1938 profiles::SHAPE_CIRCLE); | 1557 views::LabelButton* button = new BackgroundColorHoverButton( |
| 1939 views::LabelButton* button = new BackgroundColorHoverButton( | 1558 this, profiles::GetProfileSwitcherTextForItem(item), |
| 1940 this, profiles::GetProfileSwitcherTextForItem(item), | 1559 *image.ToImageSkia()); |
| 1941 *image.ToImageSkia()); | 1560 button->SetImageLabelSpacing(kMenuEdgeMargin); |
| 1942 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); | 1561 open_other_profile_indexes_map_[button] = i; |
| 1943 open_other_profile_indexes_map_[button] = i; | |
| 1944 | 1562 |
| 1945 if (!first_profile_button_) | 1563 if (!first_profile_button_) |
| 1946 first_profile_button_ = button; | 1564 first_profile_button_ = button; |
| 1947 layout->StartRow(1, 0); | 1565 layout->StartRow(1, 0); |
| 1948 layout->AddView(button); | 1566 layout->AddView(button); |
| 1949 } | |
| 1950 } | 1567 } |
| 1568 } |
| 1951 | 1569 |
| 1952 // Add the "Guest" button for browsing as guest | 1570 // Add the "Guest" button for browsing as guest |
| 1953 if (!is_guest) { | 1571 if (!is_guest) { |
| 1954 PrefService* service = g_browser_process->local_state(); | 1572 PrefService* service = g_browser_process->local_state(); |
| 1955 DCHECK(service); | 1573 DCHECK(service); |
| 1956 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | 1574 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| 1957 guest_profile_button_ = new BackgroundColorHoverButton( | 1575 guest_profile_button_ = new BackgroundColorHoverButton( |
| 1958 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | 1576 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| 1959 gfx::CreateVectorIcon(kAccountCircleIcon, kIconSize, | 1577 gfx::CreateVectorIcon(kAccountCircleIcon, kIconSize, |
| 1960 gfx::kChromeIconGrey)); | 1578 gfx::kChromeIconGrey)); |
| 1961 layout->StartRow(1, 0); | 1579 layout->StartRow(1, 0); |
| 1962 layout->AddView(guest_profile_button_); | 1580 layout->AddView(guest_profile_button_); |
| 1963 } | |
| 1964 } | 1581 } |
| 1965 } | 1582 } |
| 1966 | 1583 |
| 1967 base::string16 text = l10n_util::GetStringUTF16( | 1584 base::string16 text = l10n_util::GetStringUTF16( |
| 1968 is_guest ? IDS_PROFILES_EXIT_GUEST | 1585 is_guest ? IDS_PROFILES_EXIT_GUEST : IDS_PROFILES_MANAGE_USERS_BUTTON); |
| 1969 : (switches::IsMaterialDesignUserMenu() | |
| 1970 ? IDS_PROFILES_MANAGE_USERS_BUTTON | |
| 1971 : IDS_PROFILES_SWITCH_USERS_BUTTON)); | |
| 1972 const gfx::VectorIcon& settings_icon = | 1586 const gfx::VectorIcon& settings_icon = |
| 1973 switches::IsMaterialDesignUserMenu() | 1587 is_guest ? kCloseAllIcon : kSettingsIcon; |
| 1974 ? (is_guest ? kCloseAllIcon : kSettingsIcon) | |
| 1975 : kAccountBoxIcon; | |
| 1976 users_button_ = new BackgroundColorHoverButton( | 1588 users_button_ = new BackgroundColorHoverButton( |
| 1977 this, text, | 1589 this, text, |
| 1978 gfx::CreateVectorIcon(settings_icon, kIconSize, gfx::kChromeIconGrey)); | 1590 gfx::CreateVectorIcon(settings_icon, kIconSize, gfx::kChromeIconGrey)); |
| 1979 | 1591 |
| 1980 layout->StartRow(1, 0); | 1592 layout->StartRow(1, 0); |
| 1981 layout->AddView(users_button_); | 1593 layout->AddView(users_button_); |
| 1982 | 1594 |
| 1983 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | |
| 1984 layout->StartRow(1, 0); | |
| 1985 layout->AddView(new views::Separator()); | |
| 1986 | |
| 1987 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
| 1988 go_incognito_button_ = new BackgroundColorHoverButton( | |
| 1989 this, | |
| 1990 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | |
| 1991 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | |
| 1992 layout->StartRow(1, 0); | |
| 1993 layout->AddView(go_incognito_button_); | |
| 1994 } | |
| 1995 | |
| 1996 if (display_lock) { | 1595 if (display_lock) { |
| 1997 if (!switches::IsMaterialDesignUserMenu()) { | |
| 1998 layout->StartRow(1, 0); | |
| 1999 layout->AddView(new views::Separator()); | |
| 2000 } | |
| 2001 | |
| 2002 lock_button_ = new BackgroundColorHoverButton( | 1596 lock_button_ = new BackgroundColorHoverButton( |
| 2003 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1597 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
| 2004 gfx::CreateVectorIcon(kLockIcon, kIconSize, gfx::kChromeIconGrey)); | 1598 gfx::CreateVectorIcon(kLockIcon, kIconSize, gfx::kChromeIconGrey)); |
| 2005 layout->StartRow(1, 0); | 1599 layout->StartRow(1, 0); |
| 2006 layout->AddView(lock_button_); | 1600 layout->AddView(lock_button_); |
| 2007 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { | 1601 } else if (!is_guest) { |
| 2008 int num_browsers = 0; | 1602 int num_browsers = 0; |
| 2009 for (auto* browser : *BrowserList::GetInstance()) { | 1603 for (auto* browser : *BrowserList::GetInstance()) { |
| 2010 if (browser->profile()->GetOriginalProfile() == | 1604 if (browser->profile()->GetOriginalProfile() == |
| 2011 browser_->profile()->GetOriginalProfile()) | 1605 browser_->profile()->GetOriginalProfile()) |
| 2012 num_browsers++; | 1606 num_browsers++; |
| 2013 } | 1607 } |
| 2014 if (num_browsers > 1) { | 1608 if (num_browsers > 1) { |
| 2015 close_all_windows_button_ = new BackgroundColorHoverButton( | 1609 close_all_windows_button_ = new BackgroundColorHoverButton( |
| 2016 this, | 1610 this, |
| 2017 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), | 1611 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), |
| 2018 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize, | 1612 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize, |
| 2019 gfx::kChromeIconGrey)); | 1613 gfx::kChromeIconGrey)); |
| 2020 layout->StartRow(1, 0); | 1614 layout->StartRow(1, 0); |
| 2021 layout->AddView(close_all_windows_button_); | 1615 layout->AddView(close_all_windows_button_); |
| 2022 } | 1616 } |
| 2023 } | 1617 } |
| 2024 | 1618 |
| 2025 if (switches::IsMaterialDesignUserMenu()) | 1619 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 2026 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | |
| 2027 return view; | 1620 return view; |
| 2028 } | 1621 } |
| 2029 | 1622 |
| 2030 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1623 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
| 2031 views::View* view = new views::View(); | 1624 views::View* view = new views::View(); |
| 2032 int horizontal_margin = switches::IsMaterialDesignUserMenu() ? | 1625 int horizontal_margin = kMenuEdgeMargin; |
| 2033 kMaterialMenuEdgeMargin : views::kButtonHEdgeMarginNew; | 1626 views::GridLayout* layout = |
| 2034 views::GridLayout* layout = CreateSingleColumnLayout( | 1627 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * horizontal_margin); |
| 2035 view, GetFixedMenuWidth() - 2 * horizontal_margin); | 1628 layout->SetInsets(0, horizontal_margin, kMenuEdgeMargin, horizontal_margin); |
| 2036 if (switches::IsMaterialDesignUserMenu()) { | |
| 2037 layout->SetInsets(0, horizontal_margin, | |
| 2038 kMaterialMenuEdgeMargin, horizontal_margin); | |
| 2039 } else { | |
| 2040 layout->SetInsets( | |
| 2041 views::kRelatedControlVerticalSpacing, horizontal_margin, | |
| 2042 views::kRelatedControlVerticalSpacing, horizontal_margin); | |
| 2043 } | |
| 2044 | 1629 |
| 2045 views::Label* disclaimer = new views::Label( | 1630 views::Label* disclaimer = new views::Label( |
| 2046 avatar_menu_->GetSupervisedUserInformation()); | 1631 avatar_menu_->GetSupervisedUserInformation()); |
| 2047 disclaimer->SetMultiLine(true); | 1632 disclaimer->SetMultiLine(true); |
| 2048 disclaimer->SetAllowCharacterBreak(true); | 1633 disclaimer->SetAllowCharacterBreak(true); |
| 2049 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1634 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 2050 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1635 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 2051 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1636 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 2052 layout->StartRow(1, 0); | 1637 layout->StartRow(1, 0); |
| 2053 layout->AddView(disclaimer); | 1638 layout->AddView(disclaimer); |
| 2054 | 1639 |
| 2055 return view; | 1640 return view; |
| 2056 } | 1641 } |
| 2057 | 1642 |
| 2058 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1643 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
| 2059 const AvatarMenu::Item& avatar_item) { | 1644 const AvatarMenu::Item& avatar_item) { |
| 2060 DCHECK(avatar_item.signed_in); | 1645 DCHECK(avatar_item.signed_in); |
| 2061 views::View* view = new views::View(); | 1646 views::View* view = new views::View(); |
| 2062 view->set_background(views::Background::CreateSolidBackground( | 1647 view->set_background(views::Background::CreateSolidBackground( |
| 2063 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1648 profiles::kAvatarBubbleAccountsBackgroundColor)); |
| 2064 views::GridLayout* layout = | 1649 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 2065 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 2066 | 1650 |
| 2067 Profile* profile = browser_->profile(); | 1651 Profile* profile = browser_->profile(); |
| 2068 std::string primary_account = | 1652 std::string primary_account = |
| 2069 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1653 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
| 2070 DCHECK(!primary_account.empty()); | 1654 DCHECK(!primary_account.empty()); |
| 2071 std::vector<std::string>accounts = | 1655 std::vector<std::string>accounts = |
| 2072 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1656 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
| 2073 | 1657 |
| 2074 // Get state of authentication error, if any. | 1658 // Get state of authentication error, if any. |
| 2075 std::string error_account_id = GetAuthErrorAccountId(profile); | 1659 std::string error_account_id = GetAuthErrorAccountId(profile); |
| 2076 | 1660 |
| 2077 // The primary account should always be listed first. | 1661 // The primary account should always be listed first. |
| 2078 // TODO(rogerta): we still need to further differentiate the primary account | 1662 // TODO(rogerta): we still need to further differentiate the primary account |
| 2079 // from the others in the UI, so more work is likely required here: | 1663 // from the others in the UI, so more work is likely required here: |
| 2080 // crbug.com/311124. | 1664 // crbug.com/311124. |
| 2081 CreateAccountButton(layout, primary_account, true, | 1665 CreateAccountButton(layout, primary_account, true, |
| 2082 error_account_id == primary_account, GetFixedMenuWidth()); | 1666 error_account_id == primary_account, kFixedMenuWidth); |
| 2083 for (size_t i = 0; i < accounts.size(); ++i) | 1667 for (size_t i = 0; i < accounts.size(); ++i) |
| 2084 CreateAccountButton(layout, accounts[i], false, | 1668 CreateAccountButton(layout, accounts[i], false, |
| 2085 error_account_id == accounts[i], GetFixedMenuWidth()); | 1669 error_account_id == accounts[i], kFixedMenuWidth); |
| 2086 | 1670 |
| 2087 if (!profile->IsSupervised()) { | 1671 if (!profile->IsSupervised()) { |
| 2088 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1672 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 2089 | 1673 |
| 2090 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1674 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
| 2091 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1675 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
| 2092 add_account_link_->SetBorder( | 1676 add_account_link_->SetBorder( |
| 2093 views::CreateEmptyBorder(0, views::kButtonVEdgeMarginNew, | 1677 views::CreateEmptyBorder(0, views::kButtonVEdgeMarginNew, |
| 2094 views::kRelatedControlVerticalSpacing, 0)); | 1678 views::kRelatedControlVerticalSpacing, 0)); |
| 2095 layout->StartRow(1, 0); | 1679 layout->StartRow(1, 0); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2382 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1966 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2383 IncognitoModePrefs::DISABLED; | 1967 IncognitoModePrefs::DISABLED; |
| 2384 return incognito_available && !browser_->profile()->IsGuestSession(); | 1968 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2385 } | 1969 } |
| 2386 | 1970 |
| 2387 void ProfileChooserView::PostActionPerformed( | 1971 void ProfileChooserView::PostActionPerformed( |
| 2388 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1972 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2389 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1973 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2390 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1974 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2391 } | 1975 } |
| OLD | NEW |