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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 #include "ui/views/layout/box_layout.h" | 76 #include "ui/views/layout/box_layout.h" |
| 77 #include "ui/views/layout/fill_layout.h" | 77 #include "ui/views/layout/fill_layout.h" |
| 78 #include "ui/views/layout/grid_layout.h" | 78 #include "ui/views/layout/grid_layout.h" |
| 79 #include "ui/views/layout/layout_constants.h" | 79 #include "ui/views/layout/layout_constants.h" |
| 80 #include "ui/views/widget/widget.h" | 80 #include "ui/views/widget/widget.h" |
| 81 | 81 |
| 82 namespace { | 82 namespace { |
| 83 | 83 |
| 84 // Helpers -------------------------------------------------------------------- | 84 // Helpers -------------------------------------------------------------------- |
| 85 | 85 |
| 86 const int kFixedMenuWidth = 250; | |
| 87 const int kButtonHeight = 32; | 86 const int kButtonHeight = 32; |
| 88 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 87 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| 89 const int kFixedGaiaViewWidth = 448; | 88 const int kFixedGaiaViewWidth = 448; |
| 90 const int kFixedAccountRemovalViewWidth = 280; | 89 const int kFixedAccountRemovalViewWidth = 280; |
| 91 const int kFixedSwitchUserViewWidth = 320; | 90 const int kFixedSwitchUserViewWidth = 320; |
| 92 const int kLargeImageSide = 88; | 91 const int kLargeImageSide = 88; |
| 92 const int kMdImageSide = 40; | |
| 93 | |
| 94 // Spacing between the edge of the material design user menu and the | |
| 95 // top/bottom or left/right of the menu items. | |
| 96 const int kMaterialMenuEdgeMargin = 16; | |
| 93 | 97 |
| 94 const int kVerticalSpacing = 16; | 98 const int kVerticalSpacing = 16; |
| 95 | 99 |
| 96 const int kTitleViewNativeWidgetOffset = 8; | 100 const int kTitleViewNativeWidgetOffset = 8; |
| 97 | 101 |
| 98 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 102 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| 99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 103 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
| 100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 104 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 101 } | 105 } |
| 102 | 106 |
| 107 int GetProfileBadgeSize() { | |
| 108 return switches::IsMaterialDesignUserMenu() ? 24 : 30; | |
| 109 } | |
| 110 | |
| 111 // DEPRECATED: New user menu components should use views::BoxLayout instead. | |
| 103 // Creates a GridLayout with a single column. This ensures that all the child | 112 // Creates a GridLayout with a single column. This ensures that all the child |
| 104 // views added get auto-expanded to fill the full width of the bubble. | 113 // views added get auto-expanded to fill the full width of the bubble. |
| 105 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 114 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
| 106 views::GridLayout* layout = new views::GridLayout(view); | 115 views::GridLayout* layout = new views::GridLayout(view); |
| 107 view->SetLayoutManager(layout); | 116 view->SetLayoutManager(layout); |
| 108 | 117 |
| 109 views::ColumnSet* columns = layout->AddColumnSet(0); | 118 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 110 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 119 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 111 views::GridLayout::FIXED, width, width); | 120 views::GridLayout::FIXED, width, width); |
| 112 return layout; | 121 return layout; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 gfx::Rect bounds(title_view_->GetPreferredSize()); | 265 gfx::Rect bounds(title_view_->GetPreferredSize()); |
| 257 title_view_->SetBoundsRect(bounds); | 266 title_view_->SetBoundsRect(bounds); |
| 258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 267 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
| 259 title_widget_->SetBounds(bounds); | 268 title_widget_->SetBounds(bounds); |
| 260 } | 269 } |
| 261 | 270 |
| 262 } // namespace | 271 } // namespace |
| 263 | 272 |
| 264 // RightAlignedIconLabelButton ------------------------------------------------- | 273 // RightAlignedIconLabelButton ------------------------------------------------- |
| 265 | 274 |
| 266 // A custom LabelButton that has a centered text and right aligned icon. | 275 // A custom LabelButton that has a left-aligned text and right aligned icon. |
| 276 // For non-material-design user menu, it has centered text instead. | |
| 267 class RightAlignedIconLabelButton : public views::LabelButton { | 277 class RightAlignedIconLabelButton : public views::LabelButton { |
| 268 public: | 278 public: |
| 269 RightAlignedIconLabelButton(views::ButtonListener* listener, | 279 RightAlignedIconLabelButton(views::ButtonListener* listener, |
| 270 const base::string16& text) | 280 const base::string16& text) |
| 271 : views::LabelButton(listener, text) { | 281 : views::LabelButton(listener, text) { |
| 272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 282 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| 273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 283 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
| 284 ? gfx::ALIGN_LEFT | |
| 285 : gfx::ALIGN_CENTER); | |
| 274 } | 286 } |
| 275 | 287 |
| 276 protected: | 288 protected: |
| 277 void Layout() override { | 289 void Layout() override { |
| 278 views::LabelButton::Layout(); | 290 views::LabelButton::Layout(); |
| 279 | 291 |
| 280 // Keep the text centered and the icon right-aligned by stretching the label | 292 // Keep the text centered and the icon right-aligned by stretching the label |
| 281 // to take up more of the content area and centering its contents. | 293 // to take up more of the content area and centering its contents. |
| 282 gfx::Rect content_bounds = GetContentsBounds(); | 294 gfx::Rect content_bounds = GetContentsBounds(); |
| 283 gfx::Rect label_bounds = label()->bounds(); | 295 gfx::Rect label_bounds = label()->bounds(); |
| 284 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); | 296 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); |
| 285 label()->SetBoundsRect(label_bounds); | 297 label()->SetBoundsRect(label_bounds); |
| 286 } | 298 } |
| 287 | 299 |
| 288 private: | 300 private: |
| 289 void OnFocus() override { | 301 void OnFocus() override { |
| 290 SetState(STATE_HOVERED); | 302 SetState(STATE_HOVERED); |
| 291 } | 303 } |
| 292 | 304 |
| 293 void OnBlur() override { | 305 void OnBlur() override { |
| 294 SetState(STATE_NORMAL); | 306 SetState(STATE_NORMAL); |
| 295 } | 307 } |
| 296 | 308 |
| 297 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | 309 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
| 298 }; | 310 }; |
| 299 | 311 |
| 300 // EditableProfilePhoto ------------------------------------------------- | 312 // EditableProfilePhoto ------------------------------------------------- |
| 301 | 313 |
| 314 const size_t kProfileBadgeWhitePadding = 2; | |
| 315 | |
| 302 // A custom Image control that shows a "change" button when moused over. | 316 // A custom Image control that shows a "change" button when moused over. |
| 303 class EditableProfilePhoto : public views::LabelButton { | 317 class EditableProfilePhoto : public views::LabelButton { |
| 304 public: | 318 public: |
| 305 EditableProfilePhoto(views::ButtonListener* listener, | 319 EditableProfilePhoto(views::ButtonListener* listener, |
| 306 const gfx::Image& icon, | 320 const gfx::Image& icon, |
| 307 bool is_editing_allowed, | 321 bool is_editing_allowed, |
| 308 const gfx::Rect& bounds) | 322 Profile* profile) |
| 309 : views::LabelButton(listener, base::string16()), | 323 : views::LabelButton(listener, base::string16()), |
| 310 photo_overlay_(NULL) { | 324 photo_overlay_(nullptr), |
| 311 gfx::Image image = profiles::GetSizedAvatarIcon( | 325 profile_(profile) { |
| 312 icon, true, kLargeImageSide, kLargeImageSide); | 326 const int icon_image_side = |
| 327 switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide; | |
| 328 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side, | |
| 329 icon_image_side); | |
| 313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 330 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
| 314 SetBorder(views::Border::NullBorder()); | 331 SetBorder(views::Border::NullBorder()); |
| 315 SetBoundsRect(bounds); | 332 SetSize(GetPreferredSize()); |
| 316 | 333 |
| 317 // Calculate the circular mask that will be used to display the photo. | 334 // Calculate the circular mask that will be used to display the photo. |
| 318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 335 circular_mask_.addCircle(SkIntToScalar(icon_image_side / 2), |
| 319 SkIntToScalar(bounds.height() / 2), | 336 SkIntToScalar(icon_image_side / 2), |
| 320 SkIntToScalar(bounds.width() / 2)); | 337 SkIntToScalar(icon_image_side / 2)); |
| 321 | 338 |
| 322 if (!is_editing_allowed) { | 339 if (!is_editing_allowed) { |
| 323 SetEnabled(false); | 340 SetEnabled(false); |
| 324 return; | 341 return; |
| 325 } | 342 } |
| 326 | 343 |
| 327 set_notify_enter_exit_on_child(true); | 344 set_notify_enter_exit_on_child(true); |
| 328 | 345 |
| 329 // Photo overlay that appears when hovering over the button. | 346 // Photo overlay that appears when hovering over the button. |
| 330 photo_overlay_ = new views::ImageView(); | 347 photo_overlay_ = new views::ImageView(); |
| 331 | 348 |
| 332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 349 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
| 333 photo_overlay_->set_background( | 350 photo_overlay_->set_background( |
| 334 views::Background::CreateSolidBackground(kBackgroundColor)); | 351 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 335 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 352 photo_overlay_->SetImage( |
| 336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 353 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA, |
| 354 switches::IsMaterialDesignUserMenu() ? 22u : 48u, | |
| 355 SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 337 | 356 |
| 338 photo_overlay_->SetSize(bounds.size()); | 357 photo_overlay_->SetSize(gfx::Size(icon_image_side, icon_image_side)); |
| 339 photo_overlay_->SetVisible(false); | 358 photo_overlay_->SetVisible(false); |
| 340 AddChildView(photo_overlay_); | 359 AddChildView(photo_overlay_); |
| 341 } | 360 } |
| 342 | 361 |
| 343 void OnPaint(gfx::Canvas* canvas) override { | 362 void OnPaint(gfx::Canvas* canvas) override { |
| 363 canvas->Save(); | |
| 344 // Display the profile picture as a circle. | 364 // Display the profile picture as a circle. |
| 345 canvas->ClipPath(circular_mask_, true); | 365 canvas->ClipPath(circular_mask_, true); |
| 346 views::LabelButton::OnPaint(canvas); | 366 views::LabelButton::OnPaint(canvas); |
| 367 canvas->Restore(); | |
| 368 | |
| 369 if (profile_->IsSupervised()) { | |
| 370 gfx::VectorIconId icon_id; | |
| 371 size_t icon_size; | |
| 372 if (profile_->IsChild()) { | |
| 373 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT; | |
| 374 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26; | |
| 375 } else { | |
| 376 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
| 377 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20; | |
| 378 } | |
| 379 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | |
|
Evan Stade
2016/06/22 17:15:43
use View::bounds().
Also the coordinate calculati
Jane
2016/06/22 22:02:32
Not sure I got what you meant by View::bounds(). I
| |
| 380 gfx::Rect bounds(0, 0, size.width(), size.height()); | |
| 381 | |
| 382 SkPaint paint; | |
| 383 paint.setAntiAlias(true); | |
| 384 paint.setColor(SK_ColorWHITE); | |
|
Evan Stade
2016/06/22 17:15:43
This constant (color) should be removed in favor o
Jane
2016/06/22 22:02:32
Done.
| |
| 385 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | |
| 386 | |
| 387 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | |
| 388 canvas->DrawCircle(bounds.CenterPoint(), | |
| 389 size.width() / 2 - kProfileBadgeWhitePadding, paint); | |
| 390 | |
| 391 int offset = (GetProfileBadgeSize() - icon_size) / 2; | |
| 392 canvas->Translate(gfx::Vector2d(offset, offset)); | |
| 393 gfx::PaintVectorIcon(canvas, icon_id, icon_size, | |
| 394 SkColorSetRGB(0, 0x66, 0xff)); | |
| 395 } | |
| 347 } | 396 } |
| 348 | 397 |
| 349 void PaintChildren(const ui::PaintContext& context) override { | 398 void PaintChildren(const ui::PaintContext& context) override { |
| 350 // Display any children (the "change photo" overlay) as a circle. | 399 // Display any children (the "change photo" overlay) as a circle. |
| 351 ui::ClipRecorder clip_recorder(context); | 400 ui::ClipRecorder clip_recorder(context); |
| 352 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); | 401 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); |
| 353 View::PaintChildren(context); | 402 View::PaintChildren(context); |
| 354 } | 403 } |
| 355 | 404 |
| 356 private: | 405 private: |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 374 if (photo_overlay_ && state() != STATE_HOVERED) | 423 if (photo_overlay_ && state() != STATE_HOVERED) |
| 375 photo_overlay_->SetVisible(false); | 424 photo_overlay_->SetVisible(false); |
| 376 } | 425 } |
| 377 | 426 |
| 378 gfx::Path circular_mask_; | 427 gfx::Path circular_mask_; |
| 379 | 428 |
| 380 // Image that is shown when hovering over the image button. Can be NULL if | 429 // Image that is shown when hovering over the image button. Can be NULL if |
| 381 // the photo isn't allowed to be edited (e.g. for guest profiles). | 430 // the photo isn't allowed to be edited (e.g. for guest profiles). |
| 382 views::ImageView* photo_overlay_; | 431 views::ImageView* photo_overlay_; |
| 383 | 432 |
| 433 Profile* profile_; | |
| 434 | |
| 384 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 435 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
| 385 }; | 436 }; |
| 386 | 437 |
| 387 // EditableProfileName ------------------------------------------------- | 438 // EditableProfileName ------------------------------------------------- |
| 388 | 439 |
| 389 // A custom text control that turns into a textfield for editing when clicked. | 440 // A custom text control that turns into a textfield for editing when clicked. |
| 390 class EditableProfileName : public views::View, | 441 class EditableProfileName : public views::View, |
| 391 public views::ButtonListener { | 442 public views::ButtonListener { |
| 392 public: | 443 public: |
| 393 EditableProfileName(views::TextfieldController* controller, | 444 EditableProfileName(views::TextfieldController* controller, |
| 394 const base::string16& text, | 445 const base::string16& text, |
| 395 bool is_editing_allowed) | 446 bool is_editing_allowed) |
| 396 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { | 447 : button_(nullptr), profile_name_textfield_(nullptr) { |
| 397 SetLayoutManager( | 448 SetLayoutManager( |
| 398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 449 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 399 | 450 |
| 400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 451 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 401 const gfx::FontList& medium_font_list = | 452 const gfx::FontList& medium_font_list = |
| 402 rb->GetFontList(ui::ResourceBundle::MediumFont); | 453 rb->GetFontList(ui::ResourceBundle::MediumFont); |
| 454 const int border_width = | |
| 455 (new views::Textfield)->border()->GetInsets().top(); | |
|
Evan Stade
2016/06/22 17:15:43
this view is leaking
Evan Stade
2016/06/22 17:15:43
pretty sure this should be
const int textfield_bo
Jane
2016/06/22 22:02:32
Done.
Jane
2016/06/22 22:02:32
Done.
| |
| 403 | 456 |
| 404 if (!is_editing_allowed) { | 457 if (!is_editing_allowed) { |
| 405 label_ = new views::Label(text); | 458 views::Label* name_label = new views::Label(text); |
| 406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 459 name_label->SetBorder( |
| 407 label_->SetFontList(medium_font_list); | 460 views::Border::CreateEmptyBorder(border_width, 0, border_width, 0)); |
| 408 AddChildView(label_); | 461 name_label->SetFontList(medium_font_list); |
| 462 if (switches::IsMaterialDesignUserMenu()) | |
| 463 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 464 AddChildView(name_label); | |
| 409 return; | 465 return; |
| 410 } | 466 } |
| 411 | 467 |
| 468 profile_name_textfield_ = new views::Textfield(); | |
| 469 // Textfield that overlaps the button. | |
| 470 profile_name_textfield_->set_controller(controller); | |
| 471 profile_name_textfield_->SetFontList(medium_font_list); | |
| 472 profile_name_textfield_->SetHorizontalAlignment( | |
| 473 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT | |
| 474 : gfx::ALIGN_CENTER); | |
| 475 profile_name_textfield_->SetVisible(false); | |
| 476 AddChildView(profile_name_textfield_); | |
| 477 | |
| 412 button_ = new RightAlignedIconLabelButton(this, text); | 478 button_ = new RightAlignedIconLabelButton(this, text); |
| 413 button_->SetFontList(medium_font_list); | 479 button_->SetFontList(medium_font_list); |
| 414 // Show an "edit" pencil icon when hovering over. In the default state, | 480 // Show an "edit" pencil icon when hovering over. In the default state, |
| 415 // we need to create an empty placeholder of the correct size, so that | 481 // we need to create an empty placeholder of the correct size, so that |
| 416 // the text doesn't jump around when the hovered icon appears. | 482 // the text doesn't jump around when the hovered icon appears. |
| 417 // TODO(estade): revisit colors and press effect. | 483 // TODO(estade): revisit colors and press effect. |
| 418 const int kIconSize = 16; | 484 const int kIconSize = 16; |
| 419 button_->SetImage(views::LabelButton::STATE_NORMAL, | 485 button_->SetImage(views::LabelButton::STATE_NORMAL, |
| 420 CreateSquarePlaceholderImage(kIconSize)); | 486 CreateSquarePlaceholderImage(kIconSize)); |
| 421 button_->SetImage(views::LabelButton::STATE_HOVERED, | 487 button_->SetImage(views::LabelButton::STATE_HOVERED, |
| 422 gfx::CreateVectorIcon( | 488 gfx::CreateVectorIcon( |
| 423 gfx::VectorIconId::MODE_EDIT, kIconSize, | 489 gfx::VectorIconId::MODE_EDIT, kIconSize, |
| 424 SkColorSetRGB(0x33, 0x33, 0x33))); | 490 SkColorSetRGB(0x33, 0x33, 0x33))); |
| 425 button_->SetImage(views::LabelButton::STATE_PRESSED, | 491 button_->SetImage(views::LabelButton::STATE_PRESSED, |
| 426 gfx::CreateVectorIcon( | 492 gfx::CreateVectorIcon( |
| 427 gfx::VectorIconId::MODE_EDIT, kIconSize, | 493 gfx::VectorIconId::MODE_EDIT, kIconSize, |
| 428 SkColorSetRGB(0x20, 0x20, 0x20))); | 494 SkColorSetRGB(0x20, 0x20, 0x20))); |
| 429 // To center the text, we need to offest it by the width of the icon we | 495 // We need to add a left padding as well as a small top/bottom padding |
| 430 // are adding and its padding. We need to also add a small top/bottom | 496 // to the text to account for the textfield's border. |
| 431 // padding to account for the textfield's border. | 497 if (switches::IsMaterialDesignUserMenu()) { |
| 432 const int kIconTextLabelButtonSpacing = 5; | 498 button_->SetBorder(views::Border::CreateEmptyBorder( |
| 433 button_->SetBorder(views::Border::CreateEmptyBorder( | 499 border_width, profile_name_textfield_->GetInsets().left(), |
| 434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 500 border_width, 0)); |
| 501 } else { | |
| 502 const int kIconTextLabelButtonSpacing = 5; | |
| 503 button_->SetBorder(views::Border::CreateEmptyBorder( | |
| 504 border_width, kIconSize + kIconTextLabelButtonSpacing, border_width, | |
| 505 0)); | |
| 506 } | |
| 435 AddChildView(button_); | 507 AddChildView(button_); |
| 436 | |
| 437 profile_name_textfield_ = new views::Textfield(); | |
| 438 // Textfield that overlaps the button. | |
| 439 profile_name_textfield_->set_controller(controller); | |
| 440 profile_name_textfield_->SetFontList(medium_font_list); | |
| 441 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 442 profile_name_textfield_->SetVisible(false); | |
| 443 AddChildView(profile_name_textfield_); | |
| 444 } | 508 } |
| 445 | 509 |
| 446 views::Textfield* profile_name_textfield() { | 510 views::Textfield* profile_name_textfield() { |
| 447 return profile_name_textfield_; | 511 return profile_name_textfield_; |
| 448 } | 512 } |
| 449 | 513 |
| 450 // Hide the editable textfield to show the profile name button instead. | 514 // Hide the editable textfield to show the profile name button instead. |
| 451 void ShowReadOnlyView() { | 515 void ShowReadOnlyView() { |
| 452 button_->SetVisible(true); | 516 button_->SetVisible(true); |
| 453 profile_name_textfield_->SetVisible(false); | 517 profile_name_textfield_->SetVisible(false); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 471 // you press space and clicks it when you release space, as the space can be | 535 // you press space and clicks it when you release space, as the space can be |
| 472 // part of the new profile name typed in the textfield. | 536 // part of the new profile name typed in the textfield. |
| 473 return false; | 537 return false; |
| 474 } | 538 } |
| 475 | 539 |
| 476 // The label button which shows the profile name, and can handle the event to | 540 // The label button which shows the profile name, and can handle the event to |
| 477 // make it editable. Can be NULL if the profile name isn't allowed to be | 541 // make it editable. Can be NULL if the profile name isn't allowed to be |
| 478 // edited. | 542 // edited. |
| 479 RightAlignedIconLabelButton* button_; | 543 RightAlignedIconLabelButton* button_; |
| 480 | 544 |
| 481 // The label which shows when the profile name cannot be edited (e.g. for | |
| 482 // supervised user). Can be NULL if the profile name is allowed to be edited. | |
| 483 views::Label* label_; | |
| 484 | |
| 485 // Textfield that is shown when editing the profile name. Can be NULL if | 545 // Textfield that is shown when editing the profile name. Can be NULL if |
| 486 // the profile name isn't allowed to be edited (e.g. for guest profiles). | 546 // the profile name isn't allowed to be edited (e.g. for guest profiles). |
| 487 views::Textfield* profile_name_textfield_; | 547 views::Textfield* profile_name_textfield_; |
| 488 | 548 |
| 489 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | 549 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); |
| 490 }; | 550 }; |
| 491 | 551 |
| 492 // A title card with one back button right aligned and one label center aligned. | 552 // A title card with one back button right aligned and one label center aligned. |
| 493 class TitleCard : public views::View { | 553 class TitleCard : public views::View { |
| 494 public: | 554 public: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 } | 617 } |
| 558 | 618 |
| 559 views::ImageButton* back_button_; | 619 views::ImageButton* back_button_; |
| 560 views::Label* title_label_; | 620 views::Label* title_label_; |
| 561 | 621 |
| 562 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 622 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
| 563 }; | 623 }; |
| 564 | 624 |
| 565 // ProfileBadge -------------------------------------------------------- | 625 // ProfileBadge -------------------------------------------------------- |
| 566 | 626 |
| 567 const size_t kProfileBadgeSize = 30; | |
| 568 const size_t kProfileBadgeWhitePadding = 2; | |
| 569 | |
| 570 // Draws a white circle, then a light blue circle, then a dark blue icon. | 627 // Draws a white circle, then a light blue circle, then a dark blue icon. |
| 571 class ProfileBadge : public gfx::CanvasImageSource { | 628 class ProfileBadge : public gfx::CanvasImageSource { |
| 572 public: | 629 public: |
| 573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | 630 ProfileBadge(gfx::VectorIconId id, size_t icon_size) |
| 574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | 631 : CanvasImageSource( |
| 575 false), | 632 gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()), |
| 633 false), | |
| 576 id_(id), | 634 id_(id), |
| 577 icon_size_(icon_size) {} | 635 icon_size_(icon_size) {} |
| 578 | 636 |
| 579 ~ProfileBadge() override {} | 637 ~ProfileBadge() override {} |
| 580 | 638 |
| 581 // CanvasImageSource: | 639 // CanvasImageSource: |
| 582 void Draw(gfx::Canvas* canvas) override { | 640 void Draw(gfx::Canvas* canvas) override { |
| 583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | 641 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); |
| 584 gfx::Rect bounds(0, 0, size.width(), size.height()); | 642 gfx::Rect bounds(0, 0, size.width(), size.height()); |
| 585 | 643 |
| 586 SkPaint paint; | 644 SkPaint paint; |
| 587 paint.setAntiAlias(true); | 645 paint.setAntiAlias(true); |
| 588 paint.setColor(SK_ColorWHITE); | 646 paint.setColor(SK_ColorWHITE); |
| 589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | 647 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); |
| 590 | 648 |
| 591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | 649 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); |
| 592 canvas->DrawCircle(bounds.CenterPoint(), | 650 canvas->DrawCircle(bounds.CenterPoint(), |
| 593 size.width() / 2 - kProfileBadgeWhitePadding, paint); | 651 size.width() / 2 - kProfileBadgeWhitePadding, paint); |
| 594 | 652 |
| 595 int offset = (kProfileBadgeSize - icon_size_) / 2; | 653 int offset = (GetProfileBadgeSize() - icon_size_) / 2; |
| 596 canvas->Translate(gfx::Vector2d(offset, offset)); | 654 canvas->Translate(gfx::Vector2d(offset, offset)); |
| 597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | 655 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
| 598 } | 656 } |
| 599 | 657 |
| 600 private: | 658 private: |
| 601 const gfx::VectorIconId id_; | 659 const gfx::VectorIconId id_; |
| 602 const size_t icon_size_; | 660 const size_t icon_size_; |
| 603 | 661 |
| 604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | 662 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); |
| 605 }; | 663 }; |
| 606 | 664 |
| 607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | 665 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
| 608 ProfileBadge* badge = | 666 ProfileBadge* badge = |
| 609 profile->IsChild() | 667 profile->IsChild() |
| 610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 668 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
| 611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 669 switches::IsMaterialDesignUserMenu() ? 21 : 26) |
| 612 | 670 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
| 671 switches::IsMaterialDesignUserMenu() ? 16 : 20); | |
| 613 return gfx::ImageSkia(badge, badge->size()); | 672 return gfx::ImageSkia(badge, badge->size()); |
| 614 } | 673 } |
| 615 | 674 |
| 616 // ProfileChooserView --------------------------------------------------------- | 675 // ProfileChooserView --------------------------------------------------------- |
| 617 | 676 |
| 618 // static | 677 // static |
| 619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 678 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
| 620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 679 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
| 621 | 680 |
| 622 // static | 681 // static |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 bool ProfileChooserView::IsShowing() { | 716 bool ProfileChooserView::IsShowing() { |
| 658 return profile_bubble_ != NULL; | 717 return profile_bubble_ != NULL; |
| 659 } | 718 } |
| 660 | 719 |
| 661 // static | 720 // static |
| 662 void ProfileChooserView::Hide() { | 721 void ProfileChooserView::Hide() { |
| 663 if (IsShowing()) | 722 if (IsShowing()) |
| 664 profile_bubble_->GetWidget()->Close(); | 723 profile_bubble_->GetWidget()->Close(); |
| 665 } | 724 } |
| 666 | 725 |
| 726 // static | |
| 727 int ProfileChooserView::GetFixedMenuWidth() { | |
| 728 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
| 729 } | |
| 730 | |
| 667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 731 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
| 668 Browser* browser, | 732 Browser* browser, |
| 669 profiles::BubbleViewMode view_mode, | 733 profiles::BubbleViewMode view_mode, |
| 670 profiles::TutorialMode tutorial_mode, | 734 profiles::TutorialMode tutorial_mode, |
| 671 signin::GAIAServiceType service_type, | 735 signin::GAIAServiceType service_type, |
| 672 signin_metrics::AccessPoint access_point) | 736 signin_metrics::AccessPoint access_point) |
| 673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 737 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 674 browser_(browser), | 738 browser_(browser), |
| 675 view_mode_(view_mode), | 739 view_mode_(view_mode), |
| 676 tutorial_mode_(tutorial_mode), | 740 tutorial_mode_(tutorial_mode), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 687 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 751 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| 688 if (oauth2_token_service) | 752 if (oauth2_token_service) |
| 689 oauth2_token_service->RemoveObserver(this); | 753 oauth2_token_service->RemoveObserver(this); |
| 690 } | 754 } |
| 691 | 755 |
| 692 void ProfileChooserView::ResetView() { | 756 void ProfileChooserView::ResetView() { |
| 693 open_other_profile_indexes_map_.clear(); | 757 open_other_profile_indexes_map_.clear(); |
| 694 delete_account_button_map_.clear(); | 758 delete_account_button_map_.clear(); |
| 695 reauth_account_button_map_.clear(); | 759 reauth_account_button_map_.clear(); |
| 696 manage_accounts_link_ = NULL; | 760 manage_accounts_link_ = NULL; |
| 697 signin_current_profile_link_ = NULL; | 761 signin_current_profile_button_ = NULL; |
| 698 auth_error_email_button_ = NULL; | 762 auth_error_email_button_ = NULL; |
| 699 current_profile_photo_ = NULL; | 763 current_profile_photo_ = NULL; |
| 700 current_profile_name_ = NULL; | 764 current_profile_name_ = NULL; |
| 701 users_button_ = NULL; | 765 users_button_ = NULL; |
| 702 go_incognito_button_ = NULL; | 766 go_incognito_button_ = NULL; |
| 703 lock_button_ = NULL; | 767 lock_button_ = NULL; |
| 704 add_account_link_ = NULL; | 768 add_account_link_ = NULL; |
| 705 gaia_signin_cancel_button_ = NULL; | 769 gaia_signin_cancel_button_ = NULL; |
| 706 remove_account_button_ = NULL; | 770 remove_account_button_ = NULL; |
| 707 account_removal_cancel_button_ = NULL; | 771 account_removal_cancel_button_ = NULL; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 break; | 896 break; |
| 833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 897 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
| 834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 898 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
| 835 sub_view = CreateSwitchUserView(); | 899 sub_view = CreateSwitchUserView(); |
| 836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 900 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 901 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
| 838 break; | 902 break; |
| 839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 903 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
| 840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 904 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
| 841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 905 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
| 842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 906 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
| 843 sub_view = CreateProfileChooserView(avatar_menu); | 907 sub_view = CreateProfileChooserView(avatar_menu); |
| 844 break; | 908 break; |
| 845 } | 909 } |
| 846 // Clears tutorial mode for all non-profile-chooser views. | 910 // Clears tutorial mode for all non-profile-chooser views. |
| 847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 911 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
| 848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 912 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
| 849 | 913 |
| 850 layout->StartRow(1, 0); | 914 layout->StartRow(1, 0); |
| 851 layout->AddView(sub_view); | 915 layout->AddView(sub_view); |
| 852 Layout(); | 916 Layout(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 879 if (accelerator.key_code() != ui::VKEY_DOWN && | 943 if (accelerator.key_code() != ui::VKEY_DOWN && |
| 880 accelerator.key_code() != ui::VKEY_UP) | 944 accelerator.key_code() != ui::VKEY_UP) |
| 881 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); | 945 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); |
| 882 | 946 |
| 883 // Move the focus up or down. | 947 // Move the focus up or down. |
| 884 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); | 948 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
| 885 return true; | 949 return true; |
| 886 } | 950 } |
| 887 | 951 |
| 888 views::View* ProfileChooserView::GetInitiallyFocusedView() { | 952 views::View* ProfileChooserView::GetInitiallyFocusedView() { |
| 889 return signin_current_profile_link_; | 953 return signin_current_profile_button_; |
| 890 } | 954 } |
| 891 | 955 |
| 892 int ProfileChooserView::GetDialogButtons() const { | 956 int ProfileChooserView::GetDialogButtons() const { |
| 893 return ui::DIALOG_BUTTON_NONE; | 957 return ui::DIALOG_BUTTON_NONE; |
| 894 } | 958 } |
| 895 | 959 |
| 896 bool ProfileChooserView::HandleContextMenu( | 960 bool ProfileChooserView::HandleContextMenu( |
| 897 const content::ContextMenuParams& params) { | 961 const content::ContextMenuParams& params) { |
| 898 // Suppresses the context menu because some features, such as inspecting | 962 // Suppresses the context menu because some features, such as inspecting |
| 899 // elements, are not appropriate in a bubble. | 963 // elements, are not appropriate in a bubble. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 bool account_management_available = | 1012 bool account_management_available = |
| 949 SigninManagerFactory::GetForProfile(browser_->profile())-> | 1013 SigninManagerFactory::GetForProfile(browser_->profile())-> |
| 950 IsAuthenticated() && | 1014 IsAuthenticated() && |
| 951 switches::IsEnableAccountConsistency(); | 1015 switches::IsEnableAccountConsistency(); |
| 952 ShowViewFromMode(account_management_available ? | 1016 ShowViewFromMode(account_management_available ? |
| 953 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 1017 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
| 954 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 1018 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
| 955 } else if (sender == current_profile_photo_) { | 1019 } else if (sender == current_profile_photo_) { |
| 956 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 1020 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| 957 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 1021 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| 958 } else if (sender == signin_current_profile_link_) { | 1022 } else if (sender == signin_current_profile_button_) { |
| 959 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 1023 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
| 960 } else if (sender == add_person_button_) { | 1024 } else if (sender == add_person_button_) { |
| 961 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1025 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 962 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 1026 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
| 963 UserManager::Show(base::FilePath(), | 1027 UserManager::Show(base::FilePath(), |
| 964 profiles::USER_MANAGER_NO_TUTORIAL, | 1028 profiles::USER_MANAGER_NO_TUTORIAL, |
| 965 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1029 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 966 } else if (sender == disconnect_button_) { | 1030 } else if (sender == disconnect_button_) { |
| 967 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1031 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 968 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 1032 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1085 Indexes other_profiles; | 1149 Indexes other_profiles; |
| 1086 views::View* tutorial_view = NULL; | 1150 views::View* tutorial_view = NULL; |
| 1087 views::View* current_profile_view = NULL; | 1151 views::View* current_profile_view = NULL; |
| 1088 views::View* current_profile_accounts = NULL; | 1152 views::View* current_profile_accounts = NULL; |
| 1089 views::View* option_buttons_view = NULL; | 1153 views::View* option_buttons_view = NULL; |
| 1090 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1154 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1091 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1155 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1092 if (item.active) { | 1156 if (item.active) { |
| 1093 option_buttons_view = CreateOptionsView( | 1157 option_buttons_view = CreateOptionsView( |
| 1094 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1158 item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
| 1095 current_profile_view = CreateCurrentProfileView(item, false); | 1159 current_profile_view = |
| 1160 switches::IsMaterialDesignUserMenu() | |
| 1161 ? CreateMaterialDesignCurrentProfileView(item, false) | |
| 1162 : CreateCurrentProfileView(item, false); | |
| 1096 if (IsProfileChooser(view_mode_)) { | 1163 if (IsProfileChooser(view_mode_)) { |
| 1097 tutorial_view = CreateTutorialViewIfNeeded(item); | 1164 tutorial_view = CreateTutorialViewIfNeeded(item); |
| 1098 } else { | 1165 } else { |
| 1099 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1166 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
| 1100 } | 1167 } |
| 1101 } else { | 1168 } else { |
| 1102 other_profiles.push_back(i); | 1169 other_profiles.push_back(i); |
| 1103 } | 1170 } |
| 1104 } | 1171 } |
| 1105 | 1172 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1122 | 1189 |
| 1123 if (!IsProfileChooser(view_mode_)) { | 1190 if (!IsProfileChooser(view_mode_)) { |
| 1124 DCHECK(current_profile_accounts); | 1191 DCHECK(current_profile_accounts); |
| 1125 layout->StartRow(0, 0); | 1192 layout->StartRow(0, 0); |
| 1126 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1193 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
| 1127 layout->StartRow(1, 0); | 1194 layout->StartRow(1, 0); |
| 1128 layout->AddView(current_profile_accounts); | 1195 layout->AddView(current_profile_accounts); |
| 1129 } | 1196 } |
| 1130 | 1197 |
| 1131 if (browser_->profile()->IsSupervised()) { | 1198 if (browser_->profile()->IsSupervised()) { |
| 1132 layout->StartRow(0, 0); | 1199 if (!switches::IsMaterialDesignUserMenu()) { |
| 1133 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1200 layout->StartRow(0, 0); |
| 1201 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
| 1202 } | |
| 1134 layout->StartRow(1, 0); | 1203 layout->StartRow(1, 0); |
| 1135 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1204 layout->AddView(CreateSupervisedUserDisclaimerView()); |
| 1136 } | 1205 } |
| 1137 | 1206 |
| 1138 layout->StartRow(0, 0); | 1207 layout->StartRow(0, 0); |
| 1139 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1208 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
| 1140 | 1209 |
| 1141 if (option_buttons_view) { | 1210 if (option_buttons_view) { |
| 1142 layout->StartRow(0, 0); | 1211 layout->StartRow(0, 0); |
| 1143 layout->AddView(option_buttons_view); | 1212 layout->AddView(option_buttons_view); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1155 } | 1224 } |
| 1156 } | 1225 } |
| 1157 | 1226 |
| 1158 layout->StartRow(1, 0); | 1227 layout->StartRow(1, 0); |
| 1159 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1228 layout->AddView(CreateOtherProfilesView(other_profiles)); |
| 1160 } | 1229 } |
| 1161 | 1230 |
| 1162 views::View* ProfileChooserView::CreateProfileChooserView( | 1231 views::View* ProfileChooserView::CreateProfileChooserView( |
| 1163 AvatarMenu* avatar_menu) { | 1232 AvatarMenu* avatar_menu) { |
| 1164 views::View* view = new views::View(); | 1233 views::View* view = new views::View(); |
| 1165 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1234 views::GridLayout* layout = |
| 1235 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1166 | 1236 |
| 1167 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1237 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
| 1168 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1238 PopulateMinimalProfileChooserView(layout, avatar_menu); |
| 1169 // The user is using right-click switching, no need to tell them about it. | 1239 // The user is using right-click switching, no need to tell them about it. |
| 1170 PrefService* local_state = g_browser_process->local_state(); | 1240 PrefService* local_state = g_browser_process->local_state(); |
| 1171 local_state->SetBoolean( | 1241 local_state->SetBoolean( |
| 1172 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1242 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
| 1173 } else { | 1243 } else { |
| 1174 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1244 PopulateCompleteProfileChooserView(layout, avatar_menu); |
| 1175 } | 1245 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 const base::string16& button_text, | 1300 const base::string16& button_text, |
| 1231 bool stack_button, | 1301 bool stack_button, |
| 1232 views::Link** link, | 1302 views::Link** link, |
| 1233 views::LabelButton** button, | 1303 views::LabelButton** button, |
| 1234 views::ImageButton** close_button) { | 1304 views::ImageButton** close_button) { |
| 1235 tutorial_mode_ = tutorial_mode; | 1305 tutorial_mode_ = tutorial_mode; |
| 1236 | 1306 |
| 1237 views::View* view = new views::View(); | 1307 views::View* view = new views::View(); |
| 1238 view->set_background(views::Background::CreateSolidBackground( | 1308 view->set_background(views::Background::CreateSolidBackground( |
| 1239 profiles::kAvatarTutorialBackgroundColor)); | 1309 profiles::kAvatarTutorialBackgroundColor)); |
| 1240 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1310 views::GridLayout* layout = CreateSingleColumnLayout( |
| 1241 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1311 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
| 1242 // Creates a second column set for buttons and links. | 1312 // Creates a second column set for buttons and links. |
| 1243 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1313 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
| 1244 button_columns->AddColumn(views::GridLayout::LEADING, | 1314 button_columns->AddColumn(views::GridLayout::LEADING, |
| 1245 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1315 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 1246 button_columns->AddPaddingColumn( | 1316 button_columns->AddPaddingColumn( |
| 1247 1, views::kUnrelatedControlHorizontalSpacing); | 1317 1, views::kUnrelatedControlHorizontalSpacing); |
| 1248 button_columns->AddColumn(views::GridLayout::TRAILING, | 1318 button_columns->AddColumn(views::GridLayout::TRAILING, |
| 1249 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1319 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 1250 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1320 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 1251 views::kButtonHEdgeMarginNew, | 1321 views::kButtonHEdgeMarginNew, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1333 layout->SkipColumns(1); | 1403 layout->SkipColumns(1); |
| 1334 } | 1404 } |
| 1335 | 1405 |
| 1336 return view; | 1406 return view; |
| 1337 } | 1407 } |
| 1338 | 1408 |
| 1339 views::View* ProfileChooserView::CreateCurrentProfileView( | 1409 views::View* ProfileChooserView::CreateCurrentProfileView( |
| 1340 const AvatarMenu::Item& avatar_item, | 1410 const AvatarMenu::Item& avatar_item, |
| 1341 bool is_guest) { | 1411 bool is_guest) { |
| 1342 views::View* view = new views::View(); | 1412 views::View* view = new views::View(); |
| 1343 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1413 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
| 1344 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1414 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
| 1345 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1415 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 1346 views::kButtonHEdgeMarginNew, | 1416 views::kButtonHEdgeMarginNew, |
| 1347 views::kUnrelatedControlVerticalSpacing, | 1417 views::kUnrelatedControlVerticalSpacing, |
| 1348 views::kButtonHEdgeMarginNew); | 1418 views::kButtonHEdgeMarginNew); |
| 1349 | 1419 |
| 1350 // Profile icon, centered. | 1420 // Profile icon, centered. |
| 1351 int x_offset = (column_width - kLargeImageSide) / 2; | 1421 int x_offset = (column_width - kLargeImageSide) / 2; |
| 1352 current_profile_photo_ = new EditableProfilePhoto( | 1422 current_profile_photo_ = new EditableProfilePhoto( |
| 1353 this, avatar_item.icon, !is_guest, | 1423 this, avatar_item.icon, !is_guest, browser_->profile()); |
| 1354 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); | 1424 current_profile_photo_->SetX(x_offset); |
| 1355 SizedContainer* profile_icon_container = | 1425 SizedContainer* profile_icon_container = |
| 1356 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | 1426 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
| 1357 profile_icon_container->AddChildView(current_profile_photo_); | 1427 profile_icon_container->AddChildView(current_profile_photo_); |
| 1358 | 1428 |
| 1359 if (browser_->profile()->IsSupervised()) { | 1429 if (browser_->profile()->IsSupervised()) { |
| 1360 views::ImageView* supervised_icon = new views::ImageView(); | 1430 views::ImageView* supervised_icon = new views::ImageView(); |
| 1361 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); | 1431 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); |
| 1362 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | 1432 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); |
| 1363 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | 1433 gfx::Rect parent_bounds = current_profile_photo_->bounds(); |
| 1364 supervised_icon->SetBounds( | 1434 supervised_icon->SetBounds( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 if (signin_manager->IsSigninAllowed()) { | 1501 if (signin_manager->IsSigninAllowed()) { |
| 1432 views::Label* promo = new views::Label( | 1502 views::Label* promo = new views::Label( |
| 1433 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | 1503 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
| 1434 promo->SetMultiLine(true); | 1504 promo->SetMultiLine(true); |
| 1435 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1505 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1436 layout->StartRowWithPadding(1, 0, 0, | 1506 layout->StartRowWithPadding(1, 0, 0, |
| 1437 views::kRelatedControlSmallVerticalSpacing); | 1507 views::kRelatedControlSmallVerticalSpacing); |
| 1438 layout->StartRow(1, 0); | 1508 layout->StartRow(1, 0); |
| 1439 layout->AddView(promo); | 1509 layout->AddView(promo); |
| 1440 | 1510 |
| 1441 signin_current_profile_link_ = new views::BlueButton( | 1511 signin_current_profile_button_ = new views::BlueButton( |
| 1442 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 1512 this, l10n_util::GetStringFUTF16( |
| 1443 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 1513 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| 1514 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
| 1444 layout->StartRowWithPadding(1, 0, 0, | 1515 layout->StartRowWithPadding(1, 0, 0, |
| 1445 views::kRelatedControlVerticalSpacing); | 1516 views::kRelatedControlVerticalSpacing); |
| 1446 layout->StartRow(1, 0); | 1517 layout->StartRow(1, 0); |
| 1447 layout->AddView(signin_current_profile_link_); | 1518 layout->AddView(signin_current_profile_button_); |
| 1448 content::RecordAction( | 1519 content::RecordAction( |
| 1449 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1520 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
| 1450 } | 1521 } |
| 1451 } | 1522 } |
| 1452 | 1523 |
| 1453 return view; | 1524 return view; |
| 1454 } | 1525 } |
| 1455 | 1526 |
| 1527 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
| 1528 const AvatarMenu::Item& avatar_item, | |
| 1529 bool is_guest) { | |
| 1530 views::View* view = new views::View(); | |
| 1531 view->SetLayoutManager( | |
| 1532 new views::BoxLayout(views::BoxLayout::kVertical, kMaterialMenuEdgeMargin, | |
| 1533 views::kRelatedControlVerticalSpacing, | |
| 1534 views::kRelatedControlVerticalSpacing)); | |
| 1535 | |
| 1536 // Profile container for the profile photo and avatar/user name. | |
| 1537 views::View* profile_container = new views::View(); | |
| 1538 | |
| 1539 // Profile picture, left-aligned. | |
| 1540 current_profile_photo_ = new EditableProfilePhoto( | |
| 1541 this, avatar_item.icon, !is_guest, browser_->profile()); | |
| 1542 current_profile_photo_->SetY(views::kRelatedControlSmallVerticalSpacing); | |
| 1543 const int badge_spacing = 4; | |
| 1544 SizedContainer* profile_photo_container = new SizedContainer( | |
| 1545 gfx::Size(current_profile_photo_->width() + badge_spacing, | |
| 1546 current_profile_photo_->height() + | |
| 1547 2 * views::kRelatedControlSmallVerticalSpacing)); | |
| 1548 profile_photo_container->AddChildView(current_profile_photo_); | |
| 1549 | |
| 1550 // Profile name, left-aligned to the right of profile icon. | |
| 1551 bool editing_allowed = | |
| 1552 !is_guest && !browser_->profile()->IsLegacySupervised(); | |
| 1553 current_profile_name_ = new EditableProfileName( | |
| 1554 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
| 1555 editing_allowed); | |
| 1556 views::View* profile_name_container = new views::View(); | |
| 1557 int name_container_v_spacing = views::kRelatedControlSmallVerticalSpacing; | |
| 1558 if (!avatar_item.signed_in) | |
| 1559 name_container_v_spacing += views::kRelatedControlVerticalSpacing; | |
| 1560 profile_name_container->SetLayoutManager(new views::BoxLayout( | |
| 1561 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0)); | |
| 1562 profile_name_container->AddChildView(current_profile_name_); | |
| 1563 | |
| 1564 const int between_child_spacing = kMaterialMenuEdgeMargin - badge_spacing; | |
| 1565 profile_container->SetLayoutManager(new views::BoxLayout( | |
| 1566 views::BoxLayout::kHorizontal, 0, | |
| 1567 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); | |
| 1568 profile_container->AddChildView(profile_photo_container); | |
| 1569 profile_container->AddChildView(profile_name_container); | |
| 1570 view->AddChildView(profile_container); | |
| 1571 | |
| 1572 if (is_guest) | |
| 1573 return view; | |
| 1574 | |
| 1575 // The available links depend on the type of profile that is active. | |
| 1576 if (avatar_item.signed_in) { | |
| 1577 if (switches::IsEnableAccountConsistency()) { | |
| 1578 base::string16 link_title = l10n_util::GetStringUTF16( | |
| 1579 IsProfileChooser(view_mode_) | |
| 1580 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON | |
| 1581 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
| 1582 manage_accounts_link_ = CreateLink(link_title, this); | |
| 1583 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 1584 profile_name_container->AddChildView(manage_accounts_link_); | |
| 1585 } else { | |
| 1586 views::Label* email_label = new views::Label(avatar_item.username); | |
| 1587 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
| 1588 email_label->SetEnabled(false); | |
| 1589 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 1590 profile_name_container->AddChildView(email_label); | |
| 1591 } | |
| 1592 return view; | |
| 1593 } | |
| 1594 | |
| 1595 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
| 1596 browser_->profile()->GetOriginalProfile()); | |
| 1597 if (signin_manager->IsSigninAllowed()) { | |
| 1598 views::Label* promo = | |
| 1599 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
| 1600 promo->SetMultiLine(true); | |
| 1601 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 1602 view->AddChildView(promo); | |
| 1603 | |
| 1604 signin_current_profile_button_ = | |
| 1605 views::MdTextButton::CreateSecondaryUiBlueButton( | |
| 1606 this, l10n_util::GetStringFUTF16( | |
| 1607 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
| 1608 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
| 1609 view->AddChildView(signin_current_profile_button_); | |
| 1610 content::RecordAction( | |
| 1611 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
| 1612 view->SetBorder(views::Border::CreateEmptyBorder( | |
| 1613 0, 0, views::kRelatedControlVerticalSpacing, 0)); | |
| 1614 } | |
| 1615 | |
| 1616 return view; | |
| 1617 } | |
| 1618 | |
| 1456 views::View* ProfileChooserView::CreateGuestProfileView() { | 1619 views::View* ProfileChooserView::CreateGuestProfileView() { |
| 1457 gfx::Image guest_icon = | 1620 gfx::Image guest_icon = |
| 1458 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1621 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 1459 profiles::GetPlaceholderAvatarIconResourceID()); | 1622 profiles::GetPlaceholderAvatarIconResourceID()); |
| 1460 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1623 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
| 1461 guest_avatar_item.active = true; | 1624 guest_avatar_item.active = true; |
| 1462 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1625 guest_avatar_item.name = l10n_util::GetStringUTF16( |
| 1463 IDS_PROFILES_GUEST_PROFILE_NAME); | 1626 IDS_PROFILES_GUEST_PROFILE_NAME); |
| 1464 guest_avatar_item.signed_in = false; | 1627 guest_avatar_item.signed_in = false; |
| 1465 | 1628 |
| 1466 return CreateCurrentProfileView(guest_avatar_item, true); | 1629 return switches::IsMaterialDesignUserMenu() |
| 1630 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
| 1631 : CreateCurrentProfileView(guest_avatar_item, true); | |
| 1467 } | 1632 } |
| 1468 | 1633 |
| 1469 views::View* ProfileChooserView::CreateOtherProfilesView( | 1634 views::View* ProfileChooserView::CreateOtherProfilesView( |
| 1470 const Indexes& avatars_to_show) { | 1635 const Indexes& avatars_to_show) { |
| 1471 views::View* view = new views::View(); | 1636 views::View* view = new views::View(); |
| 1472 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1637 views::GridLayout* layout = |
| 1638 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1473 | 1639 |
| 1474 for (size_t index : avatars_to_show) { | 1640 for (size_t index : avatars_to_show) { |
| 1475 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1641 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
| 1476 const int kSmallImageSide = 32; | 1642 const int kSmallImageSide = 32; |
| 1477 | 1643 |
| 1478 // Use the low-res, small default avatars in the fast user switcher, like | 1644 // Use the low-res, small default avatars in the fast user switcher, like |
| 1479 // we do in the menu bar. | 1645 // we do in the menu bar. |
| 1480 gfx::Image item_icon; | 1646 gfx::Image item_icon; |
| 1481 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1647 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
| 1482 | 1648 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1493 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1659 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
| 1494 layout->StartRow(1, 0); | 1660 layout->StartRow(1, 0); |
| 1495 layout->AddView(button); | 1661 layout->AddView(button); |
| 1496 } | 1662 } |
| 1497 | 1663 |
| 1498 return view; | 1664 return view; |
| 1499 } | 1665 } |
| 1500 | 1666 |
| 1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1667 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
| 1502 views::View* view = new views::View(); | 1668 views::View* view = new views::View(); |
| 1503 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1669 views::GridLayout* layout = |
| 1670 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1504 | 1671 |
| 1505 base::string16 text = browser_->profile()->IsGuestSession() ? | 1672 base::string16 text = browser_->profile()->IsGuestSession() ? |
| 1506 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1673 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
| 1507 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1674 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
| 1508 if (!browser_->profile()->IsGuestSession() | 1675 if (!browser_->profile()->IsGuestSession() |
| 1509 && switches::IsMaterialDesignUserMenu()) { | 1676 && switches::IsMaterialDesignUserMenu()) { |
| 1510 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1677 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
| 1511 } | 1678 } |
| 1512 const int kIconSize = 16; | 1679 const int kIconSize = 16; |
| 1513 | 1680 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1543 gfx::kChromeIconGrey)); | 1710 gfx::kChromeIconGrey)); |
| 1544 layout->StartRow(1, 0); | 1711 layout->StartRow(1, 0); |
| 1545 layout->AddView(lock_button_); | 1712 layout->AddView(lock_button_); |
| 1546 } | 1713 } |
| 1547 return view; | 1714 return view; |
| 1548 } | 1715 } |
| 1549 | 1716 |
| 1550 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1717 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
| 1551 views::View* view = new views::View(); | 1718 views::View* view = new views::View(); |
| 1552 views::GridLayout* layout = CreateSingleColumnLayout( | 1719 views::GridLayout* layout = CreateSingleColumnLayout( |
| 1553 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1720 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
| 1554 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1721 if (switches::IsMaterialDesignUserMenu()) { |
| 1555 views::kButtonHEdgeMarginNew, | 1722 layout->SetInsets(0, kMaterialMenuEdgeMargin, kMaterialMenuEdgeMargin, |
| 1556 views::kRelatedControlVerticalSpacing, | 1723 kMaterialMenuEdgeMargin); |
| 1557 views::kButtonHEdgeMarginNew); | 1724 } else { |
| 1725 layout->SetInsets( | |
| 1726 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, | |
| 1727 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); | |
| 1728 } | |
| 1729 | |
| 1558 views::Label* disclaimer = new views::Label( | 1730 views::Label* disclaimer = new views::Label( |
| 1559 avatar_menu_->GetSupervisedUserInformation()); | 1731 avatar_menu_->GetSupervisedUserInformation()); |
| 1560 disclaimer->SetMultiLine(true); | 1732 disclaimer->SetMultiLine(true); |
| 1561 disclaimer->SetAllowCharacterBreak(true); | 1733 disclaimer->SetAllowCharacterBreak(true); |
| 1562 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1734 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1563 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1735 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1564 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1736 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 1565 layout->StartRow(1, 0); | 1737 layout->StartRow(1, 0); |
| 1566 layout->AddView(disclaimer); | 1738 layout->AddView(disclaimer); |
| 1567 | 1739 |
| 1568 return view; | 1740 return view; |
| 1569 } | 1741 } |
| 1570 | 1742 |
| 1571 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1743 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
| 1572 const AvatarMenu::Item& avatar_item) { | 1744 const AvatarMenu::Item& avatar_item) { |
| 1573 DCHECK(avatar_item.signed_in); | 1745 DCHECK(avatar_item.signed_in); |
| 1574 views::View* view = new views::View(); | 1746 views::View* view = new views::View(); |
| 1575 view->set_background(views::Background::CreateSolidBackground( | 1747 view->set_background(views::Background::CreateSolidBackground( |
| 1576 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1748 profiles::kAvatarBubbleAccountsBackgroundColor)); |
| 1577 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1749 views::GridLayout* layout = |
| 1750 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
| 1578 | 1751 |
| 1579 Profile* profile = browser_->profile(); | 1752 Profile* profile = browser_->profile(); |
| 1580 std::string primary_account = | 1753 std::string primary_account = |
| 1581 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1754 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
| 1582 DCHECK(!primary_account.empty()); | 1755 DCHECK(!primary_account.empty()); |
| 1583 std::vector<std::string>accounts = | 1756 std::vector<std::string>accounts = |
| 1584 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1757 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
| 1585 | 1758 |
| 1586 // Get state of authentication error, if any. | 1759 // Get state of authentication error, if any. |
| 1587 std::string error_account_id = GetAuthErrorAccountId(profile); | 1760 std::string error_account_id = GetAuthErrorAccountId(profile); |
| 1588 | 1761 |
| 1589 // The primary account should always be listed first. | 1762 // The primary account should always be listed first. |
| 1590 // TODO(rogerta): we still need to further differentiate the primary account | 1763 // TODO(rogerta): we still need to further differentiate the primary account |
| 1591 // from the others in the UI, so more work is likely required here: | 1764 // from the others in the UI, so more work is likely required here: |
| 1592 // crbug.com/311124. | 1765 // crbug.com/311124. |
| 1593 CreateAccountButton(layout, primary_account, true, | 1766 CreateAccountButton(layout, primary_account, true, |
| 1594 error_account_id == primary_account, kFixedMenuWidth); | 1767 error_account_id == primary_account, GetFixedMenuWidth()); |
| 1595 for (size_t i = 0; i < accounts.size(); ++i) | 1768 for (size_t i = 0; i < accounts.size(); ++i) |
| 1596 CreateAccountButton(layout, accounts[i], false, | 1769 CreateAccountButton(layout, accounts[i], false, |
| 1597 error_account_id == accounts[i], kFixedMenuWidth); | 1770 error_account_id == accounts[i], GetFixedMenuWidth()); |
| 1598 | 1771 |
| 1599 if (!profile->IsSupervised()) { | 1772 if (!profile->IsSupervised()) { |
| 1600 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1773 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 1601 | 1774 |
| 1602 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1775 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
| 1603 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1776 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
| 1604 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1777 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
| 1605 0, views::kButtonVEdgeMarginNew, | 1778 0, views::kButtonVEdgeMarginNew, |
| 1606 views::kRelatedControlVerticalSpacing, 0)); | 1779 views::kRelatedControlVerticalSpacing, 0)); |
| 1607 layout->StartRow(1, 0); | 1780 layout->StartRow(1, 0); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2070 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1898 IncognitoModePrefs::DISABLED; | 2071 IncognitoModePrefs::DISABLED; |
| 1899 return incognito_available && !browser_->profile()->IsGuestSession(); | 2072 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1900 } | 2073 } |
| 1901 | 2074 |
| 1902 void ProfileChooserView::PostActionPerformed( | 2075 void ProfileChooserView::PostActionPerformed( |
| 1903 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2076 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1904 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2077 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1905 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2078 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1906 } | 2079 } |
| OLD | NEW |