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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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 if (switches::IsMaterialDesignUserMenu()) { |
315 SetBoundsRect(bounds); | 331 SetBorder(views::Border::CreateEmptyBorder( |
332 views::kRelatedControlSmallVerticalSpacing, 0, 0, 0)); | |
333 } else { | |
334 SetBorder(views::Border::NullBorder()); | |
335 } | |
336 SetSize(gfx::Size( | |
337 GetPreferredSize().width() + badge_spacing, | |
338 GetPreferredSize().height() + badge_spacing + GetInsets().top())); | |
316 | 339 |
317 // Calculate the circular mask that will be used to display the photo. | 340 // Calculate the circular mask that will be used to display the photo. |
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 341 circular_mask_.addCircle(SkIntToScalar(icon_image_side / 2), |
319 SkIntToScalar(bounds.height() / 2), | 342 SkIntToScalar(icon_image_side / 2) + badge_spacing, |
320 SkIntToScalar(bounds.width() / 2)); | 343 SkIntToScalar(icon_image_side / 2)); |
321 | 344 |
322 if (!is_editing_allowed) { | 345 if (!is_editing_allowed) { |
323 SetEnabled(false); | 346 SetEnabled(false); |
324 return; | 347 return; |
325 } | 348 } |
326 | 349 |
327 set_notify_enter_exit_on_child(true); | 350 set_notify_enter_exit_on_child(true); |
328 | 351 |
329 // Photo overlay that appears when hovering over the button. | 352 // Photo overlay that appears when hovering over the button. |
330 photo_overlay_ = new views::ImageView(); | 353 photo_overlay_ = new views::ImageView(); |
331 | 354 |
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 355 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
333 photo_overlay_->set_background( | 356 photo_overlay_->set_background( |
334 views::Background::CreateSolidBackground(kBackgroundColor)); | 357 views::Background::CreateSolidBackground(kBackgroundColor)); |
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 358 photo_overlay_->SetImage( |
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 359 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA, |
360 switches::IsMaterialDesignUserMenu() ? 22u : 48u, | |
361 SkColorSetRGB(0x33, 0x33, 0x33))); | |
337 | 362 |
338 photo_overlay_->SetSize(bounds.size()); | 363 photo_overlay_->SetSize(gfx::Size(icon_image_side, icon_image_side)); |
364 photo_overlay_->SetY(badge_spacing); | |
339 photo_overlay_->SetVisible(false); | 365 photo_overlay_->SetVisible(false); |
340 AddChildView(photo_overlay_); | 366 AddChildView(photo_overlay_); |
341 } | 367 } |
342 | 368 |
343 void OnPaint(gfx::Canvas* canvas) override { | 369 void OnPaint(gfx::Canvas* canvas) override { |
370 canvas->Save(); | |
344 // Display the profile picture as a circle. | 371 // Display the profile picture as a circle. |
345 canvas->ClipPath(circular_mask_, true); | 372 canvas->ClipPath(circular_mask_, true); |
346 views::LabelButton::OnPaint(canvas); | 373 views::LabelButton::OnPaint(canvas); |
374 canvas->Restore(); | |
347 } | 375 } |
348 | 376 |
349 void PaintChildren(const ui::PaintContext& context) override { | 377 void PaintChildren(const ui::PaintContext& context) override { |
350 // Display any children (the "change photo" overlay) as a circle. | 378 // Display any children (the "change photo" overlay) as a circle. |
351 ui::ClipRecorder clip_recorder(context); | 379 ui::ClipRecorder clip_recorder(context); |
352 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); | 380 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); |
353 View::PaintChildren(context); | 381 View::PaintChildren(context); |
382 | |
383 ui::PaintRecorder recorder( | |
384 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); | |
385 gfx::Canvas* canvas = recorder.canvas(); | |
386 if (profile_->IsSupervised()) { | |
387 gfx::VectorIconId icon_id; | |
388 size_t icon_size; | |
389 if (profile_->IsChild()) { | |
390 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT; | |
391 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26; | |
392 } else { | |
393 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
394 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20; | |
395 } | |
396 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | |
397 | |
398 int badge_offset = views::kRelatedControlSmallVerticalSpacing + | |
399 icon_image_side + badge_spacing - | |
400 GetProfileBadgeSize(); | |
401 gfx::Point center_point = | |
402 bounds.CenterPoint() + gfx::Vector2d(badge_offset, badge_offset); | |
403 SkPaint paint; | |
404 paint.setAntiAlias(true); | |
405 paint.setColor(GetNativeTheme()->GetSystemColor( | |
406 ui::NativeTheme::kColorId_BubbleBackground)); | |
407 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); | |
408 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | |
409 canvas->DrawCircle(center_point, | |
Evan Stade
2016/06/24 18:25:26
what is this?
Jane
2016/06/27 18:08:56
This is to draw the light blue circular background
Evan Stade
2016/06/28 03:02:49
I don't see a light blue bg in the mocks. All I se
Jane
2016/06/28 14:59:22
Oops, you are right, I totally missed that change.
Evan Stade
2016/06/28 23:32:09
it already is in color_palette.h as kChromeIconGre
Jane
2016/06/29 15:39:36
Sorry, I got confused because of an inconsistency
| |
410 GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | |
411 paint); | |
412 | |
413 int offset = (GetProfileBadgeSize() - icon_size) / 2; | |
414 canvas->Translate( | |
415 gfx::Vector2d(badge_offset + offset, badge_offset + offset)); | |
416 gfx::PaintVectorIcon(canvas, icon_id, icon_size, | |
417 SkColorSetRGB(0, 0x66, 0xff)); | |
Evan Stade
2016/06/28 03:02:49
this should almost certainly be something from col
Jane
2016/06/28 14:59:22
(Changed it to white)
I couldn't find any defined
Jane
2016/06/28 15:33:11
Actually, I think it makes sense for this color to
Evan Stade
2016/06/28 23:32:09
a) the definition for white is SK_ColorWHITE
b) in
Jane
2016/06/29 15:39:36
Good suggestion on simplifying the code! I think I
| |
418 } | |
354 } | 419 } |
355 | 420 |
421 int icon_image_side = | |
422 switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide; | |
423 int badge_spacing = switches::IsMaterialDesignUserMenu() ? 4 : 0; | |
424 | |
356 private: | 425 private: |
357 // views::CustomButton: | 426 // views::CustomButton: |
358 void StateChanged() override { | 427 void StateChanged() override { |
359 bool show_overlay = | 428 bool show_overlay = |
360 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); | 429 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); |
361 if (photo_overlay_) | 430 if (photo_overlay_) |
362 photo_overlay_->SetVisible(show_overlay); | 431 photo_overlay_->SetVisible(show_overlay); |
363 } | 432 } |
364 | 433 |
365 void OnFocus() override { | 434 void OnFocus() override { |
366 views::LabelButton::OnFocus(); | 435 views::LabelButton::OnFocus(); |
367 if (photo_overlay_) | 436 if (photo_overlay_) |
368 photo_overlay_->SetVisible(true); | 437 photo_overlay_->SetVisible(true); |
369 } | 438 } |
370 | 439 |
371 void OnBlur() override { | 440 void OnBlur() override { |
372 views::LabelButton::OnBlur(); | 441 views::LabelButton::OnBlur(); |
373 // Don't hide the overlay if it's being shown as a result of a mouseover. | 442 // Don't hide the overlay if it's being shown as a result of a mouseover. |
374 if (photo_overlay_ && state() != STATE_HOVERED) | 443 if (photo_overlay_ && state() != STATE_HOVERED) |
375 photo_overlay_->SetVisible(false); | 444 photo_overlay_->SetVisible(false); |
376 } | 445 } |
377 | 446 |
378 gfx::Path circular_mask_; | 447 gfx::Path circular_mask_; |
379 | 448 |
380 // Image that is shown when hovering over the image button. Can be NULL if | 449 // 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). | 450 // the photo isn't allowed to be edited (e.g. for guest profiles). |
382 views::ImageView* photo_overlay_; | 451 views::ImageView* photo_overlay_; |
383 | 452 |
453 Profile* profile_; | |
454 | |
384 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 455 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
385 }; | 456 }; |
386 | 457 |
387 // EditableProfileName ------------------------------------------------- | 458 // EditableProfileName ------------------------------------------------- |
388 | 459 |
389 // A custom text control that turns into a textfield for editing when clicked. | 460 // A custom text control that turns into a textfield for editing when clicked. |
390 class EditableProfileName : public views::View, | 461 class EditableProfileName : public views::View, |
391 public views::ButtonListener { | 462 public views::ButtonListener { |
392 public: | 463 public: |
393 EditableProfileName(views::TextfieldController* controller, | 464 EditableProfileName(views::TextfieldController* controller, |
394 const base::string16& text, | 465 const base::string16& text, |
395 bool is_editing_allowed) | 466 bool is_editing_allowed) |
396 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { | 467 : button_(nullptr), profile_name_textfield_(nullptr) { |
397 SetLayoutManager( | 468 SetLayoutManager( |
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 469 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
399 | 470 |
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 471 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
401 const gfx::FontList& medium_font_list = | 472 const gfx::FontList& medium_font_list = |
402 rb->GetFontList(ui::ResourceBundle::MediumFont); | 473 rb->GetFontList(ui::ResourceBundle::MediumFont); |
474 const gfx::Insets textfield_border_insets = | |
475 views::Textfield().border()->GetInsets(); | |
403 | 476 |
404 if (!is_editing_allowed) { | 477 if (!is_editing_allowed) { |
405 label_ = new views::Label(text); | 478 views::Label* name_label = new views::Label(text); |
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 479 name_label->SetBorder( |
407 label_->SetFontList(medium_font_list); | 480 views::Border::CreateEmptyBorder(textfield_border_insets)); |
408 AddChildView(label_); | 481 name_label->SetFontList(medium_font_list); |
482 if (switches::IsMaterialDesignUserMenu()) | |
483 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
484 AddChildView(name_label); | |
409 return; | 485 return; |
410 } | 486 } |
411 | 487 |
488 profile_name_textfield_ = new views::Textfield(); | |
489 // Textfield that overlaps the button. | |
490 profile_name_textfield_->set_controller(controller); | |
491 profile_name_textfield_->SetFontList(medium_font_list); | |
492 profile_name_textfield_->SetHorizontalAlignment( | |
493 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT | |
494 : gfx::ALIGN_CENTER); | |
495 profile_name_textfield_->SetVisible(false); | |
496 AddChildView(profile_name_textfield_); | |
497 | |
412 button_ = new RightAlignedIconLabelButton(this, text); | 498 button_ = new RightAlignedIconLabelButton(this, text); |
413 button_->SetFontList(medium_font_list); | 499 button_->SetFontList(medium_font_list); |
414 // Show an "edit" pencil icon when hovering over. In the default state, | 500 // 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 | 501 // 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. | 502 // the text doesn't jump around when the hovered icon appears. |
417 // TODO(estade): revisit colors and press effect. | 503 // TODO(estade): revisit colors and press effect. |
418 const int kIconSize = 16; | 504 const int kIconSize = 16; |
419 button_->SetImage(views::LabelButton::STATE_NORMAL, | 505 button_->SetImage(views::LabelButton::STATE_NORMAL, |
420 CreateSquarePlaceholderImage(kIconSize)); | 506 CreateSquarePlaceholderImage(kIconSize)); |
421 button_->SetImage(views::LabelButton::STATE_HOVERED, | 507 button_->SetImage(views::LabelButton::STATE_HOVERED, |
422 gfx::CreateVectorIcon( | 508 gfx::CreateVectorIcon( |
423 gfx::VectorIconId::MODE_EDIT, kIconSize, | 509 gfx::VectorIconId::MODE_EDIT, kIconSize, |
424 SkColorSetRGB(0x33, 0x33, 0x33))); | 510 SkColorSetRGB(0x33, 0x33, 0x33))); |
425 button_->SetImage(views::LabelButton::STATE_PRESSED, | 511 button_->SetImage(views::LabelButton::STATE_PRESSED, |
426 gfx::CreateVectorIcon( | 512 gfx::CreateVectorIcon( |
427 gfx::VectorIconId::MODE_EDIT, kIconSize, | 513 gfx::VectorIconId::MODE_EDIT, kIconSize, |
428 SkColorSetRGB(0x20, 0x20, 0x20))); | 514 SkColorSetRGB(0x20, 0x20, 0x20))); |
429 // To center the text, we need to offest it by the width of the icon we | 515 // 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 | 516 // to the text to account for the textfield's border. |
431 // padding to account for the textfield's border. | 517 if (switches::IsMaterialDesignUserMenu()) { |
432 const int kIconTextLabelButtonSpacing = 5; | 518 button_->SetBorder(views::Border::CreateEmptyBorder( |
433 button_->SetBorder(views::Border::CreateEmptyBorder( | 519 textfield_border_insets + |
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 520 gfx::Insets(0, profile_name_textfield_->GetInsets().left(), 0, 0))); |
521 } else { | |
522 const int kIconTextLabelButtonSpacing = 5; | |
523 button_->SetBorder(views::Border::CreateEmptyBorder( | |
524 textfield_border_insets + | |
525 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); | |
526 } | |
435 AddChildView(button_); | 527 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 } | 528 } |
445 | 529 |
446 views::Textfield* profile_name_textfield() { | 530 views::Textfield* profile_name_textfield() { |
447 return profile_name_textfield_; | 531 return profile_name_textfield_; |
448 } | 532 } |
449 | 533 |
450 // Hide the editable textfield to show the profile name button instead. | 534 // Hide the editable textfield to show the profile name button instead. |
451 void ShowReadOnlyView() { | 535 void ShowReadOnlyView() { |
452 button_->SetVisible(true); | 536 button_->SetVisible(true); |
453 profile_name_textfield_->SetVisible(false); | 537 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 | 555 // 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. | 556 // part of the new profile name typed in the textfield. |
473 return false; | 557 return false; |
474 } | 558 } |
475 | 559 |
476 // The label button which shows the profile name, and can handle the event to | 560 // 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 | 561 // make it editable. Can be NULL if the profile name isn't allowed to be |
478 // edited. | 562 // edited. |
479 RightAlignedIconLabelButton* button_; | 563 RightAlignedIconLabelButton* button_; |
480 | 564 |
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 | 565 // 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). | 566 // the profile name isn't allowed to be edited (e.g. for guest profiles). |
487 views::Textfield* profile_name_textfield_; | 567 views::Textfield* profile_name_textfield_; |
488 | 568 |
489 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | 569 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); |
490 }; | 570 }; |
491 | 571 |
492 // A title card with one back button right aligned and one label center aligned. | 572 // A title card with one back button right aligned and one label center aligned. |
493 class TitleCard : public views::View { | 573 class TitleCard : public views::View { |
494 public: | 574 public: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 } | 637 } |
558 | 638 |
559 views::ImageButton* back_button_; | 639 views::ImageButton* back_button_; |
560 views::Label* title_label_; | 640 views::Label* title_label_; |
561 | 641 |
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 642 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
563 }; | 643 }; |
564 | 644 |
565 // ProfileBadge -------------------------------------------------------- | 645 // ProfileBadge -------------------------------------------------------- |
566 | 646 |
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. | 647 // Draws a white circle, then a light blue circle, then a dark blue icon. |
571 class ProfileBadge : public gfx::CanvasImageSource { | 648 class ProfileBadge : public gfx::CanvasImageSource { |
572 public: | 649 public: |
573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | 650 ProfileBadge(gfx::VectorIconId id, size_t icon_size) |
574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | 651 : CanvasImageSource( |
575 false), | 652 gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()), |
653 false), | |
576 id_(id), | 654 id_(id), |
577 icon_size_(icon_size) {} | 655 icon_size_(icon_size) {} |
578 | 656 |
579 ~ProfileBadge() override {} | 657 ~ProfileBadge() override {} |
580 | 658 |
581 // CanvasImageSource: | 659 // CanvasImageSource: |
582 void Draw(gfx::Canvas* canvas) override { | 660 void Draw(gfx::Canvas* canvas) override { |
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | 661 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); |
584 gfx::Rect bounds(0, 0, size.width(), size.height()); | 662 gfx::Rect bounds(0, 0, size.width(), size.height()); |
585 | 663 |
586 SkPaint paint; | 664 SkPaint paint; |
587 paint.setAntiAlias(true); | 665 paint.setAntiAlias(true); |
588 paint.setColor(SK_ColorWHITE); | 666 paint.setColor(SK_ColorWHITE); |
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | 667 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); |
590 | 668 |
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | 669 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); |
592 canvas->DrawCircle(bounds.CenterPoint(), | 670 canvas->DrawCircle(bounds.CenterPoint(), |
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); | 671 size.width() / 2 - kProfileBadgeWhitePadding, paint); |
594 | 672 |
595 int offset = (kProfileBadgeSize - icon_size_) / 2; | 673 int offset = (GetProfileBadgeSize() - icon_size_) / 2; |
596 canvas->Translate(gfx::Vector2d(offset, offset)); | 674 canvas->Translate(gfx::Vector2d(offset, offset)); |
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | 675 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
598 } | 676 } |
599 | 677 |
600 private: | 678 private: |
601 const gfx::VectorIconId id_; | 679 const gfx::VectorIconId id_; |
602 const size_t icon_size_; | 680 const size_t icon_size_; |
603 | 681 |
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | 682 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); |
605 }; | 683 }; |
606 | 684 |
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | 685 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
608 ProfileBadge* badge = | 686 ProfileBadge* badge = |
609 profile->IsChild() | 687 profile->IsChild() |
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 688 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 689 switches::IsMaterialDesignUserMenu() ? 21 : 26) |
612 | 690 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
691 switches::IsMaterialDesignUserMenu() ? 16 : 20); | |
613 return gfx::ImageSkia(badge, badge->size()); | 692 return gfx::ImageSkia(badge, badge->size()); |
614 } | 693 } |
615 | 694 |
616 // ProfileChooserView --------------------------------------------------------- | 695 // ProfileChooserView --------------------------------------------------------- |
617 | 696 |
618 // static | 697 // static |
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 698 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 699 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
621 | 700 |
622 // static | 701 // static |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 bool ProfileChooserView::IsShowing() { | 736 bool ProfileChooserView::IsShowing() { |
658 return profile_bubble_ != NULL; | 737 return profile_bubble_ != NULL; |
659 } | 738 } |
660 | 739 |
661 // static | 740 // static |
662 void ProfileChooserView::Hide() { | 741 void ProfileChooserView::Hide() { |
663 if (IsShowing()) | 742 if (IsShowing()) |
664 profile_bubble_->GetWidget()->Close(); | 743 profile_bubble_->GetWidget()->Close(); |
665 } | 744 } |
666 | 745 |
746 // static | |
747 int ProfileChooserView::GetFixedMenuWidth() { | |
748 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
749 } | |
750 | |
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 751 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
668 Browser* browser, | 752 Browser* browser, |
669 profiles::BubbleViewMode view_mode, | 753 profiles::BubbleViewMode view_mode, |
670 profiles::TutorialMode tutorial_mode, | 754 profiles::TutorialMode tutorial_mode, |
671 signin::GAIAServiceType service_type, | 755 signin::GAIAServiceType service_type, |
672 signin_metrics::AccessPoint access_point) | 756 signin_metrics::AccessPoint access_point) |
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 757 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
674 browser_(browser), | 758 browser_(browser), |
675 view_mode_(view_mode), | 759 view_mode_(view_mode), |
676 tutorial_mode_(tutorial_mode), | 760 tutorial_mode_(tutorial_mode), |
(...skipping 10 matching lines...) Expand all Loading... | |
687 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 771 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
688 if (oauth2_token_service) | 772 if (oauth2_token_service) |
689 oauth2_token_service->RemoveObserver(this); | 773 oauth2_token_service->RemoveObserver(this); |
690 } | 774 } |
691 | 775 |
692 void ProfileChooserView::ResetView() { | 776 void ProfileChooserView::ResetView() { |
693 open_other_profile_indexes_map_.clear(); | 777 open_other_profile_indexes_map_.clear(); |
694 delete_account_button_map_.clear(); | 778 delete_account_button_map_.clear(); |
695 reauth_account_button_map_.clear(); | 779 reauth_account_button_map_.clear(); |
696 manage_accounts_link_ = NULL; | 780 manage_accounts_link_ = NULL; |
697 signin_current_profile_link_ = NULL; | 781 signin_current_profile_button_ = NULL; |
698 auth_error_email_button_ = NULL; | 782 auth_error_email_button_ = NULL; |
699 current_profile_photo_ = NULL; | 783 current_profile_photo_ = NULL; |
700 current_profile_name_ = NULL; | 784 current_profile_name_ = NULL; |
701 users_button_ = NULL; | 785 users_button_ = NULL; |
702 go_incognito_button_ = NULL; | 786 go_incognito_button_ = NULL; |
703 lock_button_ = NULL; | 787 lock_button_ = NULL; |
704 add_account_link_ = NULL; | 788 add_account_link_ = NULL; |
705 gaia_signin_cancel_button_ = NULL; | 789 gaia_signin_cancel_button_ = NULL; |
706 remove_account_button_ = NULL; | 790 remove_account_button_ = NULL; |
707 account_removal_cancel_button_ = NULL; | 791 account_removal_cancel_button_ = NULL; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 break; | 916 break; |
833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 917 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 918 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
835 sub_view = CreateSwitchUserView(); | 919 sub_view = CreateSwitchUserView(); |
836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 920 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 921 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
838 break; | 922 break; |
839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 923 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 924 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 925 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 926 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
843 sub_view = CreateProfileChooserView(avatar_menu); | 927 sub_view = CreateProfileChooserView(avatar_menu); |
844 break; | 928 break; |
845 } | 929 } |
846 // Clears tutorial mode for all non-profile-chooser views. | 930 // Clears tutorial mode for all non-profile-chooser views. |
847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 931 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 932 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
849 | 933 |
850 layout->StartRow(1, 0); | 934 layout->StartRow(1, 0); |
851 layout->AddView(sub_view); | 935 layout->AddView(sub_view); |
852 Layout(); | 936 Layout(); |
(...skipping 26 matching lines...) Expand all Loading... | |
879 if (accelerator.key_code() != ui::VKEY_DOWN && | 963 if (accelerator.key_code() != ui::VKEY_DOWN && |
880 accelerator.key_code() != ui::VKEY_UP) | 964 accelerator.key_code() != ui::VKEY_UP) |
881 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); | 965 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); |
882 | 966 |
883 // Move the focus up or down. | 967 // Move the focus up or down. |
884 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); | 968 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
885 return true; | 969 return true; |
886 } | 970 } |
887 | 971 |
888 views::View* ProfileChooserView::GetInitiallyFocusedView() { | 972 views::View* ProfileChooserView::GetInitiallyFocusedView() { |
889 return signin_current_profile_link_; | 973 return signin_current_profile_button_; |
890 } | 974 } |
891 | 975 |
892 int ProfileChooserView::GetDialogButtons() const { | 976 int ProfileChooserView::GetDialogButtons() const { |
893 return ui::DIALOG_BUTTON_NONE; | 977 return ui::DIALOG_BUTTON_NONE; |
894 } | 978 } |
895 | 979 |
896 bool ProfileChooserView::HandleContextMenu( | 980 bool ProfileChooserView::HandleContextMenu( |
897 const content::ContextMenuParams& params) { | 981 const content::ContextMenuParams& params) { |
898 // Suppresses the context menu because some features, such as inspecting | 982 // Suppresses the context menu because some features, such as inspecting |
899 // elements, are not appropriate in a bubble. | 983 // 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 = | 1032 bool account_management_available = |
949 SigninManagerFactory::GetForProfile(browser_->profile())-> | 1033 SigninManagerFactory::GetForProfile(browser_->profile())-> |
950 IsAuthenticated() && | 1034 IsAuthenticated() && |
951 switches::IsEnableAccountConsistency(); | 1035 switches::IsEnableAccountConsistency(); |
952 ShowViewFromMode(account_management_available ? | 1036 ShowViewFromMode(account_management_available ? |
953 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 1037 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
954 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 1038 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
955 } else if (sender == current_profile_photo_) { | 1039 } else if (sender == current_profile_photo_) { |
956 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 1040 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
957 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 1041 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
958 } else if (sender == signin_current_profile_link_) { | 1042 } else if (sender == signin_current_profile_button_) { |
959 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 1043 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
960 } else if (sender == add_person_button_) { | 1044 } else if (sender == add_person_button_) { |
961 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1045 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
962 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 1046 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
963 UserManager::Show(base::FilePath(), | 1047 UserManager::Show(base::FilePath(), |
964 profiles::USER_MANAGER_NO_TUTORIAL, | 1048 profiles::USER_MANAGER_NO_TUTORIAL, |
965 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1049 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
966 } else if (sender == disconnect_button_) { | 1050 } else if (sender == disconnect_button_) { |
967 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1051 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
968 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 1052 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 Indexes other_profiles; | 1169 Indexes other_profiles; |
1086 views::View* tutorial_view = NULL; | 1170 views::View* tutorial_view = NULL; |
1087 views::View* current_profile_view = NULL; | 1171 views::View* current_profile_view = NULL; |
1088 views::View* current_profile_accounts = NULL; | 1172 views::View* current_profile_accounts = NULL; |
1089 views::View* option_buttons_view = NULL; | 1173 views::View* option_buttons_view = NULL; |
1090 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1174 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1091 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1175 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1092 if (item.active) { | 1176 if (item.active) { |
1093 option_buttons_view = CreateOptionsView( | 1177 option_buttons_view = CreateOptionsView( |
1094 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1178 item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
1095 current_profile_view = CreateCurrentProfileView(item, false); | 1179 current_profile_view = |
1180 switches::IsMaterialDesignUserMenu() | |
1181 ? CreateMaterialDesignCurrentProfileView(item, false) | |
1182 : CreateCurrentProfileView(item, false); | |
1096 if (IsProfileChooser(view_mode_)) { | 1183 if (IsProfileChooser(view_mode_)) { |
1097 tutorial_view = CreateTutorialViewIfNeeded(item); | 1184 tutorial_view = CreateTutorialViewIfNeeded(item); |
1098 } else { | 1185 } else { |
1099 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1186 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1100 } | 1187 } |
1101 } else { | 1188 } else { |
1102 other_profiles.push_back(i); | 1189 other_profiles.push_back(i); |
1103 } | 1190 } |
1104 } | 1191 } |
1105 | 1192 |
(...skipping 16 matching lines...) Expand all Loading... | |
1122 | 1209 |
1123 if (!IsProfileChooser(view_mode_)) { | 1210 if (!IsProfileChooser(view_mode_)) { |
1124 DCHECK(current_profile_accounts); | 1211 DCHECK(current_profile_accounts); |
1125 layout->StartRow(0, 0); | 1212 layout->StartRow(0, 0); |
1126 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1213 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1127 layout->StartRow(1, 0); | 1214 layout->StartRow(1, 0); |
1128 layout->AddView(current_profile_accounts); | 1215 layout->AddView(current_profile_accounts); |
1129 } | 1216 } |
1130 | 1217 |
1131 if (browser_->profile()->IsSupervised()) { | 1218 if (browser_->profile()->IsSupervised()) { |
1132 layout->StartRow(0, 0); | 1219 if (!switches::IsMaterialDesignUserMenu()) { |
1133 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1220 layout->StartRow(0, 0); |
1221 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
1222 } | |
1134 layout->StartRow(1, 0); | 1223 layout->StartRow(1, 0); |
1135 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1224 layout->AddView(CreateSupervisedUserDisclaimerView()); |
1136 } | 1225 } |
1137 | 1226 |
1138 layout->StartRow(0, 0); | 1227 layout->StartRow(0, 0); |
1139 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1228 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1140 | 1229 |
1141 if (option_buttons_view) { | 1230 if (option_buttons_view) { |
1142 layout->StartRow(0, 0); | 1231 layout->StartRow(0, 0); |
1143 layout->AddView(option_buttons_view); | 1232 layout->AddView(option_buttons_view); |
(...skipping 11 matching lines...) Expand all Loading... | |
1155 } | 1244 } |
1156 } | 1245 } |
1157 | 1246 |
1158 layout->StartRow(1, 0); | 1247 layout->StartRow(1, 0); |
1159 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1248 layout->AddView(CreateOtherProfilesView(other_profiles)); |
1160 } | 1249 } |
1161 | 1250 |
1162 views::View* ProfileChooserView::CreateProfileChooserView( | 1251 views::View* ProfileChooserView::CreateProfileChooserView( |
1163 AvatarMenu* avatar_menu) { | 1252 AvatarMenu* avatar_menu) { |
1164 views::View* view = new views::View(); | 1253 views::View* view = new views::View(); |
1165 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1254 views::GridLayout* layout = |
1255 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1166 | 1256 |
1167 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1257 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
1168 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1258 PopulateMinimalProfileChooserView(layout, avatar_menu); |
1169 // The user is using right-click switching, no need to tell them about it. | 1259 // The user is using right-click switching, no need to tell them about it. |
1170 PrefService* local_state = g_browser_process->local_state(); | 1260 PrefService* local_state = g_browser_process->local_state(); |
1171 local_state->SetBoolean( | 1261 local_state->SetBoolean( |
1172 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1262 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1173 } else { | 1263 } else { |
1174 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1264 PopulateCompleteProfileChooserView(layout, avatar_menu); |
1175 } | 1265 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1230 const base::string16& button_text, | 1320 const base::string16& button_text, |
1231 bool stack_button, | 1321 bool stack_button, |
1232 views::Link** link, | 1322 views::Link** link, |
1233 views::LabelButton** button, | 1323 views::LabelButton** button, |
1234 views::ImageButton** close_button) { | 1324 views::ImageButton** close_button) { |
1235 tutorial_mode_ = tutorial_mode; | 1325 tutorial_mode_ = tutorial_mode; |
1236 | 1326 |
1237 views::View* view = new views::View(); | 1327 views::View* view = new views::View(); |
1238 view->set_background(views::Background::CreateSolidBackground( | 1328 view->set_background(views::Background::CreateSolidBackground( |
1239 profiles::kAvatarTutorialBackgroundColor)); | 1329 profiles::kAvatarTutorialBackgroundColor)); |
1240 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1330 views::GridLayout* layout = CreateSingleColumnLayout( |
1241 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1331 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1242 // Creates a second column set for buttons and links. | 1332 // Creates a second column set for buttons and links. |
1243 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1333 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
1244 button_columns->AddColumn(views::GridLayout::LEADING, | 1334 button_columns->AddColumn(views::GridLayout::LEADING, |
1245 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1335 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1246 button_columns->AddPaddingColumn( | 1336 button_columns->AddPaddingColumn( |
1247 1, views::kUnrelatedControlHorizontalSpacing); | 1337 1, views::kUnrelatedControlHorizontalSpacing); |
1248 button_columns->AddColumn(views::GridLayout::TRAILING, | 1338 button_columns->AddColumn(views::GridLayout::TRAILING, |
1249 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1339 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1250 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1340 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1251 views::kButtonHEdgeMarginNew, | 1341 views::kButtonHEdgeMarginNew, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1333 layout->SkipColumns(1); | 1423 layout->SkipColumns(1); |
1334 } | 1424 } |
1335 | 1425 |
1336 return view; | 1426 return view; |
1337 } | 1427 } |
1338 | 1428 |
1339 views::View* ProfileChooserView::CreateCurrentProfileView( | 1429 views::View* ProfileChooserView::CreateCurrentProfileView( |
1340 const AvatarMenu::Item& avatar_item, | 1430 const AvatarMenu::Item& avatar_item, |
1341 bool is_guest) { | 1431 bool is_guest) { |
1342 views::View* view = new views::View(); | 1432 views::View* view = new views::View(); |
1343 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1433 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
1344 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1434 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
1345 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1435 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1346 views::kButtonHEdgeMarginNew, | 1436 views::kButtonHEdgeMarginNew, |
1347 views::kUnrelatedControlVerticalSpacing, | 1437 views::kUnrelatedControlVerticalSpacing, |
1348 views::kButtonHEdgeMarginNew); | 1438 views::kButtonHEdgeMarginNew); |
1349 | 1439 |
1350 // Profile icon, centered. | 1440 // Profile icon, centered. |
1351 int x_offset = (column_width - kLargeImageSide) / 2; | 1441 int x_offset = (column_width - kLargeImageSide) / 2; |
1352 current_profile_photo_ = new EditableProfilePhoto( | 1442 current_profile_photo_ = new EditableProfilePhoto( |
1353 this, avatar_item.icon, !is_guest, | 1443 this, avatar_item.icon, !is_guest, browser_->profile()); |
1354 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); | 1444 current_profile_photo_->SetX(x_offset); |
1355 SizedContainer* profile_icon_container = | 1445 SizedContainer* profile_icon_container = |
1356 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | 1446 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
1357 profile_icon_container->AddChildView(current_profile_photo_); | 1447 profile_icon_container->AddChildView(current_profile_photo_); |
1358 | 1448 |
1359 if (browser_->profile()->IsSupervised()) { | 1449 if (browser_->profile()->IsSupervised()) { |
1360 views::ImageView* supervised_icon = new views::ImageView(); | 1450 views::ImageView* supervised_icon = new views::ImageView(); |
1361 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); | 1451 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); |
1362 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | 1452 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); |
1363 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | 1453 gfx::Rect parent_bounds = current_profile_photo_->bounds(); |
1364 supervised_icon->SetBounds( | 1454 supervised_icon->SetBounds( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 if (signin_manager->IsSigninAllowed()) { | 1521 if (signin_manager->IsSigninAllowed()) { |
1432 views::Label* promo = new views::Label( | 1522 views::Label* promo = new views::Label( |
1433 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | 1523 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
1434 promo->SetMultiLine(true); | 1524 promo->SetMultiLine(true); |
1435 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1525 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1436 layout->StartRowWithPadding(1, 0, 0, | 1526 layout->StartRowWithPadding(1, 0, 0, |
1437 views::kRelatedControlSmallVerticalSpacing); | 1527 views::kRelatedControlSmallVerticalSpacing); |
1438 layout->StartRow(1, 0); | 1528 layout->StartRow(1, 0); |
1439 layout->AddView(promo); | 1529 layout->AddView(promo); |
1440 | 1530 |
1441 signin_current_profile_link_ = new views::BlueButton( | 1531 signin_current_profile_button_ = new views::BlueButton( |
1442 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 1532 this, l10n_util::GetStringFUTF16( |
1443 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 1533 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
1534 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1444 layout->StartRowWithPadding(1, 0, 0, | 1535 layout->StartRowWithPadding(1, 0, 0, |
1445 views::kRelatedControlVerticalSpacing); | 1536 views::kRelatedControlVerticalSpacing); |
1446 layout->StartRow(1, 0); | 1537 layout->StartRow(1, 0); |
1447 layout->AddView(signin_current_profile_link_); | 1538 layout->AddView(signin_current_profile_button_); |
1448 content::RecordAction( | 1539 content::RecordAction( |
1449 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1540 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
1450 } | 1541 } |
1451 } | 1542 } |
1452 | 1543 |
1453 return view; | 1544 return view; |
1454 } | 1545 } |
1455 | 1546 |
1547 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
1548 const AvatarMenu::Item& avatar_item, | |
1549 bool is_guest) { | |
1550 views::View* view = new views::View(); | |
1551 view->SetLayoutManager( | |
1552 new views::BoxLayout(views::BoxLayout::kVertical, kMaterialMenuEdgeMargin, | |
1553 views::kRelatedControlVerticalSpacing, | |
1554 views::kRelatedControlVerticalSpacing)); | |
1555 | |
1556 // Profile container for the profile photo and avatar/user name. | |
1557 views::View* profile_container = new views::View(); | |
1558 | |
1559 // Profile picture, left-aligned. | |
1560 current_profile_photo_ = new EditableProfilePhoto( | |
1561 this, avatar_item.icon, !is_guest, browser_->profile()); | |
1562 | |
1563 // Profile name, left-aligned to the right of profile icon. | |
1564 bool editing_allowed = | |
1565 !is_guest && !browser_->profile()->IsLegacySupervised(); | |
1566 current_profile_name_ = new EditableProfileName( | |
1567 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
1568 editing_allowed); | |
1569 views::View* profile_name_container = new views::View(); | |
1570 int name_container_v_spacing = views::kRelatedControlSmallVerticalSpacing; | |
1571 if (!avatar_item.signed_in) | |
1572 name_container_v_spacing += views::kRelatedControlVerticalSpacing; | |
1573 profile_name_container->SetLayoutManager(new views::BoxLayout( | |
1574 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0)); | |
1575 profile_name_container->AddChildView(current_profile_name_); | |
1576 | |
1577 const int between_child_spacing = | |
1578 kMaterialMenuEdgeMargin - current_profile_photo_->badge_spacing; | |
1579 profile_container->SetLayoutManager(new views::BoxLayout( | |
1580 views::BoxLayout::kHorizontal, 0, | |
1581 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); | |
1582 profile_container->AddChildView(current_profile_photo_); | |
1583 profile_container->AddChildView(profile_name_container); | |
1584 view->AddChildView(profile_container); | |
1585 | |
1586 if (is_guest) | |
1587 return view; | |
1588 | |
1589 // The available links depend on the type of profile that is active. | |
1590 if (avatar_item.signed_in) { | |
1591 if (switches::IsEnableAccountConsistency()) { | |
1592 base::string16 link_title = l10n_util::GetStringUTF16( | |
1593 IsProfileChooser(view_mode_) | |
1594 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON | |
1595 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
1596 manage_accounts_link_ = CreateLink(link_title, this); | |
1597 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1598 profile_name_container->AddChildView(manage_accounts_link_); | |
1599 } else { | |
1600 views::Label* email_label = new views::Label(avatar_item.username); | |
1601 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1602 email_label->SetEnabled(false); | |
1603 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1604 profile_name_container->AddChildView(email_label); | |
1605 } | |
1606 return view; | |
1607 } | |
1608 | |
1609 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
1610 browser_->profile()->GetOriginalProfile()); | |
1611 if (signin_manager->IsSigninAllowed()) { | |
1612 views::Label* promo = | |
1613 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
1614 promo->SetMultiLine(true); | |
1615 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1616 view->AddChildView(promo); | |
1617 | |
1618 signin_current_profile_button_ = | |
1619 views::MdTextButton::CreateSecondaryUiBlueButton( | |
1620 this, l10n_util::GetStringFUTF16( | |
1621 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
1622 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1623 view->AddChildView(signin_current_profile_button_); | |
1624 content::RecordAction( | |
1625 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
1626 view->SetBorder(views::Border::CreateEmptyBorder( | |
1627 0, 0, views::kRelatedControlVerticalSpacing, 0)); | |
1628 } | |
1629 | |
1630 return view; | |
1631 } | |
1632 | |
1456 views::View* ProfileChooserView::CreateGuestProfileView() { | 1633 views::View* ProfileChooserView::CreateGuestProfileView() { |
1457 gfx::Image guest_icon = | 1634 gfx::Image guest_icon = |
1458 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1635 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
1459 profiles::GetPlaceholderAvatarIconResourceID()); | 1636 profiles::GetPlaceholderAvatarIconResourceID()); |
1460 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1637 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
1461 guest_avatar_item.active = true; | 1638 guest_avatar_item.active = true; |
1462 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1639 guest_avatar_item.name = l10n_util::GetStringUTF16( |
1463 IDS_PROFILES_GUEST_PROFILE_NAME); | 1640 IDS_PROFILES_GUEST_PROFILE_NAME); |
1464 guest_avatar_item.signed_in = false; | 1641 guest_avatar_item.signed_in = false; |
1465 | 1642 |
1466 return CreateCurrentProfileView(guest_avatar_item, true); | 1643 return switches::IsMaterialDesignUserMenu() |
1644 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
1645 : CreateCurrentProfileView(guest_avatar_item, true); | |
1467 } | 1646 } |
1468 | 1647 |
1469 views::View* ProfileChooserView::CreateOtherProfilesView( | 1648 views::View* ProfileChooserView::CreateOtherProfilesView( |
1470 const Indexes& avatars_to_show) { | 1649 const Indexes& avatars_to_show) { |
1471 views::View* view = new views::View(); | 1650 views::View* view = new views::View(); |
1472 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1651 views::GridLayout* layout = |
1652 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1473 | 1653 |
1474 for (size_t index : avatars_to_show) { | 1654 for (size_t index : avatars_to_show) { |
1475 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1655 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
1476 const int kSmallImageSide = 32; | 1656 const int kSmallImageSide = 32; |
1477 | 1657 |
1478 // Use the low-res, small default avatars in the fast user switcher, like | 1658 // Use the low-res, small default avatars in the fast user switcher, like |
1479 // we do in the menu bar. | 1659 // we do in the menu bar. |
1480 gfx::Image item_icon; | 1660 gfx::Image item_icon; |
1481 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1661 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
1482 | 1662 |
(...skipping 10 matching lines...) Expand all Loading... | |
1493 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1673 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1494 layout->StartRow(1, 0); | 1674 layout->StartRow(1, 0); |
1495 layout->AddView(button); | 1675 layout->AddView(button); |
1496 } | 1676 } |
1497 | 1677 |
1498 return view; | 1678 return view; |
1499 } | 1679 } |
1500 | 1680 |
1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1681 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
1502 views::View* view = new views::View(); | 1682 views::View* view = new views::View(); |
1503 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1683 views::GridLayout* layout = |
1684 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1504 | 1685 |
1505 base::string16 text = browser_->profile()->IsGuestSession() ? | 1686 base::string16 text = browser_->profile()->IsGuestSession() ? |
1506 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1687 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1507 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1688 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
1508 if (!browser_->profile()->IsGuestSession() | 1689 if (!browser_->profile()->IsGuestSession() |
1509 && switches::IsMaterialDesignUserMenu()) { | 1690 && switches::IsMaterialDesignUserMenu()) { |
1510 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1691 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
1511 } | 1692 } |
1512 const int kIconSize = 16; | 1693 const int kIconSize = 16; |
1513 | 1694 |
(...skipping 29 matching lines...) Expand all Loading... | |
1543 gfx::kChromeIconGrey)); | 1724 gfx::kChromeIconGrey)); |
1544 layout->StartRow(1, 0); | 1725 layout->StartRow(1, 0); |
1545 layout->AddView(lock_button_); | 1726 layout->AddView(lock_button_); |
1546 } | 1727 } |
1547 return view; | 1728 return view; |
1548 } | 1729 } |
1549 | 1730 |
1550 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1731 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1551 views::View* view = new views::View(); | 1732 views::View* view = new views::View(); |
1552 views::GridLayout* layout = CreateSingleColumnLayout( | 1733 views::GridLayout* layout = CreateSingleColumnLayout( |
1553 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1734 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1554 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1735 if (switches::IsMaterialDesignUserMenu()) { |
1555 views::kButtonHEdgeMarginNew, | 1736 layout->SetInsets(0, kMaterialMenuEdgeMargin, kMaterialMenuEdgeMargin, |
1556 views::kRelatedControlVerticalSpacing, | 1737 kMaterialMenuEdgeMargin); |
1557 views::kButtonHEdgeMarginNew); | 1738 } else { |
1739 layout->SetInsets( | |
1740 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, | |
1741 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); | |
1742 } | |
1743 | |
1558 views::Label* disclaimer = new views::Label( | 1744 views::Label* disclaimer = new views::Label( |
1559 avatar_menu_->GetSupervisedUserInformation()); | 1745 avatar_menu_->GetSupervisedUserInformation()); |
1560 disclaimer->SetMultiLine(true); | 1746 disclaimer->SetMultiLine(true); |
1561 disclaimer->SetAllowCharacterBreak(true); | 1747 disclaimer->SetAllowCharacterBreak(true); |
1562 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1748 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1563 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1749 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1564 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1750 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
1565 layout->StartRow(1, 0); | 1751 layout->StartRow(1, 0); |
1566 layout->AddView(disclaimer); | 1752 layout->AddView(disclaimer); |
1567 | 1753 |
1568 return view; | 1754 return view; |
1569 } | 1755 } |
1570 | 1756 |
1571 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1757 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
1572 const AvatarMenu::Item& avatar_item) { | 1758 const AvatarMenu::Item& avatar_item) { |
1573 DCHECK(avatar_item.signed_in); | 1759 DCHECK(avatar_item.signed_in); |
1574 views::View* view = new views::View(); | 1760 views::View* view = new views::View(); |
1575 view->set_background(views::Background::CreateSolidBackground( | 1761 view->set_background(views::Background::CreateSolidBackground( |
1576 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1762 profiles::kAvatarBubbleAccountsBackgroundColor)); |
1577 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1763 views::GridLayout* layout = |
1764 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1578 | 1765 |
1579 Profile* profile = browser_->profile(); | 1766 Profile* profile = browser_->profile(); |
1580 std::string primary_account = | 1767 std::string primary_account = |
1581 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1768 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
1582 DCHECK(!primary_account.empty()); | 1769 DCHECK(!primary_account.empty()); |
1583 std::vector<std::string>accounts = | 1770 std::vector<std::string>accounts = |
1584 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1771 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
1585 | 1772 |
1586 // Get state of authentication error, if any. | 1773 // Get state of authentication error, if any. |
1587 std::string error_account_id = GetAuthErrorAccountId(profile); | 1774 std::string error_account_id = GetAuthErrorAccountId(profile); |
1588 | 1775 |
1589 // The primary account should always be listed first. | 1776 // The primary account should always be listed first. |
1590 // TODO(rogerta): we still need to further differentiate the primary account | 1777 // 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: | 1778 // from the others in the UI, so more work is likely required here: |
1592 // crbug.com/311124. | 1779 // crbug.com/311124. |
1593 CreateAccountButton(layout, primary_account, true, | 1780 CreateAccountButton(layout, primary_account, true, |
1594 error_account_id == primary_account, kFixedMenuWidth); | 1781 error_account_id == primary_account, GetFixedMenuWidth()); |
1595 for (size_t i = 0; i < accounts.size(); ++i) | 1782 for (size_t i = 0; i < accounts.size(); ++i) |
1596 CreateAccountButton(layout, accounts[i], false, | 1783 CreateAccountButton(layout, accounts[i], false, |
1597 error_account_id == accounts[i], kFixedMenuWidth); | 1784 error_account_id == accounts[i], GetFixedMenuWidth()); |
1598 | 1785 |
1599 if (!profile->IsSupervised()) { | 1786 if (!profile->IsSupervised()) { |
1600 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1787 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1601 | 1788 |
1602 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1789 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
1603 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1790 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
1604 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1791 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
1605 0, views::kButtonVEdgeMarginNew, | 1792 0, views::kButtonVEdgeMarginNew, |
1606 views::kRelatedControlVerticalSpacing, 0)); | 1793 views::kRelatedControlVerticalSpacing, 0)); |
1607 layout->StartRow(1, 0); | 1794 layout->StartRow(1, 0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1897 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2084 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1898 IncognitoModePrefs::DISABLED; | 2085 IncognitoModePrefs::DISABLED; |
1899 return incognito_available && !browser_->profile()->IsGuestSession(); | 2086 return incognito_available && !browser_->profile()->IsGuestSession(); |
1900 } | 2087 } |
1901 | 2088 |
1902 void ProfileChooserView::PostActionPerformed( | 2089 void ProfileChooserView::PostActionPerformed( |
1903 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2090 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1904 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2091 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1905 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2092 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1906 } | 2093 } |
OLD | NEW |