Chromium Code Reviews| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 #include "ui/views/controls/button/blue_button.h" | 73 #include "ui/views/controls/button/blue_button.h" |
| 74 #include "ui/views/controls/button/image_button.h" | 74 #include "ui/views/controls/button/image_button.h" |
| 75 #include "ui/views/controls/button/label_button.h" | 75 #include "ui/views/controls/button/label_button.h" |
| 76 #include "ui/views/controls/button/label_button_border.h" | 76 #include "ui/views/controls/button/label_button_border.h" |
| 77 #include "ui/views/controls/button/md_text_button.h" | 77 #include "ui/views/controls/button/md_text_button.h" |
| 78 #include "ui/views/controls/button/menu_button.h" | 78 #include "ui/views/controls/button/menu_button.h" |
| 79 #include "ui/views/controls/label.h" | 79 #include "ui/views/controls/label.h" |
| 80 #include "ui/views/controls/link.h" | 80 #include "ui/views/controls/link.h" |
| 81 #include "ui/views/controls/separator.h" | 81 #include "ui/views/controls/separator.h" |
| 82 #include "ui/views/controls/styled_label.h" | 82 #include "ui/views/controls/styled_label.h" |
| 83 #include "ui/views/controls/textfield/textfield.h" | |
| 84 #include "ui/views/controls/webview/webview.h" | 83 #include "ui/views/controls/webview/webview.h" |
| 85 #include "ui/views/layout/box_layout.h" | 84 #include "ui/views/layout/box_layout.h" |
| 86 #include "ui/views/layout/fill_layout.h" | 85 #include "ui/views/layout/fill_layout.h" |
| 87 #include "ui/views/layout/grid_layout.h" | 86 #include "ui/views/layout/grid_layout.h" |
| 88 #include "ui/views/layout/layout_constants.h" | 87 #include "ui/views/layout/layout_constants.h" |
| 89 #include "ui/views/widget/widget.h" | 88 #include "ui/views/widget/widget.h" |
| 90 | 89 |
| 91 namespace { | 90 namespace { |
| 92 | 91 |
| 93 // Helpers -------------------------------------------------------------------- | 92 // Helpers -------------------------------------------------------------------- |
| 94 | 93 |
| 95 const int kButtonHeight = 32; | 94 const int kButtonHeight = 32; |
| 96 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 95 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| 97 const int kFixedGaiaViewWidth = 448; | 96 const int kFixedGaiaViewWidth = 448; |
| 98 const int kFixedAccountRemovalViewWidth = 280; | 97 const int kFixedAccountRemovalViewWidth = 280; |
| 99 const int kFixedSwitchUserViewWidth = 320; | 98 const int kFixedSwitchUserViewWidth = 320; |
| 100 const int kLargeImageSide = 88; | |
| 101 const int kMdImageSide = 40; | 99 const int kMdImageSide = 40; |
| 102 | 100 |
| 103 // Spacing between the edge of the material design user menu and the | 101 // Spacing between the edge of the material design user menu and the |
| 104 // top/bottom or left/right of the menu items. | 102 // top/bottom or left/right of the menu items. |
| 105 const int kMaterialMenuEdgeMargin = 16; | 103 const int kMaterialMenuEdgeMargin = 16; |
| 106 | 104 |
| 107 const int kVerticalSpacing = 16; | 105 const int kVerticalSpacing = 16; |
| 108 | 106 |
| 109 const int kTitleViewNativeWidgetOffset = 8; | 107 const int kTitleViewNativeWidgetOffset = 8; |
| 110 | 108 |
| 111 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 109 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| 112 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 110 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
| 113 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 111 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 114 } | 112 } |
| 115 | 113 |
| 116 int GetFixedMenuWidth() { | 114 int GetFixedMenuWidth() { |
|
msarda
2017/02/23 11:51:02
Same here: Consider making these constants
jlebel
2017/02/23 18:18:49
Done.
| |
| 117 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | 115 return 240; |
| 118 } | 116 } |
| 119 | 117 |
| 120 int GetProfileBadgeSize() { | 118 int GetProfileBadgeSize() { |
| 121 return switches::IsMaterialDesignUserMenu() ? 24 : 30; | 119 return 24; |
| 122 } | 120 } |
| 123 | 121 |
| 124 // DEPRECATED: New user menu components should use views::BoxLayout instead. | 122 // DEPRECATED: New user menu components should use views::BoxLayout instead. |
| 125 // 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 |
| 126 // 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. |
| 127 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 125 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
| 128 views::GridLayout* layout = new views::GridLayout(view); | 126 views::GridLayout* layout = new views::GridLayout(view); |
| 129 view->SetLayoutManager(layout); | 127 view->SetLayoutManager(layout); |
| 130 | 128 |
| 131 views::ColumnSet* columns = layout->AddColumnSet(0); | 129 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 132 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 130 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 133 views::GridLayout::FIXED, width, width); | 131 views::GridLayout::FIXED, width, width); |
| 134 return layout; | 132 return layout; |
| 135 } | 133 } |
| 136 | 134 |
| 137 views::Link* CreateLink(const base::string16& link_text, | 135 views::Link* CreateLink(const base::string16& link_text, |
| 138 views::LinkListener* listener) { | 136 views::LinkListener* listener) { |
| 139 views::Link* link_button = new views::Link(link_text); | 137 views::Link* link_button = new views::Link(link_text); |
| 140 link_button->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 138 link_button->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 141 link_button->SetUnderline(false); | 139 link_button->SetUnderline(false); |
| 142 link_button->set_listener(listener); | 140 link_button->set_listener(listener); |
| 143 return link_button; | 141 return link_button; |
| 144 } | 142 } |
| 145 | 143 |
| 146 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { | |
| 147 SkBitmap bitmap; | |
| 148 bitmap.allocPixels(SkImageInfo::MakeA8(size, size)); | |
| 149 bitmap.eraseARGB(0, 0, 0, 0); | |
| 150 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 151 } | |
| 152 | |
| 153 bool HasAuthError(Profile* profile) { | 144 bool HasAuthError(Profile* profile) { |
| 154 const SigninErrorController* error = | 145 const SigninErrorController* error = |
| 155 SigninErrorControllerFactory::GetForProfile(profile); | 146 SigninErrorControllerFactory::GetForProfile(profile); |
| 156 return error && error->HasError(); | 147 return error && error->HasError(); |
| 157 } | 148 } |
| 158 | 149 |
| 159 std::string GetAuthErrorAccountId(Profile* profile) { | 150 std::string GetAuthErrorAccountId(Profile* profile) { |
| 160 const SigninErrorController* error = | 151 const SigninErrorController* error = |
| 161 SigninErrorControllerFactory::GetForProfile(profile); | 152 SigninErrorControllerFactory::GetForProfile(profile); |
| 162 if (!error) | 153 if (!error) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 188 class BackgroundColorHoverButton : public views::LabelButton { | 179 class BackgroundColorHoverButton : public views::LabelButton { |
| 189 public: | 180 public: |
| 190 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, | 181 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, |
| 191 const base::string16& text) | 182 const base::string16& text) |
| 192 : views::LabelButton(profile_chooser_view, text), | 183 : views::LabelButton(profile_chooser_view, text), |
| 193 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 184 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 194 profile_chooser_view_(profile_chooser_view), | 185 profile_chooser_view_(profile_chooser_view), |
| 195 #endif | 186 #endif |
| 196 title_(nullptr), | 187 title_(nullptr), |
| 197 subtitle_(nullptr) { | 188 subtitle_(nullptr) { |
| 198 SetImageLabelSpacing(switches::IsMaterialDesignUserMenu() | 189 SetImageLabelSpacing(kMaterialMenuEdgeMargin - 2); |
| 199 ? (kMaterialMenuEdgeMargin - 2) | 190 SetBorder(views::CreateEmptyBorder(0, kMaterialMenuEdgeMargin, 0, |
| 200 : views::kItemLabelSpacing); | 191 kMaterialMenuEdgeMargin)); |
| 201 const int button_margin = switches::IsMaterialDesignUserMenu() | |
| 202 ? kMaterialMenuEdgeMargin | |
| 203 : views::kButtonHEdgeMarginNew; | |
| 204 SetBorder(views::CreateEmptyBorder(0, button_margin, 0, button_margin)); | |
| 205 SetFocusForPlatform(); | 192 SetFocusForPlatform(); |
| 206 | 193 |
| 207 if (switches::IsMaterialDesignUserMenu()) { | 194 label()->SetHandlesTooltips(false); |
| 208 label()->SetHandlesTooltips(false); | |
| 209 } | |
| 210 } | 195 } |
| 211 | 196 |
| 212 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, | 197 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, |
| 213 const base::string16& text, | 198 const base::string16& text, |
| 214 const gfx::ImageSkia& icon) | 199 const gfx::ImageSkia& icon) |
| 215 : BackgroundColorHoverButton(profile_chooser_view, text) { | 200 : BackgroundColorHoverButton(profile_chooser_view, text) { |
| 216 SetMinSize(gfx::Size( | 201 SetMinSize(gfx::Size( |
| 217 icon.width(), kButtonHeight + views::kRelatedControlVerticalSpacing)); | 202 icon.width(), kButtonHeight + views::kRelatedControlVerticalSpacing)); |
| 218 SetImage(STATE_NORMAL, icon); | 203 SetImage(STATE_NORMAL, icon); |
| 219 } | 204 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 title_widget_->SetContentsView(title_view_); | 348 title_widget_->SetContentsView(title_view_); |
| 364 | 349 |
| 365 gfx::Rect bounds(title_view_->GetPreferredSize()); | 350 gfx::Rect bounds(title_view_->GetPreferredSize()); |
| 366 title_view_->SetBoundsRect(bounds); | 351 title_view_->SetBoundsRect(bounds); |
| 367 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 352 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
| 368 title_widget_->SetBounds(bounds); | 353 title_widget_->SetBounds(bounds); |
| 369 } | 354 } |
| 370 | 355 |
| 371 } // namespace | 356 } // namespace |
| 372 | 357 |
| 373 // RightAlignedIconLabelButton ------------------------------------------------- | |
| 374 | |
| 375 // A custom LabelButton that has a center-aligned text and right aligned icon. | |
| 376 // Only used in non-material-design user menu. | |
| 377 class RightAlignedIconLabelButton : public views::LabelButton { | |
| 378 public: | |
| 379 RightAlignedIconLabelButton(views::ButtonListener* listener, | |
| 380 const base::string16& text) | |
| 381 : views::LabelButton(listener, text) { | |
| 382 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | |
| 383 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 384 } | |
| 385 | |
| 386 protected: | |
| 387 void Layout() override { | |
| 388 views::LabelButton::Layout(); | |
| 389 | |
| 390 // Keep the text centered and the icon right-aligned by stretching the label | |
| 391 // to take up more of the content area and centering its contents. | |
| 392 gfx::Rect content_bounds = GetContentsBounds(); | |
| 393 gfx::Rect label_bounds = label()->bounds(); | |
| 394 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); | |
| 395 label()->SetBoundsRect(label_bounds); | |
| 396 } | |
| 397 | |
| 398 private: | |
| 399 void OnFocus() override { | |
| 400 SetState(STATE_HOVERED); | |
| 401 } | |
| 402 | |
| 403 void OnBlur() override { | |
| 404 SetState(STATE_NORMAL); | |
| 405 } | |
| 406 | |
| 407 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | |
| 408 }; | |
| 409 | |
| 410 // EditableProfilePhoto ------------------------------------------------- | 358 // EditableProfilePhoto ------------------------------------------------- |
| 411 | 359 |
| 412 const size_t kProfileBadgeWhitePadding = 2; | |
| 413 | |
| 414 // A custom Image control that shows a "change" button when moused over. | 360 // A custom Image control that shows a "change" button when moused over. |
| 415 class EditableProfilePhoto : public views::LabelButton { | 361 class EditableProfilePhoto : public views::LabelButton { |
| 416 public: | 362 public: |
| 417 EditableProfilePhoto(views::ButtonListener* listener, | 363 EditableProfilePhoto(views::ButtonListener* listener, |
| 418 const gfx::Image& icon, | 364 const gfx::Image& icon, |
| 419 bool is_editing_allowed, | 365 bool is_editing_allowed, |
| 420 Profile* profile) | 366 Profile* profile) |
| 421 : views::LabelButton(listener, base::string16()), | 367 : views::LabelButton(listener, base::string16()), |
| 422 interactive_(!switches::IsMaterialDesignUserMenu()), | |
| 423 photo_overlay_(nullptr), | 368 photo_overlay_(nullptr), |
| 424 profile_(profile) { | 369 profile_(profile) { |
| 370 set_can_process_events_within_subtree(false); | |
|
msarda
2017/02/23 11:51:02
Why this change?
jlebel
2017/02/23 18:18:49
To replace:
bool CanProcessEventsWithinSubtree() c
| |
| 425 gfx::Image image = profiles::GetSizedAvatarIcon( | 371 gfx::Image image = profiles::GetSizedAvatarIcon( |
| 426 icon, true, icon_image_side(), icon_image_side()); | 372 icon, true, icon_image_side(), icon_image_side()); |
| 427 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 373 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
| 428 SetBorder(views::NullBorder()); | 374 SetBorder(views::NullBorder()); |
| 429 if (switches::IsMaterialDesignUserMenu()) { | 375 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), |
| 430 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), | 376 GetPreferredSize().height() + badge_spacing() + |
| 431 GetPreferredSize().height() + badge_spacing() + | 377 views::kRelatedControlSmallVerticalSpacing)); |
| 432 views::kRelatedControlSmallVerticalSpacing)); | |
| 433 } else { | |
| 434 SetSize(GetPreferredSize()); | |
| 435 } | |
| 436 | 378 |
| 437 if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) { | 379 SetEnabled(false); |
| 438 SetEnabled(false); | |
| 439 return; | |
| 440 } | |
| 441 | |
| 442 set_notify_enter_exit_on_child(true); | |
| 443 | |
| 444 // Photo overlay that appears when hovering over the button. | |
| 445 photo_overlay_ = new views::ImageView(); | |
| 446 | |
| 447 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | |
| 448 photo_overlay_->set_background( | |
| 449 views::Background::CreateSolidBackground(kBackgroundColor)); | |
| 450 photo_overlay_->SetImage(gfx::CreateVectorIcon( | |
| 451 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 452 | |
| 453 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); | |
| 454 photo_overlay_->SetY(badge_spacing()); | |
| 455 photo_overlay_->SetVisible(false); | |
| 456 AddChildView(photo_overlay_); | |
| 457 } | 380 } |
| 458 | 381 |
| 459 void PaintChildren(const ui::PaintContext& context) override { | 382 void PaintChildren(const ui::PaintContext& context) override { |
| 460 { | 383 { |
| 461 // Display any children (the "change photo" overlay) as a circle. | 384 // Display any children (the "change photo" overlay) as a circle. |
| 462 ui::ClipRecorder clip_recorder(context); | 385 ui::ClipRecorder clip_recorder(context); |
| 463 gfx::Rect clip_bounds = image()->GetMirroredBounds(); | 386 gfx::Rect clip_bounds = image()->GetMirroredBounds(); |
| 464 gfx::Path clip_mask; | 387 gfx::Path clip_mask; |
| 465 clip_mask.addCircle( | 388 clip_mask.addCircle( |
| 466 clip_bounds.x() + clip_bounds.width() / 2, | 389 clip_bounds.x() + clip_bounds.width() / 2, |
| 467 clip_bounds.y() + clip_bounds.height() / 2, | 390 clip_bounds.y() + clip_bounds.height() / 2, |
| 468 clip_bounds.width() / 2); | 391 clip_bounds.width() / 2); |
| 469 clip_recorder.ClipPathWithAntiAliasing(clip_mask); | 392 clip_recorder.ClipPathWithAntiAliasing(clip_mask); |
| 470 View::PaintChildren(context); | 393 View::PaintChildren(context); |
| 471 } | 394 } |
| 472 | 395 |
| 473 ui::PaintRecorder paint_recorder( | 396 ui::PaintRecorder paint_recorder( |
| 474 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); | 397 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); |
| 475 gfx::Canvas* canvas = paint_recorder.canvas(); | 398 gfx::Canvas* canvas = paint_recorder.canvas(); |
| 476 if (profile_->IsSupervised()) { | 399 if (profile_->IsSupervised()) { |
| 477 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | 400 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); |
| 478 int badge_offset = | 401 int badge_offset = |
| 479 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); | 402 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); |
| 480 gfx::Vector2d badge_offset_vector = gfx::Vector2d( | 403 gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
| 481 GetMirroredXWithWidthInView(badge_offset, GetProfileBadgeSize()), | 404 GetMirroredXWithWidthInView(badge_offset, GetProfileBadgeSize()), |
| 482 badge_offset + (switches::IsMaterialDesignUserMenu() | 405 badge_offset + views::kRelatedControlSmallVerticalSpacing); |
| 483 ? views::kRelatedControlSmallVerticalSpacing | |
| 484 : 0)); | |
| 485 | 406 |
| 486 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | 407 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| 487 | 408 |
| 488 // Paint the circular background. | 409 // Paint the circular background. |
| 489 cc::PaintFlags flags; | 410 cc::PaintFlags flags; |
| 490 flags.setAntiAlias(true); | 411 flags.setAntiAlias(true); |
| 491 flags.setColor(GetNativeTheme()->GetSystemColor( | 412 flags.setColor(GetNativeTheme()->GetSystemColor( |
| 492 ui::NativeTheme::kColorId_BubbleBackground)); | 413 ui::NativeTheme::kColorId_BubbleBackground)); |
| 493 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); | 414 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); |
| 494 | 415 |
| 495 gfx::VectorIconId icon_id; | 416 gfx::VectorIconId icon_id; |
| 496 int icon_size; | 417 int icon_size; |
| 497 SkColor icon_color; | 418 SkColor icon_color; |
| 498 if (switches::IsMaterialDesignUserMenu()) { | 419 icon_id = profile_->IsChild() |
| 499 icon_id = profile_->IsChild() | 420 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE |
| 500 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE | 421 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; |
| 501 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; | 422 icon_size = 22; |
|
msarda
2017/02/23 11:51:03
consider making this a constant.
jlebel
2017/02/23 18:18:49
Done.
| |
| 502 icon_size = 22; | 423 icon_color = gfx::kChromeIconGrey; |
|
msarda
2017/02/23 11:51:02
I think this variable can be removed now.
jlebel
2017/02/23 18:18:49
Done.
| |
| 503 icon_color = gfx::kChromeIconGrey; | |
| 504 } else { | |
| 505 // Paint the light blue circle. | |
| 506 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); | |
| 507 canvas->DrawCircle( | |
| 508 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | |
| 509 flags); | |
| 510 | |
| 511 icon_id = profile_->IsChild() | |
| 512 ? gfx::VectorIconId::ACCOUNT_CHILD | |
| 513 : gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
| 514 icon_size = profile_->IsChild() ? 26 : 20; | |
| 515 icon_color = SkColorSetRGB(0, 0x66, 0xff); | |
| 516 } | |
| 517 | 424 |
| 518 // Paint the badge icon. | 425 // Paint the badge icon. |
| 519 int offset = (GetProfileBadgeSize() - icon_size) / 2; | 426 int offset = (GetProfileBadgeSize() - icon_size) / 2; |
| 520 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); | 427 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); |
| 521 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color); | 428 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color); |
| 522 } | 429 } |
| 523 } | 430 } |
| 524 | 431 |
| 525 static int icon_image_side() { | 432 static int icon_image_side() { return kMdImageSide; } |
|
msarda
2017/02/23 11:51:02
Can this this function be replaced by a const?
jlebel
2017/02/23 18:18:49
Done.
| |
| 526 return switches::IsMaterialDesignUserMenu() ? kMdImageSide | |
| 527 : kLargeImageSide; | |
| 528 } | |
| 529 | 433 |
| 530 static int badge_spacing() { | 434 static int badge_spacing() { |
|
msarda
2017/02/23 11:51:03
Can this this function be replaced by a const?
jlebel
2017/02/23 18:18:49
Done.
| |
| 531 // The space between the right/bottom edge of the profile badge and the | 435 // The space between the right/bottom edge of the profile badge and the |
| 532 // right/bottom edge of the profile icon. | 436 // right/bottom edge of the profile icon. |
| 533 return switches::IsMaterialDesignUserMenu() ? 4 : 0; | 437 return 4; |
| 534 } | 438 } |
| 535 | 439 |
| 536 bool CanProcessEventsWithinSubtree() const override { return interactive_; } | |
| 537 | |
| 538 private: | 440 private: |
| 539 // views::CustomButton: | 441 // views::CustomButton: |
| 540 void StateChanged(ButtonState old_state) override { | 442 void StateChanged(ButtonState old_state) override { |
| 541 if (photo_overlay_) { | 443 if (photo_overlay_) { |
| 542 photo_overlay_->SetVisible( | 444 photo_overlay_->SetVisible( |
| 543 state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); | 445 state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); |
| 544 } | 446 } |
| 545 } | 447 } |
| 546 | 448 |
| 547 void OnFocus() override { | 449 void OnFocus() override { |
| 548 views::LabelButton::OnFocus(); | 450 views::LabelButton::OnFocus(); |
| 549 if (photo_overlay_) | 451 if (photo_overlay_) |
| 550 photo_overlay_->SetVisible(true); | 452 photo_overlay_->SetVisible(true); |
| 551 } | 453 } |
| 552 | 454 |
| 553 void OnBlur() override { | 455 void OnBlur() override { |
| 554 views::LabelButton::OnBlur(); | 456 views::LabelButton::OnBlur(); |
| 555 // Don't hide the overlay if it's being shown as a result of a mouseover. | 457 // Don't hide the overlay if it's being shown as a result of a mouseover. |
| 556 if (photo_overlay_ && state() != STATE_HOVERED) | 458 if (photo_overlay_ && state() != STATE_HOVERED) |
| 557 photo_overlay_->SetVisible(false); | 459 photo_overlay_->SetVisible(false); |
| 558 } | 460 } |
| 559 | 461 |
| 560 bool interactive_; | |
| 561 | |
| 562 // Image that is shown when hovering over the image button. Can be NULL if | 462 // Image that is shown when hovering over the image button. Can be NULL if |
| 563 // the photo isn't allowed to be edited (e.g. for guest profiles). | 463 // the photo isn't allowed to be edited (e.g. for guest profiles). |
| 564 views::ImageView* photo_overlay_; | 464 views::ImageView* photo_overlay_; |
| 565 | 465 |
| 566 Profile* profile_; | 466 Profile* profile_; |
| 567 | 467 |
| 568 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 468 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
| 569 }; | 469 }; |
| 570 | 470 |
| 571 // EditableProfileName ------------------------------------------------- | |
| 572 | |
| 573 // A custom text control that turns into a textfield for editing when clicked. | |
| 574 // Only used in non-material-design user menu. | |
| 575 class EditableProfileName : public views::View, | |
| 576 public views::ButtonListener { | |
| 577 public: | |
| 578 EditableProfileName(views::TextfieldController* controller, | |
| 579 const base::string16& text, | |
| 580 bool is_editing_allowed) | |
| 581 : button_(nullptr), profile_name_textfield_(nullptr) { | |
| 582 SetLayoutManager( | |
| 583 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | |
| 584 | |
| 585 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
| 586 const gfx::FontList& medium_font_list = | |
| 587 rb->GetFontList(ui::ResourceBundle::MediumFont); | |
| 588 const gfx::Insets textfield_border_insets = | |
| 589 views::Textfield().border()->GetInsets(); | |
| 590 | |
| 591 if (!is_editing_allowed) { | |
| 592 views::Label* name_label = new views::Label(text); | |
| 593 name_label->SetBorder(views::CreateEmptyBorder(textfield_border_insets)); | |
| 594 name_label->SetFontList(medium_font_list); | |
| 595 AddChildView(name_label); | |
| 596 return; | |
| 597 } | |
| 598 | |
| 599 profile_name_textfield_ = new views::Textfield(); | |
| 600 // Textfield that overlaps the button. | |
| 601 profile_name_textfield_->set_controller(controller); | |
| 602 profile_name_textfield_->SetFontList(medium_font_list); | |
| 603 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 604 profile_name_textfield_->SetVisible(false); | |
| 605 AddChildView(profile_name_textfield_); | |
| 606 | |
| 607 button_ = new RightAlignedIconLabelButton(this, text); | |
| 608 button_->SetFontListDeprecated(medium_font_list); | |
| 609 // Show an "edit" pencil icon when hovering over. In the default state, | |
| 610 // we need to create an empty placeholder of the correct size, so that | |
| 611 // the text doesn't jump around when the hovered icon appears. | |
| 612 // TODO(estade): revisit colors and press effect. | |
| 613 const int kIconSize = 16; | |
| 614 button_->SetImage(views::LabelButton::STATE_NORMAL, | |
| 615 CreateSquarePlaceholderImage(kIconSize)); | |
| 616 button_->SetImage(views::LabelButton::STATE_HOVERED, | |
| 617 gfx::CreateVectorIcon( | |
| 618 gfx::VectorIconId::MODE_EDIT, kIconSize, | |
| 619 SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 620 button_->SetImage(views::LabelButton::STATE_PRESSED, | |
| 621 gfx::CreateVectorIcon( | |
| 622 gfx::VectorIconId::MODE_EDIT, kIconSize, | |
| 623 SkColorSetRGB(0x20, 0x20, 0x20))); | |
| 624 // We need to add a left padding as well as a small top/bottom padding | |
| 625 // to the text to account for the textfield's border. | |
| 626 const int kIconTextLabelButtonSpacing = 5; | |
| 627 button_->SetBorder(views::CreateEmptyBorder( | |
| 628 textfield_border_insets + | |
| 629 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); | |
| 630 AddChildView(button_); | |
| 631 } | |
| 632 | |
| 633 views::Textfield* profile_name_textfield() { | |
| 634 return profile_name_textfield_; | |
| 635 } | |
| 636 | |
| 637 // Hide the editable textfield to show the profile name button instead. | |
| 638 void ShowReadOnlyView() { | |
| 639 button_->SetVisible(true); | |
| 640 profile_name_textfield_->SetVisible(false); | |
| 641 } | |
| 642 | |
| 643 private: | |
| 644 // views::ButtonListener: | |
| 645 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | |
| 646 button_->SetVisible(false); | |
| 647 profile_name_textfield_->SetVisible(true); | |
| 648 profile_name_textfield_->SetText(button_->GetText()); | |
| 649 profile_name_textfield_->SelectAll(false); | |
| 650 profile_name_textfield_->RequestFocus(); | |
| 651 // Re-layouts the view after swaping the controls. | |
| 652 Layout(); | |
| 653 } | |
| 654 | |
| 655 // views::LabelButton: | |
| 656 bool OnKeyReleased(const ui::KeyEvent& event) override { | |
| 657 // Override CustomButton's implementation, which presses the button when | |
| 658 // you press space and clicks it when you release space, as the space can be | |
| 659 // part of the new profile name typed in the textfield. | |
| 660 return false; | |
| 661 } | |
| 662 | |
| 663 // The label button which shows the profile name, and can handle the event to | |
| 664 // make it editable. Can be NULL if the profile name isn't allowed to be | |
| 665 // edited. | |
| 666 RightAlignedIconLabelButton* button_; | |
| 667 | |
| 668 // Textfield that is shown when editing the profile name. Can be NULL if | |
| 669 // the profile name isn't allowed to be edited (e.g. for guest profiles). | |
| 670 views::Textfield* profile_name_textfield_; | |
| 671 | |
| 672 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | |
| 673 }; | |
| 674 | |
| 675 // A title card with one back button right aligned and one label center aligned. | 471 // A title card with one back button right aligned and one label center aligned. |
| 676 class TitleCard : public views::View { | 472 class TitleCard : public views::View { |
| 677 public: | 473 public: |
| 678 TitleCard(const base::string16& message, views::ButtonListener* listener, | 474 TitleCard(const base::string16& message, views::ButtonListener* listener, |
| 679 views::ImageButton** back_button) { | 475 views::ImageButton** back_button) { |
| 680 back_button_ = CreateBackButton(listener); | 476 back_button_ = CreateBackButton(listener); |
| 681 *back_button = back_button_; | 477 *back_button = back_button_; |
| 682 | 478 |
| 683 title_label_ = new views::Label(message); | 479 title_label_ = new views::Label(message); |
| 684 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 480 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 profiles::TutorialMode tutorial_mode, | 553 profiles::TutorialMode tutorial_mode, |
| 758 const signin::ManageAccountsParams& manage_accounts_params, | 554 const signin::ManageAccountsParams& manage_accounts_params, |
| 759 signin_metrics::AccessPoint access_point, | 555 signin_metrics::AccessPoint access_point, |
| 760 views::View* anchor_view, | 556 views::View* anchor_view, |
| 761 Browser* browser) { | 557 Browser* browser) { |
| 762 // Don't start creating the view if it would be an empty fast user switcher. | 558 // Don't start creating the view if it would be an empty fast user switcher. |
| 763 // It has to happen here to prevent the view system from creating an empty | 559 // It has to happen here to prevent the view system from creating an empty |
| 764 // container. | 560 // container. |
| 765 // Same for material design user menu since fast profile switcher will be | 561 // Same for material design user menu since fast profile switcher will be |
| 766 // migrated to the left-click menu. | 562 // migrated to the left-click menu. |
| 767 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | 563 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
| 768 (!profiles::HasProfileSwitchTargets(browser->profile()) || | |
| 769 switches::IsMaterialDesignUserMenu())) { | |
| 770 return; | 564 return; |
| 771 } | 565 } |
| 772 | 566 |
| 773 if (IsShowing()) { | 567 if (IsShowing()) { |
| 774 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 568 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
| 775 profile_bubble_->tutorial_mode_ = tutorial_mode; | 569 profile_bubble_->tutorial_mode_ = tutorial_mode; |
| 776 profile_bubble_->ShowViewFromMode(view_mode); | 570 profile_bubble_->ShowViewFromMode(view_mode); |
| 777 } | 571 } |
| 778 return; | 572 return; |
| 779 } | 573 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 tutorial_learn_more_link_ = nullptr; | 630 tutorial_learn_more_link_ = nullptr; |
| 837 sync_error_signin_button_ = nullptr; | 631 sync_error_signin_button_ = nullptr; |
| 838 sync_error_passphrase_button_ = nullptr; | 632 sync_error_passphrase_button_ = nullptr; |
| 839 sync_error_upgrade_button_ = nullptr; | 633 sync_error_upgrade_button_ = nullptr; |
| 840 sync_error_signin_again_button_ = nullptr; | 634 sync_error_signin_again_button_ = nullptr; |
| 841 sync_error_signout_button_ = nullptr; | 635 sync_error_signout_button_ = nullptr; |
| 842 manage_accounts_link_ = nullptr; | 636 manage_accounts_link_ = nullptr; |
| 843 manage_accounts_button_ = nullptr; | 637 manage_accounts_button_ = nullptr; |
| 844 signin_current_profile_button_ = nullptr; | 638 signin_current_profile_button_ = nullptr; |
| 845 auth_error_email_button_ = nullptr; | 639 auth_error_email_button_ = nullptr; |
| 846 current_profile_photo_ = nullptr; | |
| 847 current_profile_name_ = nullptr; | |
| 848 current_profile_card_ = nullptr; | 640 current_profile_card_ = nullptr; |
| 849 guest_profile_button_ = nullptr; | 641 guest_profile_button_ = nullptr; |
| 850 users_button_ = nullptr; | 642 users_button_ = nullptr; |
| 851 go_incognito_button_ = nullptr; | 643 go_incognito_button_ = nullptr; |
| 852 lock_button_ = nullptr; | 644 lock_button_ = nullptr; |
| 853 close_all_windows_button_ = nullptr; | 645 close_all_windows_button_ = nullptr; |
| 854 add_account_link_ = nullptr; | 646 add_account_link_ = nullptr; |
| 855 gaia_signin_cancel_button_ = nullptr; | 647 gaia_signin_cancel_button_ = nullptr; |
| 856 remove_account_button_ = nullptr; | 648 remove_account_button_ = nullptr; |
| 857 account_removal_cancel_button_ = nullptr; | 649 account_removal_cancel_button_ = nullptr; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 } else if (sender == gaia_signin_cancel_button_) { | 912 } else if (sender == gaia_signin_cancel_button_) { |
| 1121 // The account management view is only available with the | 913 // The account management view is only available with the |
| 1122 // --enable-account-consistency flag. | 914 // --enable-account-consistency flag. |
| 1123 bool account_management_available = | 915 bool account_management_available = |
| 1124 SigninManagerFactory::GetForProfile(browser_->profile())-> | 916 SigninManagerFactory::GetForProfile(browser_->profile())-> |
| 1125 IsAuthenticated() && | 917 IsAuthenticated() && |
| 1126 switches::IsEnableAccountConsistency(); | 918 switches::IsEnableAccountConsistency(); |
| 1127 ShowViewFromMode(account_management_available ? | 919 ShowViewFromMode(account_management_available ? |
| 1128 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 920 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
| 1129 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 921 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
| 1130 } else if (sender == current_profile_photo_) { | |
| 1131 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | |
| 1132 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | |
| 1133 } else if (sender == current_profile_card_) { | 922 } else if (sender == current_profile_card_) { |
| 1134 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 923 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| 1135 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 924 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| 1136 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); | 925 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); |
| 1137 } else if (sender == manage_accounts_button_) { | 926 } else if (sender == manage_accounts_button_) { |
| 1138 // This button can either mean show/hide the account management view, | 927 // This button can either mean show/hide the account management view, |
| 1139 // depending on which view it is displayed. | 928 // depending on which view it is displayed. |
| 1140 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT | 929 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT |
| 1141 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER | 930 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER |
| 1142 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | 931 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | 1011 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
| 1223 } | 1012 } |
| 1224 } | 1013 } |
| 1225 | 1014 |
| 1226 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, | 1015 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, |
| 1227 const gfx::Range& range, | 1016 const gfx::Range& range, |
| 1228 int event_flags) { | 1017 int event_flags) { |
| 1229 chrome::ShowSettings(browser_); | 1018 chrome::ShowSettings(browser_); |
| 1230 } | 1019 } |
| 1231 | 1020 |
| 1232 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, | |
| 1233 const ui::KeyEvent& key_event) { | |
| 1234 if (key_event.type() != ui::ET_KEY_PRESSED) | |
| 1235 return false; | |
| 1236 | |
| 1237 views::Textfield* name_textfield = | |
| 1238 current_profile_name_->profile_name_textfield(); | |
| 1239 DCHECK(sender == name_textfield); | |
| 1240 | |
| 1241 if (key_event.key_code() == ui::VKEY_RETURN || | |
| 1242 key_event.key_code() == ui::VKEY_TAB) { | |
| 1243 // Pressing Tab/Enter commits the new profile name, unless it's empty. | |
| 1244 base::string16 new_profile_name = name_textfield->text(); | |
| 1245 base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name); | |
| 1246 if (new_profile_name.empty()) | |
| 1247 return true; | |
| 1248 | |
| 1249 const AvatarMenu::Item& active_item = avatar_menu_->GetItemAt( | |
| 1250 avatar_menu_->GetActiveProfileIndex()); | |
| 1251 Profile* profile = g_browser_process->profile_manager()->GetProfile( | |
| 1252 active_item.profile_path); | |
| 1253 DCHECK(profile); | |
| 1254 | |
| 1255 if (profile->IsLegacySupervised()) | |
| 1256 return true; | |
| 1257 | |
| 1258 profiles::UpdateProfileName(profile, new_profile_name); | |
| 1259 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); | |
| 1260 current_profile_name_->ShowReadOnlyView(); | |
| 1261 return true; | |
| 1262 } | |
| 1263 return false; | |
| 1264 } | |
| 1265 | |
| 1266 void ProfileChooserView::PopulateCompleteProfileChooserView( | 1021 void ProfileChooserView::PopulateCompleteProfileChooserView( |
| 1267 views::GridLayout* layout, | 1022 views::GridLayout* layout, |
| 1268 AvatarMenu* avatar_menu) { | 1023 AvatarMenu* avatar_menu) { |
| 1269 // Separate items into active and alternatives. | 1024 // Separate items into active and alternatives. |
| 1270 Indexes other_profiles; | 1025 Indexes other_profiles; |
| 1271 views::View* tutorial_view = NULL; | 1026 views::View* tutorial_view = NULL; |
| 1272 views::View* sync_error_view = NULL; | 1027 views::View* sync_error_view = NULL; |
| 1273 views::View* current_profile_view = NULL; | 1028 views::View* current_profile_view = NULL; |
| 1274 views::View* current_profile_accounts = NULL; | 1029 views::View* current_profile_accounts = NULL; |
| 1275 views::View* option_buttons_view = NULL; | 1030 views::View* option_buttons_view = NULL; |
| 1276 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1031 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1277 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1032 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1278 if (item.active) { | 1033 if (item.active) { |
| 1279 option_buttons_view = CreateOptionsView( | 1034 option_buttons_view = CreateOptionsView( |
| 1280 item.signed_in && profiles::IsLockAvailable(browser_->profile()), | 1035 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
| 1281 avatar_menu); | 1036 avatar_menu); |
| 1282 current_profile_view = | 1037 current_profile_view = |
| 1283 switches::IsMaterialDesignUserMenu() | 1038 CreateMaterialDesignCurrentProfileView(item, false); |
| 1284 ? CreateMaterialDesignCurrentProfileView(item, false) | 1039 if (!IsProfileChooser(view_mode_)) { |
| 1285 : CreateCurrentProfileView(item, false); | |
| 1286 if (IsProfileChooser(view_mode_)) { | |
| 1287 if (!switches::IsMaterialDesignUserMenu()) | |
| 1288 tutorial_view = CreateTutorialViewIfNeeded(item); | |
| 1289 } else { | |
| 1290 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1040 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
| 1291 } | 1041 } |
| 1292 if (switches::IsMaterialDesignUserMenu()) | 1042 sync_error_view = CreateSyncErrorViewIfNeeded(); |
| 1293 sync_error_view = CreateSyncErrorViewIfNeeded(); | |
| 1294 } else { | 1043 } else { |
| 1295 other_profiles.push_back(i); | 1044 other_profiles.push_back(i); |
| 1296 } | 1045 } |
| 1297 } | 1046 } |
| 1298 | 1047 |
| 1299 if (tutorial_view) { | 1048 if (tutorial_view) { |
| 1300 // TODO(mlerman): update UMA stats for the new tutorial. | 1049 // TODO(mlerman): update UMA stats for the new tutorial. |
| 1301 layout->StartRow(1, 0); | 1050 layout->StartRow(1, 0); |
| 1302 layout->AddView(tutorial_view); | 1051 layout->AddView(tutorial_view); |
| 1303 } else { | 1052 } else { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1322 | 1071 |
| 1323 if (!IsProfileChooser(view_mode_)) { | 1072 if (!IsProfileChooser(view_mode_)) { |
| 1324 DCHECK(current_profile_accounts); | 1073 DCHECK(current_profile_accounts); |
| 1325 layout->StartRow(0, 0); | 1074 layout->StartRow(0, 0); |
| 1326 layout->AddView(new views::Separator()); | 1075 layout->AddView(new views::Separator()); |
| 1327 layout->StartRow(1, 0); | 1076 layout->StartRow(1, 0); |
| 1328 layout->AddView(current_profile_accounts); | 1077 layout->AddView(current_profile_accounts); |
| 1329 } | 1078 } |
| 1330 | 1079 |
| 1331 if (browser_->profile()->IsSupervised()) { | 1080 if (browser_->profile()->IsSupervised()) { |
| 1332 if (!switches::IsMaterialDesignUserMenu()) { | |
| 1333 layout->StartRow(0, 0); | |
| 1334 layout->AddView(new views::Separator()); | |
| 1335 } | |
| 1336 layout->StartRow(1, 0); | 1081 layout->StartRow(1, 0); |
| 1337 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1082 layout->AddView(CreateSupervisedUserDisclaimerView()); |
| 1338 } | 1083 } |
| 1339 | 1084 |
| 1340 layout->StartRow(0, 0); | 1085 layout->StartRow(0, 0); |
| 1341 layout->AddView(new views::Separator()); | 1086 layout->AddView(new views::Separator()); |
| 1342 | 1087 |
| 1343 if (option_buttons_view) { | 1088 if (option_buttons_view) { |
| 1344 layout->StartRow(0, 0); | 1089 layout->StartRow(0, 0); |
| 1345 layout->AddView(option_buttons_view); | 1090 layout->AddView(option_buttons_view); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 this, l10n_util::GetStringUTF16(button_string_id)); | 1367 this, l10n_util::GetStringUTF16(button_string_id)); |
| 1623 vertical_view->AddChildView(*button_out); | 1368 vertical_view->AddChildView(*button_out); |
| 1624 view->SetBorder(views::CreateEmptyBorder( | 1369 view->SetBorder(views::CreateEmptyBorder( |
| 1625 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); | 1370 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); |
| 1626 } | 1371 } |
| 1627 | 1372 |
| 1628 view->AddChildView(vertical_view); | 1373 view->AddChildView(vertical_view); |
| 1629 return view; | 1374 return view; |
| 1630 } | 1375 } |
| 1631 | 1376 |
| 1632 views::View* ProfileChooserView::CreateCurrentProfileView( | |
| 1633 const AvatarMenu::Item& avatar_item, | |
| 1634 bool is_guest) { | |
| 1635 views::View* view = new views::View(); | |
| 1636 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; | |
| 1637 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | |
| 1638 layout->SetInsets(views::kButtonVEdgeMarginNew, | |
| 1639 views::kButtonHEdgeMarginNew, | |
| 1640 views::kUnrelatedControlVerticalSpacing, | |
| 1641 views::kButtonHEdgeMarginNew); | |
| 1642 | |
| 1643 // Profile icon, centered. | |
| 1644 int x_offset = (column_width - kLargeImageSide) / 2; | |
| 1645 current_profile_photo_ = new EditableProfilePhoto( | |
| 1646 this, avatar_item.icon, !is_guest, browser_->profile()); | |
| 1647 current_profile_photo_->SetX(x_offset); | |
| 1648 SizedContainer* profile_icon_container = | |
| 1649 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | |
| 1650 profile_icon_container->AddChildView(current_profile_photo_); | |
| 1651 | |
| 1652 | |
| 1653 layout->StartRow(1, 0); | |
| 1654 layout->AddView(profile_icon_container); | |
| 1655 | |
| 1656 // Profile name, centered. | |
| 1657 bool editing_allowed = !is_guest && | |
| 1658 !browser_->profile()->IsLegacySupervised(); | |
| 1659 current_profile_name_ = new EditableProfileName( | |
| 1660 this, | |
| 1661 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
| 1662 editing_allowed); | |
| 1663 layout->StartRowWithPadding(1, 0, 0, | |
| 1664 views::kRelatedControlSmallVerticalSpacing); | |
| 1665 layout->StartRow(1, 0); | |
| 1666 layout->AddView(current_profile_name_); | |
| 1667 | |
| 1668 if (is_guest) | |
| 1669 return view; | |
| 1670 | |
| 1671 // The available links depend on the type of profile that is active. | |
| 1672 if (avatar_item.signed_in) { | |
| 1673 layout->StartRow(1, 0); | |
| 1674 if (switches::IsEnableAccountConsistency()) { | |
| 1675 base::string16 link_title = l10n_util::GetStringUTF16( | |
| 1676 IsProfileChooser(view_mode_) ? | |
| 1677 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : | |
| 1678 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
| 1679 manage_accounts_link_ = CreateLink(link_title, this); | |
| 1680 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 1681 layout->AddView(manage_accounts_link_); | |
| 1682 } else { | |
| 1683 // Badge the email address if there's an authentication error. | |
| 1684 if (HasAuthError(browser_->profile())) { | |
| 1685 auth_error_email_button_ = | |
| 1686 new RightAlignedIconLabelButton(this, avatar_item.username); | |
| 1687 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | |
| 1688 auth_error_email_button_->SetImage( | |
| 1689 views::LabelButton::STATE_NORMAL, | |
| 1690 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, | |
| 1691 gfx::kChromeIconGrey)); | |
| 1692 auth_error_email_button_->SetFocusForPlatform(); | |
| 1693 gfx::Insets insets = | |
| 1694 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | |
| 1695 views::Button::STYLE_TEXTBUTTON); | |
| 1696 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( | |
| 1697 insets.top(), insets.left(), insets.bottom(), insets.right())); | |
| 1698 layout->AddView(auth_error_email_button_); | |
| 1699 } else { | |
| 1700 // Add a small padding between the email button and the profile name. | |
| 1701 layout->StartRowWithPadding(1, 0, 0, 2); | |
| 1702 views::Label* email_label = new views::Label(avatar_item.username); | |
| 1703 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
| 1704 email_label->SetEnabled(false); | |
| 1705 layout->AddView(email_label); | |
| 1706 } | |
| 1707 } | |
| 1708 } else { | |
| 1709 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
| 1710 browser_->profile()->GetOriginalProfile()); | |
| 1711 if (signin_manager->IsSigninAllowed()) { | |
| 1712 views::Label* promo = new views::Label( | |
| 1713 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
| 1714 promo->SetMultiLine(true); | |
| 1715 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 1716 layout->StartRowWithPadding(1, 0, 0, | |
| 1717 views::kRelatedControlSmallVerticalSpacing); | |
| 1718 layout->StartRow(1, 0); | |
| 1719 layout->AddView(promo); | |
| 1720 | |
| 1721 signin_current_profile_button_ = | |
| 1722 views::MdTextButton::CreateSecondaryUiBlueButton( | |
| 1723 this, l10n_util::GetStringFUTF16( | |
| 1724 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
| 1725 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
| 1726 layout->StartRowWithPadding(1, 0, 0, | |
| 1727 views::kRelatedControlVerticalSpacing); | |
| 1728 layout->StartRow(1, 0); | |
| 1729 layout->AddView(signin_current_profile_button_); | |
| 1730 content::RecordAction( | |
| 1731 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
| 1732 } | |
| 1733 } | |
| 1734 | |
| 1735 return view; | |
| 1736 } | |
| 1737 | |
| 1738 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | 1377 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| 1739 const AvatarMenu::Item& avatar_item, | 1378 const AvatarMenu::Item& avatar_item, |
| 1740 bool is_guest) { | 1379 bool is_guest) { |
| 1741 views::View* view = new views::View(); | 1380 views::View* view = new views::View(); |
| 1742 view->SetLayoutManager( | 1381 view->SetLayoutManager( |
| 1743 new views::BoxLayout(views::BoxLayout::kVertical, 0, | 1382 new views::BoxLayout(views::BoxLayout::kVertical, 0, |
| 1744 views::kRelatedControlVerticalSpacing, 0)); | 1383 views::kRelatedControlVerticalSpacing, 0)); |
| 1745 | 1384 |
| 1746 // Container for the profile photo and avatar/user name. | 1385 // Container for the profile photo and avatar/user name. |
| 1747 BackgroundColorHoverButton* current_profile_card = | 1386 BackgroundColorHoverButton* current_profile_card = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 views::View* ProfileChooserView::CreateGuestProfileView() { | 1503 views::View* ProfileChooserView::CreateGuestProfileView() { |
| 1865 gfx::Image guest_icon = | 1504 gfx::Image guest_icon = |
| 1866 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1505 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 1867 profiles::GetPlaceholderAvatarIconResourceID()); | 1506 profiles::GetPlaceholderAvatarIconResourceID()); |
| 1868 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1507 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
| 1869 guest_avatar_item.active = true; | 1508 guest_avatar_item.active = true; |
| 1870 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1509 guest_avatar_item.name = l10n_util::GetStringUTF16( |
| 1871 IDS_PROFILES_GUEST_PROFILE_NAME); | 1510 IDS_PROFILES_GUEST_PROFILE_NAME); |
| 1872 guest_avatar_item.signed_in = false; | 1511 guest_avatar_item.signed_in = false; |
| 1873 | 1512 |
| 1874 return switches::IsMaterialDesignUserMenu() | 1513 return CreateMaterialDesignCurrentProfileView(guest_avatar_item, true); |
| 1875 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
| 1876 : CreateCurrentProfileView(guest_avatar_item, true); | |
| 1877 } | 1514 } |
| 1878 | 1515 |
| 1879 views::View* ProfileChooserView::CreateOtherProfilesView( | 1516 views::View* ProfileChooserView::CreateOtherProfilesView( |
| 1880 const Indexes& avatars_to_show) { | 1517 const Indexes& avatars_to_show) { |
| 1881 views::View* view = new views::View(); | 1518 views::View* view = new views::View(); |
| 1882 views::GridLayout* layout = | 1519 views::GridLayout* layout = |
| 1883 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | 1520 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
| 1884 | 1521 |
| 1885 for (size_t index : avatars_to_show) { | 1522 for (size_t index : avatars_to_show) { |
| 1886 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1523 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1909 return view; | 1546 return view; |
| 1910 } | 1547 } |
| 1911 | 1548 |
| 1912 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, | 1549 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| 1913 AvatarMenu* avatar_menu) { | 1550 AvatarMenu* avatar_menu) { |
| 1914 views::View* view = new views::View(); | 1551 views::View* view = new views::View(); |
| 1915 views::GridLayout* layout = | 1552 views::GridLayout* layout = |
| 1916 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | 1553 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
| 1917 | 1554 |
| 1918 const bool is_guest = browser_->profile()->IsGuestSession(); | 1555 const bool is_guest = browser_->profile()->IsGuestSession(); |
| 1919 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; | 1556 const int kIconSize = 20; |
| 1920 if (switches::IsMaterialDesignUserMenu()) { | 1557 // Add the user switching buttons |
| 1921 // Add the user switching buttons | 1558 const int kProfileIconSize = 18; |
| 1922 const int kProfileIconSize = 18; | 1559 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 1923 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1560 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1924 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1561 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1925 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1562 if (!item.active) { |
| 1926 if (!item.active) { | 1563 gfx::Image image = profiles::GetSizedAvatarIcon( |
| 1927 gfx::Image image = profiles::GetSizedAvatarIcon( | 1564 item.icon, true, kProfileIconSize, kProfileIconSize, |
| 1928 item.icon, true, kProfileIconSize, kProfileIconSize, | 1565 profiles::SHAPE_CIRCLE); |
| 1929 profiles::SHAPE_CIRCLE); | 1566 views::LabelButton* button = new BackgroundColorHoverButton( |
| 1930 views::LabelButton* button = new BackgroundColorHoverButton( | 1567 this, profiles::GetProfileSwitcherTextForItem(item), |
| 1931 this, profiles::GetProfileSwitcherTextForItem(item), | 1568 *image.ToImageSkia()); |
| 1932 *image.ToImageSkia()); | 1569 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); |
| 1933 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); | 1570 open_other_profile_indexes_map_[button] = i; |
| 1934 open_other_profile_indexes_map_[button] = i; | |
| 1935 | 1571 |
| 1936 layout->StartRow(1, 0); | 1572 layout->StartRow(1, 0); |
| 1937 layout->AddView(button); | 1573 layout->AddView(button); |
| 1938 } | |
| 1939 } | |
| 1940 | |
| 1941 // Add the "Guest" button for browsing as guest | |
| 1942 if (!is_guest) { | |
| 1943 PrefService* service = g_browser_process->local_state(); | |
| 1944 DCHECK(service); | |
| 1945 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | |
| 1946 guest_profile_button_ = new BackgroundColorHoverButton( | |
| 1947 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | |
| 1948 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, | |
| 1949 gfx::kChromeIconGrey)); | |
| 1950 layout->StartRow(1, 0); | |
| 1951 layout->AddView(guest_profile_button_); | |
| 1952 } | |
| 1953 } | 1574 } |
| 1954 } | 1575 } |
| 1955 | 1576 |
| 1956 base::string16 text; | 1577 // Add the "Guest" button for browsing as guest |
| 1957 gfx::VectorIconId settings_icon; | 1578 if (!is_guest) { |
| 1958 if (switches::IsMaterialDesignUserMenu()) { | 1579 PrefService* service = g_browser_process->local_state(); |
| 1959 text = is_guest | 1580 DCHECK(service); |
| 1960 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) | 1581 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| 1582 guest_profile_button_ = new BackgroundColorHoverButton( | |
| 1583 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | |
| 1584 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, | |
| 1585 gfx::kChromeIconGrey)); | |
| 1586 layout->StartRow(1, 0); | |
| 1587 layout->AddView(guest_profile_button_); | |
| 1588 } | |
| 1589 } | |
| 1590 | |
| 1591 base::string16 text = | |
| 1592 is_guest ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) | |
| 1961 : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1593 : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
| 1962 settings_icon = | 1594 gfx::VectorIconId settings_icon = |
| 1963 is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; | 1595 is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; |
| 1964 } else { | |
| 1965 text = is_guest | |
| 1966 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) | |
| 1967 : l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | |
| 1968 settings_icon = gfx::VectorIconId::ACCOUNT_BOX; | |
| 1969 } | |
| 1970 users_button_ = new BackgroundColorHoverButton( | 1596 users_button_ = new BackgroundColorHoverButton( |
| 1971 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, | 1597 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, |
| 1972 gfx::kChromeIconGrey)); | 1598 gfx::kChromeIconGrey)); |
| 1973 | 1599 |
| 1974 layout->StartRow(1, 0); | 1600 layout->StartRow(1, 0); |
| 1975 layout->AddView(users_button_); | 1601 layout->AddView(users_button_); |
| 1976 | 1602 |
| 1977 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | |
| 1978 layout->StartRow(1, 0); | |
| 1979 layout->AddView(new views::Separator()); | |
| 1980 | |
| 1981 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
| 1982 go_incognito_button_ = new BackgroundColorHoverButton( | |
| 1983 this, | |
| 1984 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | |
| 1985 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | |
| 1986 layout->StartRow(1, 0); | |
| 1987 layout->AddView(go_incognito_button_); | |
| 1988 } | |
| 1989 | |
| 1990 if (display_lock) { | 1603 if (display_lock) { |
| 1991 if (!switches::IsMaterialDesignUserMenu()) { | |
| 1992 layout->StartRow(1, 0); | |
| 1993 layout->AddView(new views::Separator()); | |
| 1994 } | |
| 1995 | |
| 1996 lock_button_ = new BackgroundColorHoverButton( | 1604 lock_button_ = new BackgroundColorHoverButton( |
| 1997 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1605 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
| 1998 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | 1606 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
| 1999 gfx::kChromeIconGrey)); | 1607 gfx::kChromeIconGrey)); |
| 2000 layout->StartRow(1, 0); | 1608 layout->StartRow(1, 0); |
| 2001 layout->AddView(lock_button_); | 1609 layout->AddView(lock_button_); |
| 2002 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { | 1610 } else if (!is_guest) { |
| 2003 int num_browsers = 0; | 1611 int num_browsers = 0; |
| 2004 for (auto* browser : *BrowserList::GetInstance()) { | 1612 for (auto* browser : *BrowserList::GetInstance()) { |
| 2005 if (browser->profile()->GetOriginalProfile() == | 1613 if (browser->profile()->GetOriginalProfile() == |
| 2006 browser_->profile()->GetOriginalProfile()) | 1614 browser_->profile()->GetOriginalProfile()) |
| 2007 num_browsers++; | 1615 num_browsers++; |
| 2008 } | 1616 } |
| 2009 if (num_browsers > 1) { | 1617 if (num_browsers > 1) { |
| 2010 close_all_windows_button_ = new BackgroundColorHoverButton( | 1618 close_all_windows_button_ = new BackgroundColorHoverButton( |
| 2011 this, | 1619 this, |
| 2012 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), | 1620 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), |
| 2013 gfx::CreateVectorIcon(gfx::VectorIconId::CLOSE_ALL, kIconSize, | 1621 gfx::CreateVectorIcon(gfx::VectorIconId::CLOSE_ALL, kIconSize, |
| 2014 gfx::kChromeIconGrey)); | 1622 gfx::kChromeIconGrey)); |
| 2015 layout->StartRow(1, 0); | 1623 layout->StartRow(1, 0); |
| 2016 layout->AddView(close_all_windows_button_); | 1624 layout->AddView(close_all_windows_button_); |
| 2017 } | 1625 } |
| 2018 } | 1626 } |
| 2019 | 1627 |
| 2020 if (switches::IsMaterialDesignUserMenu()) | 1628 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 2021 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | |
| 2022 return view; | 1629 return view; |
| 2023 } | 1630 } |
| 2024 | 1631 |
| 2025 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1632 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
| 2026 views::View* view = new views::View(); | 1633 views::View* view = new views::View(); |
| 2027 int horizontal_margin = switches::IsMaterialDesignUserMenu() ? | 1634 int horizontal_margin = kMaterialMenuEdgeMargin; |
| 2028 kMaterialMenuEdgeMargin : views::kButtonHEdgeMarginNew; | |
| 2029 views::GridLayout* layout = CreateSingleColumnLayout( | 1635 views::GridLayout* layout = CreateSingleColumnLayout( |
| 2030 view, GetFixedMenuWidth() - 2 * horizontal_margin); | 1636 view, GetFixedMenuWidth() - 2 * horizontal_margin); |
| 2031 if (switches::IsMaterialDesignUserMenu()) { | 1637 layout->SetInsets(0, horizontal_margin, kMaterialMenuEdgeMargin, |
| 2032 layout->SetInsets(0, horizontal_margin, | 1638 horizontal_margin); |
| 2033 kMaterialMenuEdgeMargin, horizontal_margin); | |
| 2034 } else { | |
| 2035 layout->SetInsets( | |
| 2036 views::kRelatedControlVerticalSpacing, horizontal_margin, | |
| 2037 views::kRelatedControlVerticalSpacing, horizontal_margin); | |
| 2038 } | |
| 2039 | 1639 |
| 2040 views::Label* disclaimer = new views::Label( | 1640 views::Label* disclaimer = new views::Label( |
| 2041 avatar_menu_->GetSupervisedUserInformation()); | 1641 avatar_menu_->GetSupervisedUserInformation()); |
| 2042 disclaimer->SetMultiLine(true); | 1642 disclaimer->SetMultiLine(true); |
| 2043 disclaimer->SetAllowCharacterBreak(true); | 1643 disclaimer->SetAllowCharacterBreak(true); |
| 2044 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1644 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 2045 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1645 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 2046 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1646 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 2047 layout->StartRow(1, 0); | 1647 layout->StartRow(1, 0); |
| 2048 layout->AddView(disclaimer); | 1648 layout->AddView(disclaimer); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2380 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1980 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2381 IncognitoModePrefs::DISABLED; | 1981 IncognitoModePrefs::DISABLED; |
| 2382 return incognito_available && !browser_->profile()->IsGuestSession(); | 1982 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2383 } | 1983 } |
| 2384 | 1984 |
| 2385 void ProfileChooserView::PostActionPerformed( | 1985 void ProfileChooserView::PostActionPerformed( |
| 2386 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1986 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2387 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1987 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2388 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1988 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2389 } | 1989 } |
| OLD | NEW |