Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2023093002: Reflow of the profile items in desktop user menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-profile-icon
Patch Set: Some cleanup Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "components/signin/core/browser/signin_manager.h" 42 #include "components/signin/core/browser/signin_manager.h"
43 #include "components/signin/core/common/profile_management_switches.h" 43 #include "components/signin/core/common/profile_management_switches.h"
44 #include "content/public/browser/render_widget_host_view.h" 44 #include "content/public/browser/render_widget_host_view.h"
45 #include "content/public/browser/user_metrics.h" 45 #include "content/public/browser/user_metrics.h"
46 #include "grit/theme_resources.h" 46 #include "grit/theme_resources.h"
47 #include "third_party/skia/include/core/SkColor.h" 47 #include "third_party/skia/include/core/SkColor.h"
48 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
49 #include "ui/base/material_design/material_design_controller.h" 49 #include "ui/base/material_design/material_design_controller.h"
50 #include "ui/base/resource/resource_bundle.h" 50 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/compositor/clip_recorder.h" 51 #include "ui/compositor/clip_recorder.h"
52 #include "ui/compositor/paint_recorder.h"
52 #include "ui/gfx/canvas.h" 53 #include "ui/gfx/canvas.h"
53 #include "ui/gfx/color_palette.h" 54 #include "ui/gfx/color_palette.h"
54 #include "ui/gfx/image/canvas_image_source.h" 55 #include "ui/gfx/image/canvas_image_source.h"
55 #include "ui/gfx/image/image.h" 56 #include "ui/gfx/image/image.h"
56 #include "ui/gfx/image/image_skia.h" 57 #include "ui/gfx/image/image_skia.h"
57 #include "ui/gfx/paint_vector_icon.h" 58 #include "ui/gfx/paint_vector_icon.h"
58 #include "ui/gfx/path.h" 59 #include "ui/gfx/path.h"
59 #include "ui/gfx/skia_util.h" 60 #include "ui/gfx/skia_util.h"
60 #include "ui/gfx/text_elider.h" 61 #include "ui/gfx/text_elider.h"
61 #include "ui/gfx/vector_icons_public.h" 62 #include "ui/gfx/vector_icons_public.h"
(...skipping 14 matching lines...) Expand all
76 #include "ui/views/layout/box_layout.h" 77 #include "ui/views/layout/box_layout.h"
77 #include "ui/views/layout/fill_layout.h" 78 #include "ui/views/layout/fill_layout.h"
78 #include "ui/views/layout/grid_layout.h" 79 #include "ui/views/layout/grid_layout.h"
79 #include "ui/views/layout/layout_constants.h" 80 #include "ui/views/layout/layout_constants.h"
80 #include "ui/views/widget/widget.h" 81 #include "ui/views/widget/widget.h"
81 82
82 namespace { 83 namespace {
83 84
84 // Helpers -------------------------------------------------------------------- 85 // Helpers --------------------------------------------------------------------
85 86
86 const int kFixedMenuWidth = 250;
87 const int kButtonHeight = 32; 87 const int kButtonHeight = 32;
88 const int kPasswordCombinedFixedGaiaViewWidth = 360; 88 const int kPasswordCombinedFixedGaiaViewWidth = 360;
89 const int kFixedGaiaViewWidth = 448; 89 const int kFixedGaiaViewWidth = 448;
90 const int kFixedAccountRemovalViewWidth = 280; 90 const int kFixedAccountRemovalViewWidth = 280;
91 const int kFixedSwitchUserViewWidth = 320; 91 const int kFixedSwitchUserViewWidth = 320;
92 const int kLargeImageSide = 88; 92 const int kLargeImageSide = 88;
93 const int kMdImageSide = 40;
94
95 // Spacing between the edge of the material design user menu and the
96 // top/bottom or left/right of the menu items.
97 const int kMaterialMenuEdgeMargin = 16;
93 98
94 const int kVerticalSpacing = 16; 99 const int kVerticalSpacing = 16;
95 100
96 const int kTitleViewNativeWidgetOffset = 8; 101 const int kTitleViewNativeWidgetOffset = 8;
97 102
98 bool IsProfileChooser(profiles::BubbleViewMode mode) { 103 bool IsProfileChooser(profiles::BubbleViewMode mode) {
99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || 104 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; 105 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
101 } 106 }
102 107
108 int GetProfileBadgeSize() {
109 return switches::IsMaterialDesignUserMenu() ? 24 : 30;
110 }
111
112 // DEPRECATED: New user menu components should use views::BoxLayout instead.
103 // Creates a GridLayout with a single column. This ensures that all the child 113 // 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. 114 // views added get auto-expanded to fill the full width of the bubble.
105 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { 115 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) {
106 views::GridLayout* layout = new views::GridLayout(view); 116 views::GridLayout* layout = new views::GridLayout(view);
107 view->SetLayoutManager(layout); 117 view->SetLayoutManager(layout);
108 118
109 views::ColumnSet* columns = layout->AddColumnSet(0); 119 views::ColumnSet* columns = layout->AddColumnSet(0);
110 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 120 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
111 views::GridLayout::FIXED, width, width); 121 views::GridLayout::FIXED, width, width);
112 return layout; 122 return layout;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 gfx::Rect bounds(title_view_->GetPreferredSize()); 266 gfx::Rect bounds(title_view_->GetPreferredSize());
257 title_view_->SetBoundsRect(bounds); 267 title_view_->SetBoundsRect(bounds);
258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); 268 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset);
259 title_widget_->SetBounds(bounds); 269 title_widget_->SetBounds(bounds);
260 } 270 }
261 271
262 } // namespace 272 } // namespace
263 273
264 // RightAlignedIconLabelButton ------------------------------------------------- 274 // RightAlignedIconLabelButton -------------------------------------------------
265 275
266 // A custom LabelButton that has a centered text and right aligned icon. 276 // A custom LabelButton that has a left-aligned text and right aligned icon.
277 // For non-material-design user menu, it has centered text instead.
267 class RightAlignedIconLabelButton : public views::LabelButton { 278 class RightAlignedIconLabelButton : public views::LabelButton {
268 public: 279 public:
269 RightAlignedIconLabelButton(views::ButtonListener* listener, 280 RightAlignedIconLabelButton(views::ButtonListener* listener,
270 const base::string16& text) 281 const base::string16& text)
271 : views::LabelButton(listener, text) { 282 : views::LabelButton(listener, text) {
272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); 283 SetHorizontalAlignment(gfx::ALIGN_RIGHT);
273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); 284 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu()
285 ? gfx::ALIGN_LEFT
286 : gfx::ALIGN_CENTER);
274 } 287 }
275 288
276 protected: 289 protected:
277 void Layout() override { 290 void Layout() override {
278 views::LabelButton::Layout(); 291 views::LabelButton::Layout();
279 292
280 // Keep the text centered and the icon right-aligned by stretching the label 293 // 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. 294 // to take up more of the content area and centering its contents.
282 gfx::Rect content_bounds = GetContentsBounds(); 295 gfx::Rect content_bounds = GetContentsBounds();
283 gfx::Rect label_bounds = label()->bounds(); 296 gfx::Rect label_bounds = label()->bounds();
284 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); 297 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0);
285 label()->SetBoundsRect(label_bounds); 298 label()->SetBoundsRect(label_bounds);
286 } 299 }
287 300
288 private: 301 private:
289 void OnFocus() override { 302 void OnFocus() override {
290 SetState(STATE_HOVERED); 303 SetState(STATE_HOVERED);
291 } 304 }
292 305
293 void OnBlur() override { 306 void OnBlur() override {
294 SetState(STATE_NORMAL); 307 SetState(STATE_NORMAL);
295 } 308 }
296 309
297 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); 310 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton);
298 }; 311 };
299 312
300 // EditableProfilePhoto ------------------------------------------------- 313 // EditableProfilePhoto -------------------------------------------------
301 314
315 const size_t kProfileBadgeWhitePadding = 2;
316
302 // A custom Image control that shows a "change" button when moused over. 317 // A custom Image control that shows a "change" button when moused over.
303 class EditableProfilePhoto : public views::LabelButton { 318 class EditableProfilePhoto : public views::LabelButton {
304 public: 319 public:
305 EditableProfilePhoto(views::ButtonListener* listener, 320 EditableProfilePhoto(views::ButtonListener* listener,
306 const gfx::Image& icon, 321 const gfx::Image& icon,
307 bool is_editing_allowed, 322 bool is_editing_allowed,
308 const gfx::Rect& bounds) 323 Profile* profile)
309 : views::LabelButton(listener, base::string16()), 324 : views::LabelButton(listener, base::string16()),
310 photo_overlay_(NULL) { 325 photo_overlay_(nullptr),
311 gfx::Image image = profiles::GetSizedAvatarIcon( 326 profile_(profile) {
312 icon, true, kLargeImageSide, kLargeImageSide); 327 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side,
328 icon_image_side);
313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); 329 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia());
314 SetBorder(views::Border::NullBorder()); 330 SetBorder(views::Border::NullBorder());
315 SetBoundsRect(bounds); 331 if (switches::IsMaterialDesignUserMenu()) {
332 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing,
333 GetPreferredSize().height() + badge_spacing +
334 views::kRelatedControlSmallVerticalSpacing));
335 } else {
336 SetSize(GetPreferredSize());
337 }
316 338
317 // Calculate the circular mask that will be used to display the photo. 339 // Calculate the circular mask that will be used to display the photo.
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), 340 circular_mask_.addCircle(SkIntToScalar(icon_image_side / 2),
319 SkIntToScalar(bounds.height() / 2), 341 SkIntToScalar(icon_image_side / 2) + badge_spacing,
320 SkIntToScalar(bounds.width() / 2)); 342 SkIntToScalar(icon_image_side / 2));
321 343
322 if (!is_editing_allowed) { 344 if (!is_editing_allowed) {
323 SetEnabled(false); 345 SetEnabled(false);
324 return; 346 return;
325 } 347 }
326 348
327 set_notify_enter_exit_on_child(true); 349 set_notify_enter_exit_on_child(true);
328 350
329 // Photo overlay that appears when hovering over the button. 351 // Photo overlay that appears when hovering over the button.
330 photo_overlay_ = new views::ImageView(); 352 photo_overlay_ = new views::ImageView();
331 353
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); 354 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255);
333 photo_overlay_->set_background( 355 photo_overlay_->set_background(
334 views::Background::CreateSolidBackground(kBackgroundColor)); 356 views::Background::CreateSolidBackground(kBackgroundColor));
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( 357 photo_overlay_->SetImage(
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); 358 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA,
359 switches::IsMaterialDesignUserMenu() ? 22u : 48u,
360 SkColorSetRGB(0x33, 0x33, 0x33)));
337 361
338 photo_overlay_->SetSize(bounds.size()); 362 photo_overlay_->SetSize(gfx::Size(icon_image_side, icon_image_side));
363 photo_overlay_->SetY(badge_spacing);
339 photo_overlay_->SetVisible(false); 364 photo_overlay_->SetVisible(false);
340 AddChildView(photo_overlay_); 365 AddChildView(photo_overlay_);
341 } 366 }
342 367
343 void OnPaint(gfx::Canvas* canvas) override { 368 void OnPaint(gfx::Canvas* canvas) override {
369 canvas->Save();
344 // Display the profile picture as a circle. 370 // Display the profile picture as a circle.
345 canvas->ClipPath(circular_mask_, true); 371 canvas->ClipPath(circular_mask_, true);
346 views::LabelButton::OnPaint(canvas); 372 views::LabelButton::OnPaint(canvas);
373 canvas->Restore();
347 } 374 }
348 375
349 void PaintChildren(const ui::PaintContext& context) override { 376 void PaintChildren(const ui::PaintContext& context) override {
350 // Display any children (the "change photo" overlay) as a circle. 377 // Display any children (the "change photo" overlay) as a circle.
351 ui::ClipRecorder clip_recorder(context); 378 ui::ClipRecorder clip_recorder(context);
352 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); 379 clip_recorder.ClipPathWithAntiAliasing(circular_mask_);
353 View::PaintChildren(context); 380 View::PaintChildren(context);
381
Jane 2016/06/27 18:08:57 Here is my question in more details: AFAIU, clip_r
Evan Stade 2016/06/28 03:02:50 I dunno offhand. Did you try using two different c
Jane 2016/06/28 14:59:22 Done. Thanks, this worked!
382 ui::PaintRecorder paint_recorder(
383 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()));
384 gfx::Canvas* canvas = paint_recorder.canvas();
385 if (profile_->IsSupervised()) {
386 gfx::VectorIconId icon_id;
387 size_t icon_size;
388 if (profile_->IsChild()) {
389 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT;
390 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26;
391 } else {
392 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT;
393 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20;
394 }
395 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize());
396
397 int badge_offset =
398 icon_image_side + badge_spacing - GetProfileBadgeSize();
399 gfx::Point center_point =
400 bounds.CenterPoint() +
401 gfx::Vector2d(
402 badge_offset,
403 badge_offset + views::kRelatedControlSmallVerticalSpacing);
404 SkPaint paint;
405 paint.setAntiAlias(true);
406 paint.setColor(GetNativeTheme()->GetSystemColor(
407 ui::NativeTheme::kColorId_BubbleBackground));
408 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint);
409 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC));
410 canvas->DrawCircle(center_point,
411 GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding,
412 paint);
413
414 int offset = (GetProfileBadgeSize() - icon_size) / 2;
415 canvas->Translate(gfx::Vector2d(
416 badge_offset + offset,
417 badge_offset + offset + views::kRelatedControlSmallVerticalSpacing));
418 gfx::PaintVectorIcon(canvas, icon_id, icon_size,
419 SkColorSetRGB(0, 0x66, 0xff));
420 }
354 } 421 }
355 422
423 int icon_image_side =
424 switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide;
425 int badge_spacing = switches::IsMaterialDesignUserMenu() ? 4 : 0;
426
356 private: 427 private:
357 // views::CustomButton: 428 // views::CustomButton:
358 void StateChanged() override { 429 void StateChanged() override {
359 bool show_overlay = 430 bool show_overlay =
360 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); 431 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus());
361 if (photo_overlay_) 432 if (photo_overlay_)
362 photo_overlay_->SetVisible(show_overlay); 433 photo_overlay_->SetVisible(show_overlay);
363 } 434 }
364 435
365 void OnFocus() override { 436 void OnFocus() override {
366 views::LabelButton::OnFocus(); 437 views::LabelButton::OnFocus();
367 if (photo_overlay_) 438 if (photo_overlay_)
368 photo_overlay_->SetVisible(true); 439 photo_overlay_->SetVisible(true);
369 } 440 }
370 441
371 void OnBlur() override { 442 void OnBlur() override {
372 views::LabelButton::OnBlur(); 443 views::LabelButton::OnBlur();
373 // Don't hide the overlay if it's being shown as a result of a mouseover. 444 // Don't hide the overlay if it's being shown as a result of a mouseover.
374 if (photo_overlay_ && state() != STATE_HOVERED) 445 if (photo_overlay_ && state() != STATE_HOVERED)
375 photo_overlay_->SetVisible(false); 446 photo_overlay_->SetVisible(false);
376 } 447 }
377 448
378 gfx::Path circular_mask_; 449 gfx::Path circular_mask_;
379 450
380 // Image that is shown when hovering over the image button. Can be NULL if 451 // 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). 452 // the photo isn't allowed to be edited (e.g. for guest profiles).
382 views::ImageView* photo_overlay_; 453 views::ImageView* photo_overlay_;
383 454
455 Profile* profile_;
456
384 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); 457 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto);
385 }; 458 };
386 459
387 // EditableProfileName ------------------------------------------------- 460 // EditableProfileName -------------------------------------------------
388 461
389 // A custom text control that turns into a textfield for editing when clicked. 462 // A custom text control that turns into a textfield for editing when clicked.
390 class EditableProfileName : public views::View, 463 class EditableProfileName : public views::View,
391 public views::ButtonListener { 464 public views::ButtonListener {
392 public: 465 public:
393 EditableProfileName(views::TextfieldController* controller, 466 EditableProfileName(views::TextfieldController* controller,
394 const base::string16& text, 467 const base::string16& text,
395 bool is_editing_allowed) 468 bool is_editing_allowed)
396 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { 469 : button_(nullptr), profile_name_textfield_(nullptr) {
397 SetLayoutManager( 470 SetLayoutManager(
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 471 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
399 472
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 473 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
401 const gfx::FontList& medium_font_list = 474 const gfx::FontList& medium_font_list =
402 rb->GetFontList(ui::ResourceBundle::MediumFont); 475 rb->GetFontList(ui::ResourceBundle::MediumFont);
476 const gfx::Insets textfield_border_insets =
477 views::Textfield().border()->GetInsets();
403 478
404 if (!is_editing_allowed) { 479 if (!is_editing_allowed) {
405 label_ = new views::Label(text); 480 views::Label* name_label = new views::Label(text);
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); 481 name_label->SetBorder(
407 label_->SetFontList(medium_font_list); 482 views::Border::CreateEmptyBorder(textfield_border_insets));
408 AddChildView(label_); 483 name_label->SetFontList(medium_font_list);
484 if (switches::IsMaterialDesignUserMenu())
485 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
486 AddChildView(name_label);
409 return; 487 return;
410 } 488 }
411 489
490 profile_name_textfield_ = new views::Textfield();
491 // Textfield that overlaps the button.
492 profile_name_textfield_->set_controller(controller);
493 profile_name_textfield_->SetFontList(medium_font_list);
494 profile_name_textfield_->SetHorizontalAlignment(
495 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT
496 : gfx::ALIGN_CENTER);
497 profile_name_textfield_->SetVisible(false);
498 AddChildView(profile_name_textfield_);
499
412 button_ = new RightAlignedIconLabelButton(this, text); 500 button_ = new RightAlignedIconLabelButton(this, text);
413 button_->SetFontList(medium_font_list); 501 button_->SetFontList(medium_font_list);
414 // Show an "edit" pencil icon when hovering over. In the default state, 502 // 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 503 // 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. 504 // the text doesn't jump around when the hovered icon appears.
417 // TODO(estade): revisit colors and press effect. 505 // TODO(estade): revisit colors and press effect.
418 const int kIconSize = 16; 506 const int kIconSize = 16;
419 button_->SetImage(views::LabelButton::STATE_NORMAL, 507 button_->SetImage(views::LabelButton::STATE_NORMAL,
420 CreateSquarePlaceholderImage(kIconSize)); 508 CreateSquarePlaceholderImage(kIconSize));
421 button_->SetImage(views::LabelButton::STATE_HOVERED, 509 button_->SetImage(views::LabelButton::STATE_HOVERED,
422 gfx::CreateVectorIcon( 510 gfx::CreateVectorIcon(
423 gfx::VectorIconId::MODE_EDIT, kIconSize, 511 gfx::VectorIconId::MODE_EDIT, kIconSize,
424 SkColorSetRGB(0x33, 0x33, 0x33))); 512 SkColorSetRGB(0x33, 0x33, 0x33)));
425 button_->SetImage(views::LabelButton::STATE_PRESSED, 513 button_->SetImage(views::LabelButton::STATE_PRESSED,
426 gfx::CreateVectorIcon( 514 gfx::CreateVectorIcon(
427 gfx::VectorIconId::MODE_EDIT, kIconSize, 515 gfx::VectorIconId::MODE_EDIT, kIconSize,
428 SkColorSetRGB(0x20, 0x20, 0x20))); 516 SkColorSetRGB(0x20, 0x20, 0x20)));
429 // To center the text, we need to offest it by the width of the icon we 517 // 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 518 // to the text to account for the textfield's border.
431 // padding to account for the textfield's border. 519 if (switches::IsMaterialDesignUserMenu()) {
432 const int kIconTextLabelButtonSpacing = 5; 520 button_->SetBorder(views::Border::CreateEmptyBorder(
433 button_->SetBorder(views::Border::CreateEmptyBorder( 521 textfield_border_insets +
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); 522 gfx::Insets(0, profile_name_textfield_->GetInsets().left(), 0, 0)));
523 } else {
524 const int kIconTextLabelButtonSpacing = 5;
525 button_->SetBorder(views::Border::CreateEmptyBorder(
526 textfield_border_insets +
527 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0)));
528 }
435 AddChildView(button_); 529 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 } 530 }
445 531
446 views::Textfield* profile_name_textfield() { 532 views::Textfield* profile_name_textfield() {
447 return profile_name_textfield_; 533 return profile_name_textfield_;
448 } 534 }
449 535
450 // Hide the editable textfield to show the profile name button instead. 536 // Hide the editable textfield to show the profile name button instead.
451 void ShowReadOnlyView() { 537 void ShowReadOnlyView() {
452 button_->SetVisible(true); 538 button_->SetVisible(true);
453 profile_name_textfield_->SetVisible(false); 539 profile_name_textfield_->SetVisible(false);
(...skipping 17 matching lines...) Expand all
471 // you press space and clicks it when you release space, as the space can be 557 // 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. 558 // part of the new profile name typed in the textfield.
473 return false; 559 return false;
474 } 560 }
475 561
476 // The label button which shows the profile name, and can handle the event to 562 // 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 563 // make it editable. Can be NULL if the profile name isn't allowed to be
478 // edited. 564 // edited.
479 RightAlignedIconLabelButton* button_; 565 RightAlignedIconLabelButton* button_;
480 566
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 567 // 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). 568 // the profile name isn't allowed to be edited (e.g. for guest profiles).
487 views::Textfield* profile_name_textfield_; 569 views::Textfield* profile_name_textfield_;
488 570
489 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); 571 DISALLOW_COPY_AND_ASSIGN(EditableProfileName);
490 }; 572 };
491 573
492 // A title card with one back button right aligned and one label center aligned. 574 // A title card with one back button right aligned and one label center aligned.
493 class TitleCard : public views::View { 575 class TitleCard : public views::View {
494 public: 576 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 639 }
558 640
559 views::ImageButton* back_button_; 641 views::ImageButton* back_button_;
560 views::Label* title_label_; 642 views::Label* title_label_;
561 643
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); 644 DISALLOW_COPY_AND_ASSIGN(TitleCard);
563 }; 645 };
564 646
565 // ProfileBadge -------------------------------------------------------- 647 // ProfileBadge --------------------------------------------------------
566 648
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. 649 // Draws a white circle, then a light blue circle, then a dark blue icon.
571 class ProfileBadge : public gfx::CanvasImageSource { 650 class ProfileBadge : public gfx::CanvasImageSource {
572 public: 651 public:
573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) 652 ProfileBadge(gfx::VectorIconId id, size_t icon_size)
574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), 653 : CanvasImageSource(
575 false), 654 gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()),
655 false),
576 id_(id), 656 id_(id),
577 icon_size_(icon_size) {} 657 icon_size_(icon_size) {}
578 658
579 ~ProfileBadge() override {} 659 ~ProfileBadge() override {}
580 660
581 // CanvasImageSource: 661 // CanvasImageSource:
582 void Draw(gfx::Canvas* canvas) override { 662 void Draw(gfx::Canvas* canvas) override {
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); 663 const SkISize size = canvas->sk_canvas()->getBaseLayerSize();
584 gfx::Rect bounds(0, 0, size.width(), size.height()); 664 gfx::Rect bounds(0, 0, size.width(), size.height());
585 665
586 SkPaint paint; 666 SkPaint paint;
587 paint.setAntiAlias(true); 667 paint.setAntiAlias(true);
588 paint.setColor(SK_ColorWHITE); 668 paint.setColor(SK_ColorWHITE);
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); 669 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint);
590 670
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); 671 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC));
592 canvas->DrawCircle(bounds.CenterPoint(), 672 canvas->DrawCircle(bounds.CenterPoint(),
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); 673 size.width() / 2 - kProfileBadgeWhitePadding, paint);
594 674
595 int offset = (kProfileBadgeSize - icon_size_) / 2; 675 int offset = (GetProfileBadgeSize() - icon_size_) / 2;
596 canvas->Translate(gfx::Vector2d(offset, offset)); 676 canvas->Translate(gfx::Vector2d(offset, offset));
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); 677 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff));
598 } 678 }
599 679
600 private: 680 private:
601 const gfx::VectorIconId id_; 681 const gfx::VectorIconId id_;
602 const size_t icon_size_; 682 const size_t icon_size_;
603 683
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); 684 DISALLOW_COPY_AND_ASSIGN(ProfileBadge);
605 }; 685 };
606 686
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { 687 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) {
608 ProfileBadge* badge = 688 ProfileBadge* badge =
609 profile->IsChild() 689 profile->IsChild()
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) 690 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT,
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); 691 switches::IsMaterialDesignUserMenu() ? 21 : 26)
612 692 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT,
693 switches::IsMaterialDesignUserMenu() ? 16 : 20);
613 return gfx::ImageSkia(badge, badge->size()); 694 return gfx::ImageSkia(badge, badge->size());
614 } 695 }
615 696
616 // ProfileChooserView --------------------------------------------------------- 697 // ProfileChooserView ---------------------------------------------------------
617 698
618 // static 699 // static
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 700 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 701 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
621 702
622 // static 703 // static
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 bool ProfileChooserView::IsShowing() { 738 bool ProfileChooserView::IsShowing() {
658 return profile_bubble_ != NULL; 739 return profile_bubble_ != NULL;
659 } 740 }
660 741
661 // static 742 // static
662 void ProfileChooserView::Hide() { 743 void ProfileChooserView::Hide() {
663 if (IsShowing()) 744 if (IsShowing())
664 profile_bubble_->GetWidget()->Close(); 745 profile_bubble_->GetWidget()->Close();
665 } 746 }
666 747
748 // static
749 int ProfileChooserView::GetFixedMenuWidth() {
750 return switches::IsMaterialDesignUserMenu() ? 240 : 250;
751 }
752
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 753 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
668 Browser* browser, 754 Browser* browser,
669 profiles::BubbleViewMode view_mode, 755 profiles::BubbleViewMode view_mode,
670 profiles::TutorialMode tutorial_mode, 756 profiles::TutorialMode tutorial_mode,
671 signin::GAIAServiceType service_type, 757 signin::GAIAServiceType service_type,
672 signin_metrics::AccessPoint access_point) 758 signin_metrics::AccessPoint access_point)
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 759 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
674 browser_(browser), 760 browser_(browser),
675 view_mode_(view_mode), 761 view_mode_(view_mode),
676 tutorial_mode_(tutorial_mode), 762 tutorial_mode_(tutorial_mode),
(...skipping 10 matching lines...) Expand all
687 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 773 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
688 if (oauth2_token_service) 774 if (oauth2_token_service)
689 oauth2_token_service->RemoveObserver(this); 775 oauth2_token_service->RemoveObserver(this);
690 } 776 }
691 777
692 void ProfileChooserView::ResetView() { 778 void ProfileChooserView::ResetView() {
693 open_other_profile_indexes_map_.clear(); 779 open_other_profile_indexes_map_.clear();
694 delete_account_button_map_.clear(); 780 delete_account_button_map_.clear();
695 reauth_account_button_map_.clear(); 781 reauth_account_button_map_.clear();
696 manage_accounts_link_ = NULL; 782 manage_accounts_link_ = NULL;
697 signin_current_profile_link_ = NULL; 783 signin_current_profile_button_ = NULL;
698 auth_error_email_button_ = NULL; 784 auth_error_email_button_ = NULL;
699 current_profile_photo_ = NULL; 785 current_profile_photo_ = NULL;
700 current_profile_name_ = NULL; 786 current_profile_name_ = NULL;
701 users_button_ = NULL; 787 users_button_ = NULL;
702 go_incognito_button_ = NULL; 788 go_incognito_button_ = NULL;
703 lock_button_ = NULL; 789 lock_button_ = NULL;
704 add_account_link_ = NULL; 790 add_account_link_ = NULL;
705 gaia_signin_cancel_button_ = NULL; 791 gaia_signin_cancel_button_ = NULL;
706 remove_account_button_ = NULL; 792 remove_account_button_ = NULL;
707 account_removal_cancel_button_ = NULL; 793 account_removal_cancel_button_ = NULL;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 break; 918 break;
833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 919 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 920 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
835 sub_view = CreateSwitchUserView(); 921 sub_view = CreateSwitchUserView();
836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 922 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); 923 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
838 break; 924 break;
839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: 925 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: 926 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: 927 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER:
842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 928 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth());
843 sub_view = CreateProfileChooserView(avatar_menu); 929 sub_view = CreateProfileChooserView(avatar_menu);
844 break; 930 break;
845 } 931 }
846 // Clears tutorial mode for all non-profile-chooser views. 932 // Clears tutorial mode for all non-profile-chooser views.
847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) 933 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 934 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
849 935
850 layout->StartRow(1, 0); 936 layout->StartRow(1, 0);
851 layout->AddView(sub_view); 937 layout->AddView(sub_view);
852 Layout(); 938 Layout();
(...skipping 26 matching lines...) Expand all
879 if (accelerator.key_code() != ui::VKEY_DOWN && 965 if (accelerator.key_code() != ui::VKEY_DOWN &&
880 accelerator.key_code() != ui::VKEY_UP) 966 accelerator.key_code() != ui::VKEY_UP)
881 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); 967 return BubbleDialogDelegateView::AcceleratorPressed(accelerator);
882 968
883 // Move the focus up or down. 969 // Move the focus up or down.
884 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); 970 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN);
885 return true; 971 return true;
886 } 972 }
887 973
888 views::View* ProfileChooserView::GetInitiallyFocusedView() { 974 views::View* ProfileChooserView::GetInitiallyFocusedView() {
889 return signin_current_profile_link_; 975 return signin_current_profile_button_;
890 } 976 }
891 977
892 int ProfileChooserView::GetDialogButtons() const { 978 int ProfileChooserView::GetDialogButtons() const {
893 return ui::DIALOG_BUTTON_NONE; 979 return ui::DIALOG_BUTTON_NONE;
894 } 980 }
895 981
896 bool ProfileChooserView::HandleContextMenu( 982 bool ProfileChooserView::HandleContextMenu(
897 const content::ContextMenuParams& params) { 983 const content::ContextMenuParams& params) {
898 // Suppresses the context menu because some features, such as inspecting 984 // Suppresses the context menu because some features, such as inspecting
899 // elements, are not appropriate in a bubble. 985 // elements, are not appropriate in a bubble.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 bool account_management_available = 1034 bool account_management_available =
949 SigninManagerFactory::GetForProfile(browser_->profile())-> 1035 SigninManagerFactory::GetForProfile(browser_->profile())->
950 IsAuthenticated() && 1036 IsAuthenticated() &&
951 switches::IsEnableAccountConsistency(); 1037 switches::IsEnableAccountConsistency();
952 ShowViewFromMode(account_management_available ? 1038 ShowViewFromMode(account_management_available ?
953 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 1039 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
954 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); 1040 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
955 } else if (sender == current_profile_photo_) { 1041 } else if (sender == current_profile_photo_) {
956 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 1042 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
957 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); 1043 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE);
958 } else if (sender == signin_current_profile_link_) { 1044 } else if (sender == signin_current_profile_button_) {
959 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); 1045 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
960 } else if (sender == add_person_button_) { 1046 } else if (sender == add_person_button_) {
961 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 1047 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
962 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 1048 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
963 UserManager::Show(base::FilePath(), 1049 UserManager::Show(base::FilePath(),
964 profiles::USER_MANAGER_NO_TUTORIAL, 1050 profiles::USER_MANAGER_NO_TUTORIAL,
965 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 1051 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
966 } else if (sender == disconnect_button_) { 1052 } else if (sender == disconnect_button_) {
967 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 1053 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
968 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); 1054 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 Indexes other_profiles; 1171 Indexes other_profiles;
1086 views::View* tutorial_view = NULL; 1172 views::View* tutorial_view = NULL;
1087 views::View* current_profile_view = NULL; 1173 views::View* current_profile_view = NULL;
1088 views::View* current_profile_accounts = NULL; 1174 views::View* current_profile_accounts = NULL;
1089 views::View* option_buttons_view = NULL; 1175 views::View* option_buttons_view = NULL;
1090 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1176 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1091 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1177 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1092 if (item.active) { 1178 if (item.active) {
1093 option_buttons_view = CreateOptionsView( 1179 option_buttons_view = CreateOptionsView(
1094 item.signed_in && profiles::IsLockAvailable(browser_->profile())); 1180 item.signed_in && profiles::IsLockAvailable(browser_->profile()));
1095 current_profile_view = CreateCurrentProfileView(item, false); 1181 current_profile_view =
1182 switches::IsMaterialDesignUserMenu()
1183 ? CreateMaterialDesignCurrentProfileView(item, false)
1184 : CreateCurrentProfileView(item, false);
1096 if (IsProfileChooser(view_mode_)) { 1185 if (IsProfileChooser(view_mode_)) {
1097 tutorial_view = CreateTutorialViewIfNeeded(item); 1186 tutorial_view = CreateTutorialViewIfNeeded(item);
1098 } else { 1187 } else {
1099 current_profile_accounts = CreateCurrentProfileAccountsView(item); 1188 current_profile_accounts = CreateCurrentProfileAccountsView(item);
1100 } 1189 }
1101 } else { 1190 } else {
1102 other_profiles.push_back(i); 1191 other_profiles.push_back(i);
1103 } 1192 }
1104 } 1193 }
1105 1194
(...skipping 16 matching lines...) Expand all
1122 1211
1123 if (!IsProfileChooser(view_mode_)) { 1212 if (!IsProfileChooser(view_mode_)) {
1124 DCHECK(current_profile_accounts); 1213 DCHECK(current_profile_accounts);
1125 layout->StartRow(0, 0); 1214 layout->StartRow(0, 0);
1126 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1215 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1127 layout->StartRow(1, 0); 1216 layout->StartRow(1, 0);
1128 layout->AddView(current_profile_accounts); 1217 layout->AddView(current_profile_accounts);
1129 } 1218 }
1130 1219
1131 if (browser_->profile()->IsSupervised()) { 1220 if (browser_->profile()->IsSupervised()) {
1132 layout->StartRow(0, 0); 1221 if (!switches::IsMaterialDesignUserMenu()) {
1133 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1222 layout->StartRow(0, 0);
1223 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1224 }
1134 layout->StartRow(1, 0); 1225 layout->StartRow(1, 0);
1135 layout->AddView(CreateSupervisedUserDisclaimerView()); 1226 layout->AddView(CreateSupervisedUserDisclaimerView());
1136 } 1227 }
1137 1228
1138 layout->StartRow(0, 0); 1229 layout->StartRow(0, 0);
1139 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1230 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1140 1231
1141 if (option_buttons_view) { 1232 if (option_buttons_view) {
1142 layout->StartRow(0, 0); 1233 layout->StartRow(0, 0);
1143 layout->AddView(option_buttons_view); 1234 layout->AddView(option_buttons_view);
(...skipping 11 matching lines...) Expand all
1155 } 1246 }
1156 } 1247 }
1157 1248
1158 layout->StartRow(1, 0); 1249 layout->StartRow(1, 0);
1159 layout->AddView(CreateOtherProfilesView(other_profiles)); 1250 layout->AddView(CreateOtherProfilesView(other_profiles));
1160 } 1251 }
1161 1252
1162 views::View* ProfileChooserView::CreateProfileChooserView( 1253 views::View* ProfileChooserView::CreateProfileChooserView(
1163 AvatarMenu* avatar_menu) { 1254 AvatarMenu* avatar_menu) {
1164 views::View* view = new views::View(); 1255 views::View* view = new views::View();
1165 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1256 views::GridLayout* layout =
1257 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1166 1258
1167 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { 1259 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
1168 PopulateMinimalProfileChooserView(layout, avatar_menu); 1260 PopulateMinimalProfileChooserView(layout, avatar_menu);
1169 // The user is using right-click switching, no need to tell them about it. 1261 // The user is using right-click switching, no need to tell them about it.
1170 PrefService* local_state = g_browser_process->local_state(); 1262 PrefService* local_state = g_browser_process->local_state();
1171 local_state->SetBoolean( 1263 local_state->SetBoolean(
1172 prefs::kProfileAvatarRightClickTutorialDismissed, true); 1264 prefs::kProfileAvatarRightClickTutorialDismissed, true);
1173 } else { 1265 } else {
1174 PopulateCompleteProfileChooserView(layout, avatar_menu); 1266 PopulateCompleteProfileChooserView(layout, avatar_menu);
1175 } 1267 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 const base::string16& button_text, 1322 const base::string16& button_text,
1231 bool stack_button, 1323 bool stack_button,
1232 views::Link** link, 1324 views::Link** link,
1233 views::LabelButton** button, 1325 views::LabelButton** button,
1234 views::ImageButton** close_button) { 1326 views::ImageButton** close_button) {
1235 tutorial_mode_ = tutorial_mode; 1327 tutorial_mode_ = tutorial_mode;
1236 1328
1237 views::View* view = new views::View(); 1329 views::View* view = new views::View();
1238 view->set_background(views::Background::CreateSolidBackground( 1330 view->set_background(views::Background::CreateSolidBackground(
1239 profiles::kAvatarTutorialBackgroundColor)); 1331 profiles::kAvatarTutorialBackgroundColor));
1240 views::GridLayout* layout = CreateSingleColumnLayout(view, 1332 views::GridLayout* layout = CreateSingleColumnLayout(
1241 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1333 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1242 // Creates a second column set for buttons and links. 1334 // Creates a second column set for buttons and links.
1243 views::ColumnSet* button_columns = layout->AddColumnSet(1); 1335 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1244 button_columns->AddColumn(views::GridLayout::LEADING, 1336 button_columns->AddColumn(views::GridLayout::LEADING,
1245 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1337 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1246 button_columns->AddPaddingColumn( 1338 button_columns->AddPaddingColumn(
1247 1, views::kUnrelatedControlHorizontalSpacing); 1339 1, views::kUnrelatedControlHorizontalSpacing);
1248 button_columns->AddColumn(views::GridLayout::TRAILING, 1340 button_columns->AddColumn(views::GridLayout::TRAILING,
1249 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1341 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1250 layout->SetInsets(views::kButtonVEdgeMarginNew, 1342 layout->SetInsets(views::kButtonVEdgeMarginNew,
1251 views::kButtonHEdgeMarginNew, 1343 views::kButtonHEdgeMarginNew,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 layout->SkipColumns(1); 1425 layout->SkipColumns(1);
1334 } 1426 }
1335 1427
1336 return view; 1428 return view;
1337 } 1429 }
1338 1430
1339 views::View* ProfileChooserView::CreateCurrentProfileView( 1431 views::View* ProfileChooserView::CreateCurrentProfileView(
1340 const AvatarMenu::Item& avatar_item, 1432 const AvatarMenu::Item& avatar_item,
1341 bool is_guest) { 1433 bool is_guest) {
1342 views::View* view = new views::View(); 1434 views::View* view = new views::View();
1343 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; 1435 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew;
1344 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); 1436 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width);
1345 layout->SetInsets(views::kButtonVEdgeMarginNew, 1437 layout->SetInsets(views::kButtonVEdgeMarginNew,
1346 views::kButtonHEdgeMarginNew, 1438 views::kButtonHEdgeMarginNew,
1347 views::kUnrelatedControlVerticalSpacing, 1439 views::kUnrelatedControlVerticalSpacing,
1348 views::kButtonHEdgeMarginNew); 1440 views::kButtonHEdgeMarginNew);
1349 1441
1350 // Profile icon, centered. 1442 // Profile icon, centered.
1351 int x_offset = (column_width - kLargeImageSide) / 2; 1443 int x_offset = (column_width - kLargeImageSide) / 2;
1352 current_profile_photo_ = new EditableProfilePhoto( 1444 current_profile_photo_ = new EditableProfilePhoto(
1353 this, avatar_item.icon, !is_guest, 1445 this, avatar_item.icon, !is_guest, browser_->profile());
1354 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); 1446 current_profile_photo_->SetX(x_offset);
1355 SizedContainer* profile_icon_container = 1447 SizedContainer* profile_icon_container =
1356 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); 1448 new SizedContainer(gfx::Size(column_width, kLargeImageSide));
1357 profile_icon_container->AddChildView(current_profile_photo_); 1449 profile_icon_container->AddChildView(current_profile_photo_);
1358 1450
1359 if (browser_->profile()->IsSupervised()) {
1360 views::ImageView* supervised_icon = new views::ImageView();
1361 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile()));
1362 gfx::Size preferred_size = supervised_icon->GetPreferredSize();
1363 gfx::Rect parent_bounds = current_profile_photo_->bounds();
1364 supervised_icon->SetBounds(
1365 parent_bounds.right() - preferred_size.width(),
1366 parent_bounds.bottom() - preferred_size.height(),
1367 preferred_size.width(),
1368 preferred_size.height());
1369 profile_icon_container->AddChildView(supervised_icon);
1370 }
1371 1451
1372 layout->StartRow(1, 0); 1452 layout->StartRow(1, 0);
1373 layout->AddView(profile_icon_container); 1453 layout->AddView(profile_icon_container);
1374 1454
1375 // Profile name, centered. 1455 // Profile name, centered.
1376 bool editing_allowed = !is_guest && 1456 bool editing_allowed = !is_guest &&
1377 !browser_->profile()->IsLegacySupervised(); 1457 !browser_->profile()->IsLegacySupervised();
1378 current_profile_name_ = new EditableProfileName( 1458 current_profile_name_ = new EditableProfileName(
1379 this, 1459 this,
1380 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), 1460 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 if (signin_manager->IsSigninAllowed()) { 1511 if (signin_manager->IsSigninAllowed()) {
1432 views::Label* promo = new views::Label( 1512 views::Label* promo = new views::Label(
1433 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); 1513 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1434 promo->SetMultiLine(true); 1514 promo->SetMultiLine(true);
1435 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1515 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1436 layout->StartRowWithPadding(1, 0, 0, 1516 layout->StartRowWithPadding(1, 0, 0,
1437 views::kRelatedControlSmallVerticalSpacing); 1517 views::kRelatedControlSmallVerticalSpacing);
1438 layout->StartRow(1, 0); 1518 layout->StartRow(1, 0);
1439 layout->AddView(promo); 1519 layout->AddView(promo);
1440 1520
1441 signin_current_profile_link_ = new views::BlueButton( 1521 signin_current_profile_button_ = new views::BlueButton(
1442 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, 1522 this, l10n_util::GetStringFUTF16(
1443 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 1523 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1524 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1444 layout->StartRowWithPadding(1, 0, 0, 1525 layout->StartRowWithPadding(1, 0, 0,
1445 views::kRelatedControlVerticalSpacing); 1526 views::kRelatedControlVerticalSpacing);
1446 layout->StartRow(1, 0); 1527 layout->StartRow(1, 0);
1447 layout->AddView(signin_current_profile_link_); 1528 layout->AddView(signin_current_profile_button_);
1448 content::RecordAction( 1529 content::RecordAction(
1449 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); 1530 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1450 } 1531 }
1451 } 1532 }
1452 1533
1453 return view; 1534 return view;
1454 } 1535 }
1455 1536
1537 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
1538 const AvatarMenu::Item& avatar_item,
1539 bool is_guest) {
1540 views::View* view = new views::View();
1541 view->SetLayoutManager(
1542 new views::BoxLayout(views::BoxLayout::kVertical, kMaterialMenuEdgeMargin,
1543 views::kRelatedControlVerticalSpacing,
1544 views::kRelatedControlVerticalSpacing));
1545
1546 // Profile container for the profile photo and avatar/user name.
1547 views::View* profile_container = new views::View();
1548
1549 // Profile picture, left-aligned.
1550 current_profile_photo_ = new EditableProfilePhoto(
1551 this, avatar_item.icon, !is_guest, browser_->profile());
1552
1553 // Profile name, left-aligned to the right of profile icon.
1554 bool editing_allowed =
1555 !is_guest && !browser_->profile()->IsLegacySupervised();
1556 current_profile_name_ = new EditableProfileName(
1557 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()),
1558 editing_allowed);
1559 views::View* profile_name_container = new views::View();
1560 int name_container_v_spacing = views::kRelatedControlSmallVerticalSpacing;
1561 if (!avatar_item.signed_in)
1562 name_container_v_spacing += views::kRelatedControlVerticalSpacing;
1563 profile_name_container->SetLayoutManager(new views::BoxLayout(
1564 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0));
1565 profile_name_container->AddChildView(current_profile_name_);
1566
1567 const int between_child_spacing =
1568 kMaterialMenuEdgeMargin - current_profile_photo_->badge_spacing;
1569 profile_container->SetLayoutManager(new views::BoxLayout(
1570 views::BoxLayout::kHorizontal, 0,
1571 views::kRelatedControlSmallVerticalSpacing, between_child_spacing));
1572 profile_container->AddChildView(current_profile_photo_);
1573 profile_container->AddChildView(profile_name_container);
1574 view->AddChildView(profile_container);
1575
1576 if (is_guest)
1577 return view;
1578
1579 // The available links depend on the type of profile that is active.
1580 if (avatar_item.signed_in) {
1581 if (switches::IsEnableAccountConsistency()) {
1582 base::string16 link_title = l10n_util::GetStringUTF16(
1583 IsProfileChooser(view_mode_)
1584 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON
1585 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
1586 manage_accounts_link_ = CreateLink(link_title, this);
1587 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1588 profile_name_container->AddChildView(manage_accounts_link_);
1589 } else {
1590 views::Label* email_label = new views::Label(avatar_item.username);
1591 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1592 email_label->SetEnabled(false);
1593 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1594 profile_name_container->AddChildView(email_label);
1595 }
1596 return view;
1597 }
1598
1599 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
1600 browser_->profile()->GetOriginalProfile());
1601 if (signin_manager->IsSigninAllowed()) {
1602 views::Label* promo =
1603 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1604 promo->SetMultiLine(true);
1605 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1606 view->AddChildView(promo);
1607
1608 signin_current_profile_button_ =
1609 views::MdTextButton::CreateSecondaryUiBlueButton(
1610 this, l10n_util::GetStringFUTF16(
1611 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1612 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1613 view->AddChildView(signin_current_profile_button_);
1614 content::RecordAction(
1615 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1616 view->SetBorder(views::Border::CreateEmptyBorder(
1617 0, 0, views::kRelatedControlVerticalSpacing, 0));
1618 }
1619
1620 return view;
1621 }
1622
1456 views::View* ProfileChooserView::CreateGuestProfileView() { 1623 views::View* ProfileChooserView::CreateGuestProfileView() {
1457 gfx::Image guest_icon = 1624 gfx::Image guest_icon =
1458 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 1625 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
1459 profiles::GetPlaceholderAvatarIconResourceID()); 1626 profiles::GetPlaceholderAvatarIconResourceID());
1460 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); 1627 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon);
1461 guest_avatar_item.active = true; 1628 guest_avatar_item.active = true;
1462 guest_avatar_item.name = l10n_util::GetStringUTF16( 1629 guest_avatar_item.name = l10n_util::GetStringUTF16(
1463 IDS_PROFILES_GUEST_PROFILE_NAME); 1630 IDS_PROFILES_GUEST_PROFILE_NAME);
1464 guest_avatar_item.signed_in = false; 1631 guest_avatar_item.signed_in = false;
1465 1632
1466 return CreateCurrentProfileView(guest_avatar_item, true); 1633 return switches::IsMaterialDesignUserMenu()
1634 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true)
1635 : CreateCurrentProfileView(guest_avatar_item, true);
1467 } 1636 }
1468 1637
1469 views::View* ProfileChooserView::CreateOtherProfilesView( 1638 views::View* ProfileChooserView::CreateOtherProfilesView(
1470 const Indexes& avatars_to_show) { 1639 const Indexes& avatars_to_show) {
1471 views::View* view = new views::View(); 1640 views::View* view = new views::View();
1472 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1641 views::GridLayout* layout =
1642 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1473 1643
1474 for (size_t index : avatars_to_show) { 1644 for (size_t index : avatars_to_show) {
1475 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); 1645 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index);
1476 const int kSmallImageSide = 32; 1646 const int kSmallImageSide = 32;
1477 1647
1478 // Use the low-res, small default avatars in the fast user switcher, like 1648 // Use the low-res, small default avatars in the fast user switcher, like
1479 // we do in the menu bar. 1649 // we do in the menu bar.
1480 gfx::Image item_icon; 1650 gfx::Image item_icon;
1481 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); 1651 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon);
1482 1652
(...skipping 10 matching lines...) Expand all
1493 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1663 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1494 layout->StartRow(1, 0); 1664 layout->StartRow(1, 0);
1495 layout->AddView(button); 1665 layout->AddView(button);
1496 } 1666 }
1497 1667
1498 return view; 1668 return view;
1499 } 1669 }
1500 1670
1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { 1671 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
1502 views::View* view = new views::View(); 1672 views::View* view = new views::View();
1503 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1673 views::GridLayout* layout =
1674 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1504 1675
1505 base::string16 text = browser_->profile()->IsGuestSession() ? 1676 base::string16 text = browser_->profile()->IsGuestSession() ?
1506 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : 1677 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
1507 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); 1678 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
1508 if (!browser_->profile()->IsGuestSession() 1679 if (!browser_->profile()->IsGuestSession()
1509 && switches::IsMaterialDesignUserMenu()) { 1680 && switches::IsMaterialDesignUserMenu()) {
1510 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); 1681 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
1511 } 1682 }
1512 const int kIconSize = 16; 1683 const int kIconSize = 16;
1513 1684
(...skipping 29 matching lines...) Expand all
1543 gfx::kChromeIconGrey)); 1714 gfx::kChromeIconGrey));
1544 layout->StartRow(1, 0); 1715 layout->StartRow(1, 0);
1545 layout->AddView(lock_button_); 1716 layout->AddView(lock_button_);
1546 } 1717 }
1547 return view; 1718 return view;
1548 } 1719 }
1549 1720
1550 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { 1721 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
1551 views::View* view = new views::View(); 1722 views::View* view = new views::View();
1552 views::GridLayout* layout = CreateSingleColumnLayout( 1723 views::GridLayout* layout = CreateSingleColumnLayout(
1553 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1724 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1554 layout->SetInsets(views::kRelatedControlVerticalSpacing, 1725 if (switches::IsMaterialDesignUserMenu()) {
1555 views::kButtonHEdgeMarginNew, 1726 layout->SetInsets(0, kMaterialMenuEdgeMargin, kMaterialMenuEdgeMargin,
1556 views::kRelatedControlVerticalSpacing, 1727 kMaterialMenuEdgeMargin);
1557 views::kButtonHEdgeMarginNew); 1728 } else {
1729 layout->SetInsets(
1730 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew,
1731 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew);
1732 }
1733
1558 views::Label* disclaimer = new views::Label( 1734 views::Label* disclaimer = new views::Label(
1559 avatar_menu_->GetSupervisedUserInformation()); 1735 avatar_menu_->GetSupervisedUserInformation());
1560 disclaimer->SetMultiLine(true); 1736 disclaimer->SetMultiLine(true);
1561 disclaimer->SetAllowCharacterBreak(true); 1737 disclaimer->SetAllowCharacterBreak(true);
1562 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1738 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1563 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1739 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1564 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); 1740 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont));
1565 layout->StartRow(1, 0); 1741 layout->StartRow(1, 0);
1566 layout->AddView(disclaimer); 1742 layout->AddView(disclaimer);
1567 1743
1568 return view; 1744 return view;
1569 } 1745 }
1570 1746
1571 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( 1747 views::View* ProfileChooserView::CreateCurrentProfileAccountsView(
1572 const AvatarMenu::Item& avatar_item) { 1748 const AvatarMenu::Item& avatar_item) {
1573 DCHECK(avatar_item.signed_in); 1749 DCHECK(avatar_item.signed_in);
1574 views::View* view = new views::View(); 1750 views::View* view = new views::View();
1575 view->set_background(views::Background::CreateSolidBackground( 1751 view->set_background(views::Background::CreateSolidBackground(
1576 profiles::kAvatarBubbleAccountsBackgroundColor)); 1752 profiles::kAvatarBubbleAccountsBackgroundColor));
1577 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1753 views::GridLayout* layout =
1754 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1578 1755
1579 Profile* profile = browser_->profile(); 1756 Profile* profile = browser_->profile();
1580 std::string primary_account = 1757 std::string primary_account =
1581 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); 1758 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId();
1582 DCHECK(!primary_account.empty()); 1759 DCHECK(!primary_account.empty());
1583 std::vector<std::string>accounts = 1760 std::vector<std::string>accounts =
1584 profiles::GetSecondaryAccountsForProfile(profile, primary_account); 1761 profiles::GetSecondaryAccountsForProfile(profile, primary_account);
1585 1762
1586 // Get state of authentication error, if any. 1763 // Get state of authentication error, if any.
1587 std::string error_account_id = GetAuthErrorAccountId(profile); 1764 std::string error_account_id = GetAuthErrorAccountId(profile);
1588 1765
1589 // The primary account should always be listed first. 1766 // The primary account should always be listed first.
1590 // TODO(rogerta): we still need to further differentiate the primary account 1767 // 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: 1768 // from the others in the UI, so more work is likely required here:
1592 // crbug.com/311124. 1769 // crbug.com/311124.
1593 CreateAccountButton(layout, primary_account, true, 1770 CreateAccountButton(layout, primary_account, true,
1594 error_account_id == primary_account, kFixedMenuWidth); 1771 error_account_id == primary_account, GetFixedMenuWidth());
1595 for (size_t i = 0; i < accounts.size(); ++i) 1772 for (size_t i = 0; i < accounts.size(); ++i)
1596 CreateAccountButton(layout, accounts[i], false, 1773 CreateAccountButton(layout, accounts[i], false,
1597 error_account_id == accounts[i], kFixedMenuWidth); 1774 error_account_id == accounts[i], GetFixedMenuWidth());
1598 1775
1599 if (!profile->IsSupervised()) { 1776 if (!profile->IsSupervised()) {
1600 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1777 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1601 1778
1602 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( 1779 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16(
1603 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); 1780 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this);
1604 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( 1781 add_account_link_->SetBorder(views::Border::CreateEmptyBorder(
1605 0, views::kButtonVEdgeMarginNew, 1782 0, views::kButtonVEdgeMarginNew,
1606 views::kRelatedControlVerticalSpacing, 0)); 1783 views::kRelatedControlVerticalSpacing, 0));
1607 layout->StartRow(1, 0); 1784 layout->StartRow(1, 0);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2074 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1898 IncognitoModePrefs::DISABLED; 2075 IncognitoModePrefs::DISABLED;
1899 return incognito_available && !browser_->profile()->IsGuestSession(); 2076 return incognito_available && !browser_->profile()->IsGuestSession();
1900 } 2077 }
1901 2078
1902 void ProfileChooserView::PostActionPerformed( 2079 void ProfileChooserView::PostActionPerformed(
1903 ProfileMetrics::ProfileDesktopMenu action_performed) { 2080 ProfileMetrics::ProfileDesktopMenu action_performed) {
1904 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2081 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1905 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2082 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1906 } 2083 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698