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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "components/signin/core/browser/signin_manager.h" | 43 #include "components/signin/core/browser/signin_manager.h" |
44 #include "components/signin/core/common/profile_management_switches.h" | 44 #include "components/signin/core/common/profile_management_switches.h" |
45 #include "content/public/browser/render_widget_host_view.h" | 45 #include "content/public/browser/render_widget_host_view.h" |
46 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
47 #include "grit/theme_resources.h" | 47 #include "grit/theme_resources.h" |
48 #include "third_party/skia/include/core/SkColor.h" | 48 #include "third_party/skia/include/core/SkColor.h" |
49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
50 #include "ui/base/material_design/material_design_controller.h" | 50 #include "ui/base/material_design/material_design_controller.h" |
51 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
52 #include "ui/compositor/clip_recorder.h" | 52 #include "ui/compositor/clip_recorder.h" |
53 #include "ui/compositor/paint_recorder.h" | |
53 #include "ui/gfx/canvas.h" | 54 #include "ui/gfx/canvas.h" |
54 #include "ui/gfx/color_palette.h" | 55 #include "ui/gfx/color_palette.h" |
55 #include "ui/gfx/image/canvas_image_source.h" | 56 #include "ui/gfx/image/canvas_image_source.h" |
56 #include "ui/gfx/image/image.h" | 57 #include "ui/gfx/image/image.h" |
57 #include "ui/gfx/image/image_skia.h" | 58 #include "ui/gfx/image/image_skia.h" |
58 #include "ui/gfx/paint_vector_icon.h" | 59 #include "ui/gfx/paint_vector_icon.h" |
59 #include "ui/gfx/path.h" | 60 #include "ui/gfx/path.h" |
60 #include "ui/gfx/skia_util.h" | 61 #include "ui/gfx/skia_util.h" |
61 #include "ui/gfx/text_elider.h" | 62 #include "ui/gfx/text_elider.h" |
62 #include "ui/gfx/vector_icons_public.h" | 63 #include "ui/gfx/vector_icons_public.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
77 #include "ui/views/layout/box_layout.h" | 78 #include "ui/views/layout/box_layout.h" |
78 #include "ui/views/layout/fill_layout.h" | 79 #include "ui/views/layout/fill_layout.h" |
79 #include "ui/views/layout/grid_layout.h" | 80 #include "ui/views/layout/grid_layout.h" |
80 #include "ui/views/layout/layout_constants.h" | 81 #include "ui/views/layout/layout_constants.h" |
81 #include "ui/views/widget/widget.h" | 82 #include "ui/views/widget/widget.h" |
82 | 83 |
83 namespace { | 84 namespace { |
84 | 85 |
85 // Helpers -------------------------------------------------------------------- | 86 // Helpers -------------------------------------------------------------------- |
86 | 87 |
87 const int kFixedMenuWidth = 250; | |
88 const int kButtonHeight = 32; | 88 const int kButtonHeight = 32; |
89 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 89 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
90 const int kFixedGaiaViewWidth = 448; | 90 const int kFixedGaiaViewWidth = 448; |
91 const int kFixedAccountRemovalViewWidth = 280; | 91 const int kFixedAccountRemovalViewWidth = 280; |
92 const int kFixedSwitchUserViewWidth = 320; | 92 const int kFixedSwitchUserViewWidth = 320; |
93 const int kLargeImageSide = 88; | 93 const int kLargeImageSide = 88; |
94 const int kMdImageSide = 40; | |
95 | |
96 // Spacing between the edge of the material design user menu and the | |
97 // top/bottom or left/right of the menu items. | |
98 const int kMaterialMenuEdgeMargin = 16; | |
94 | 99 |
95 const int kVerticalSpacing = 16; | 100 const int kVerticalSpacing = 16; |
96 | 101 |
97 const int kTitleViewNativeWidgetOffset = 8; | 102 const int kTitleViewNativeWidgetOffset = 8; |
98 | 103 |
99 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 104 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
100 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 105 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
101 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 106 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
102 } | 107 } |
103 | 108 |
109 int GetProfileBadgeSize() { | |
110 return switches::IsMaterialDesignUserMenu() ? 24 : 30; | |
111 } | |
112 | |
113 // DEPRECATED: New user menu components should use views::BoxLayout instead. | |
104 // Creates a GridLayout with a single column. This ensures that all the child | 114 // Creates a GridLayout with a single column. This ensures that all the child |
105 // views added get auto-expanded to fill the full width of the bubble. | 115 // views added get auto-expanded to fill the full width of the bubble. |
106 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 116 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
107 views::GridLayout* layout = new views::GridLayout(view); | 117 views::GridLayout* layout = new views::GridLayout(view); |
108 view->SetLayoutManager(layout); | 118 view->SetLayoutManager(layout); |
109 | 119 |
110 views::ColumnSet* columns = layout->AddColumnSet(0); | 120 views::ColumnSet* columns = layout->AddColumnSet(0); |
111 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 121 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
112 views::GridLayout::FIXED, width, width); | 122 views::GridLayout::FIXED, width, width); |
113 return layout; | 123 return layout; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 gfx::Rect bounds(title_view_->GetPreferredSize()); | 267 gfx::Rect bounds(title_view_->GetPreferredSize()); |
258 title_view_->SetBoundsRect(bounds); | 268 title_view_->SetBoundsRect(bounds); |
259 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 269 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
260 title_widget_->SetBounds(bounds); | 270 title_widget_->SetBounds(bounds); |
261 } | 271 } |
262 | 272 |
263 } // namespace | 273 } // namespace |
264 | 274 |
265 // RightAlignedIconLabelButton ------------------------------------------------- | 275 // RightAlignedIconLabelButton ------------------------------------------------- |
266 | 276 |
267 // A custom LabelButton that has a centered text and right aligned icon. | 277 // A custom LabelButton that has a left-aligned text and right aligned icon. |
278 // For non-material-design user menu, it has centered text instead. | |
268 class RightAlignedIconLabelButton : public views::LabelButton { | 279 class RightAlignedIconLabelButton : public views::LabelButton { |
269 public: | 280 public: |
270 RightAlignedIconLabelButton(views::ButtonListener* listener, | 281 RightAlignedIconLabelButton(views::ButtonListener* listener, |
271 const base::string16& text) | 282 const base::string16& text) |
272 : views::LabelButton(listener, text) { | 283 : views::LabelButton(listener, text) { |
273 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 284 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
274 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 285 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
286 ? gfx::ALIGN_LEFT | |
287 : gfx::ALIGN_CENTER); | |
275 } | 288 } |
276 | 289 |
277 protected: | 290 protected: |
278 void Layout() override { | 291 void Layout() override { |
279 views::LabelButton::Layout(); | 292 views::LabelButton::Layout(); |
280 | 293 |
281 // Keep the text centered and the icon right-aligned by stretching the label | 294 // Keep the text centered and the icon right-aligned by stretching the label |
282 // to take up more of the content area and centering its contents. | 295 // to take up more of the content area and centering its contents. |
283 gfx::Rect content_bounds = GetContentsBounds(); | 296 gfx::Rect content_bounds = GetContentsBounds(); |
284 gfx::Rect label_bounds = label()->bounds(); | 297 gfx::Rect label_bounds = label()->bounds(); |
285 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); | 298 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); |
286 label()->SetBoundsRect(label_bounds); | 299 label()->SetBoundsRect(label_bounds); |
287 } | 300 } |
288 | 301 |
289 private: | 302 private: |
290 void OnFocus() override { | 303 void OnFocus() override { |
291 SetState(STATE_HOVERED); | 304 SetState(STATE_HOVERED); |
292 } | 305 } |
293 | 306 |
294 void OnBlur() override { | 307 void OnBlur() override { |
295 SetState(STATE_NORMAL); | 308 SetState(STATE_NORMAL); |
296 } | 309 } |
297 | 310 |
298 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | 311 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
299 }; | 312 }; |
300 | 313 |
301 // EditableProfilePhoto ------------------------------------------------- | 314 // EditableProfilePhoto ------------------------------------------------- |
302 | 315 |
316 const size_t kProfileBadgeWhitePadding = 2; | |
317 | |
303 // A custom Image control that shows a "change" button when moused over. | 318 // A custom Image control that shows a "change" button when moused over. |
304 class EditableProfilePhoto : public views::LabelButton { | 319 class EditableProfilePhoto : public views::LabelButton { |
305 public: | 320 public: |
306 EditableProfilePhoto(views::ButtonListener* listener, | 321 EditableProfilePhoto(views::ButtonListener* listener, |
307 const gfx::Image& icon, | 322 const gfx::Image& icon, |
308 bool is_editing_allowed, | 323 bool is_editing_allowed, |
309 const gfx::Rect& bounds) | 324 Profile* profile) |
310 : views::LabelButton(listener, base::string16()), | 325 : views::LabelButton(listener, base::string16()), |
311 photo_overlay_(NULL) { | 326 photo_overlay_(nullptr), |
312 gfx::Image image = profiles::GetSizedAvatarIcon( | 327 profile_(profile) { |
313 icon, true, kLargeImageSide, kLargeImageSide); | 328 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side, |
329 icon_image_side); | |
314 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 330 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
315 SetBorder(views::Border::NullBorder()); | 331 SetBorder(views::Border::NullBorder()); |
316 SetBoundsRect(bounds); | 332 if (switches::IsMaterialDesignUserMenu()) { |
333 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing, | |
334 GetPreferredSize().height() + badge_spacing + | |
335 views::kRelatedControlSmallVerticalSpacing)); | |
336 } else { | |
337 SetSize(GetPreferredSize()); | |
338 } | |
317 | 339 |
318 // 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. |
319 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 341 circular_mask_.addCircle(SkIntToScalar(icon_image_side / 2), |
320 SkIntToScalar(bounds.height() / 2), | 342 SkIntToScalar(icon_image_side / 2) + badge_spacing, |
321 SkIntToScalar(bounds.width() / 2)); | 343 SkIntToScalar(icon_image_side / 2)); |
322 | 344 |
323 if (!is_editing_allowed) { | 345 if (!is_editing_allowed) { |
324 SetEnabled(false); | 346 SetEnabled(false); |
325 return; | 347 return; |
326 } | 348 } |
327 | 349 |
328 set_notify_enter_exit_on_child(true); | 350 set_notify_enter_exit_on_child(true); |
329 | 351 |
330 // Photo overlay that appears when hovering over the button. | 352 // Photo overlay that appears when hovering over the button. |
331 photo_overlay_ = new views::ImageView(); | 353 photo_overlay_ = new views::ImageView(); |
332 | 354 |
333 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 355 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
334 photo_overlay_->set_background( | 356 photo_overlay_->set_background( |
335 views::Background::CreateSolidBackground(kBackgroundColor)); | 357 views::Background::CreateSolidBackground(kBackgroundColor)); |
336 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 358 photo_overlay_->SetImage( |
337 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))); | |
338 | 362 |
339 photo_overlay_->SetSize(bounds.size()); | 363 photo_overlay_->SetSize(gfx::Size(icon_image_side, icon_image_side)); |
364 photo_overlay_->SetY(badge_spacing); | |
340 photo_overlay_->SetVisible(false); | 365 photo_overlay_->SetVisible(false); |
341 AddChildView(photo_overlay_); | 366 AddChildView(photo_overlay_); |
342 } | 367 } |
343 | 368 |
344 void OnPaint(gfx::Canvas* canvas) override { | 369 void OnPaint(gfx::Canvas* canvas) override { |
370 canvas->Save(); | |
345 // Display the profile picture as a circle. | 371 // Display the profile picture as a circle. |
346 canvas->ClipPath(circular_mask_, true); | 372 canvas->ClipPath(circular_mask_, true); |
347 views::LabelButton::OnPaint(canvas); | 373 views::LabelButton::OnPaint(canvas); |
374 canvas->Restore(); | |
348 } | 375 } |
349 | 376 |
350 void PaintChildren(const ui::PaintContext& context) override { | 377 void PaintChildren(const ui::PaintContext& context) override { |
351 // Display any children (the "change photo" overlay) as a circle. | 378 // Display any children (the "change photo" overlay) as a circle. |
352 ui::ClipRecorder clip_recorder(context); | 379 { |
353 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); | 380 ui::ClipRecorder clip_recorder(context); |
354 View::PaintChildren(context); | 381 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); |
382 View::PaintChildren(context); | |
383 } | |
384 | |
385 ui::PaintRecorder paint_recorder( | |
386 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); | |
387 gfx::Canvas* canvas = paint_recorder.canvas(); | |
388 if (profile_->IsSupervised()) { | |
389 gfx::VectorIconId icon_id; | |
390 size_t icon_size; | |
391 // TODO(janeliulwq): Replace the following two icons when new versions of | |
392 // them are ready, which be inverted as silhouettes. | |
Evan Stade
2016/06/30 13:32:38
can you elaborate a little on this TODO? Some indi
Jane
2016/06/30 14:06:30
Done.
| |
393 if (profile_->IsChild()) { | |
394 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT; | |
395 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26; | |
396 } else { | |
397 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
398 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20; | |
399 } | |
400 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | |
401 | |
402 int badge_offset = | |
403 icon_image_side + badge_spacing - GetProfileBadgeSize(); | |
404 gfx::Vector2d badge_offset_vector = gfx::Vector2d( | |
405 badge_offset, | |
406 badge_offset + (switches::IsMaterialDesignUserMenu() | |
407 ? views::kRelatedControlSmallVerticalSpacing | |
408 : 0)); | |
409 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | |
410 | |
411 SkPaint paint; | |
412 paint.setAntiAlias(true); | |
413 paint.setColor(SK_ColorWHITE); | |
Evan Stade
2016/06/30 13:32:38
I liked the idea you had of using the theme's bubb
Jane
2016/06/30 14:06:30
Done.
| |
414 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); | |
415 | |
416 if (!switches::IsMaterialDesignUserMenu()) { | |
417 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); | |
418 canvas->DrawCircle( | |
419 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | |
420 paint); | |
421 } | |
422 | |
423 int offset = (GetProfileBadgeSize() - icon_size) / 2; | |
424 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); | |
425 const SkColor badge_color = switches::IsMaterialDesignUserMenu() | |
426 ? gfx::kChromeIconGrey | |
427 : SkColorSetRGB(0, 0x66, 0xff); | |
428 gfx::PaintVectorIcon(canvas, icon_id, icon_size, badge_color); | |
429 } | |
355 } | 430 } |
356 | 431 |
432 int icon_image_side = | |
433 switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide; | |
434 int badge_spacing = switches::IsMaterialDesignUserMenu() ? 4 : 0; | |
Evan Stade
2016/06/30 13:32:38
these both need to be static functions rather than
Jane
2016/06/30 14:06:29
Done.
| |
435 | |
357 private: | 436 private: |
358 // views::CustomButton: | 437 // views::CustomButton: |
359 void StateChanged() override { | 438 void StateChanged() override { |
360 bool show_overlay = | 439 bool show_overlay = |
361 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); | 440 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); |
362 if (photo_overlay_) | 441 if (photo_overlay_) |
363 photo_overlay_->SetVisible(show_overlay); | 442 photo_overlay_->SetVisible(show_overlay); |
364 } | 443 } |
365 | 444 |
366 void OnFocus() override { | 445 void OnFocus() override { |
367 views::LabelButton::OnFocus(); | 446 views::LabelButton::OnFocus(); |
368 if (photo_overlay_) | 447 if (photo_overlay_) |
369 photo_overlay_->SetVisible(true); | 448 photo_overlay_->SetVisible(true); |
370 } | 449 } |
371 | 450 |
372 void OnBlur() override { | 451 void OnBlur() override { |
373 views::LabelButton::OnBlur(); | 452 views::LabelButton::OnBlur(); |
374 // Don't hide the overlay if it's being shown as a result of a mouseover. | 453 // Don't hide the overlay if it's being shown as a result of a mouseover. |
375 if (photo_overlay_ && state() != STATE_HOVERED) | 454 if (photo_overlay_ && state() != STATE_HOVERED) |
376 photo_overlay_->SetVisible(false); | 455 photo_overlay_->SetVisible(false); |
377 } | 456 } |
378 | 457 |
379 gfx::Path circular_mask_; | 458 gfx::Path circular_mask_; |
380 | 459 |
381 // Image that is shown when hovering over the image button. Can be NULL if | 460 // Image that is shown when hovering over the image button. Can be NULL if |
382 // the photo isn't allowed to be edited (e.g. for guest profiles). | 461 // the photo isn't allowed to be edited (e.g. for guest profiles). |
383 views::ImageView* photo_overlay_; | 462 views::ImageView* photo_overlay_; |
384 | 463 |
464 Profile* profile_; | |
465 | |
385 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 466 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
386 }; | 467 }; |
387 | 468 |
388 // EditableProfileName ------------------------------------------------- | 469 // EditableProfileName ------------------------------------------------- |
389 | 470 |
390 // A custom text control that turns into a textfield for editing when clicked. | 471 // A custom text control that turns into a textfield for editing when clicked. |
391 class EditableProfileName : public views::View, | 472 class EditableProfileName : public views::View, |
392 public views::ButtonListener { | 473 public views::ButtonListener { |
393 public: | 474 public: |
394 EditableProfileName(views::TextfieldController* controller, | 475 EditableProfileName(views::TextfieldController* controller, |
395 const base::string16& text, | 476 const base::string16& text, |
396 bool is_editing_allowed) | 477 bool is_editing_allowed) |
397 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { | 478 : button_(nullptr), profile_name_textfield_(nullptr) { |
398 SetLayoutManager( | 479 SetLayoutManager( |
399 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 480 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
400 | 481 |
401 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 482 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
402 const gfx::FontList& medium_font_list = | 483 const gfx::FontList& medium_font_list = |
403 rb->GetFontList(ui::ResourceBundle::MediumFont); | 484 rb->GetFontList(ui::ResourceBundle::MediumFont); |
485 const gfx::Insets textfield_border_insets = | |
486 views::Textfield().border()->GetInsets(); | |
404 | 487 |
405 if (!is_editing_allowed) { | 488 if (!is_editing_allowed) { |
406 label_ = new views::Label(text); | 489 views::Label* name_label = new views::Label(text); |
407 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 490 name_label->SetBorder( |
408 label_->SetFontList(medium_font_list); | 491 views::Border::CreateEmptyBorder(textfield_border_insets)); |
409 AddChildView(label_); | 492 name_label->SetFontList(medium_font_list); |
493 if (switches::IsMaterialDesignUserMenu()) | |
494 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
495 AddChildView(name_label); | |
410 return; | 496 return; |
411 } | 497 } |
412 | 498 |
499 profile_name_textfield_ = new views::Textfield(); | |
500 // Textfield that overlaps the button. | |
501 profile_name_textfield_->set_controller(controller); | |
502 profile_name_textfield_->SetFontList(medium_font_list); | |
503 profile_name_textfield_->SetHorizontalAlignment( | |
504 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT | |
505 : gfx::ALIGN_CENTER); | |
506 profile_name_textfield_->SetVisible(false); | |
507 AddChildView(profile_name_textfield_); | |
508 | |
413 button_ = new RightAlignedIconLabelButton(this, text); | 509 button_ = new RightAlignedIconLabelButton(this, text); |
414 button_->SetFontList(medium_font_list); | 510 button_->SetFontList(medium_font_list); |
415 // Show an "edit" pencil icon when hovering over. In the default state, | 511 // Show an "edit" pencil icon when hovering over. In the default state, |
416 // we need to create an empty placeholder of the correct size, so that | 512 // we need to create an empty placeholder of the correct size, so that |
417 // the text doesn't jump around when the hovered icon appears. | 513 // the text doesn't jump around when the hovered icon appears. |
418 // TODO(estade): revisit colors and press effect. | 514 // TODO(estade): revisit colors and press effect. |
419 const int kIconSize = 16; | 515 const int kIconSize = 16; |
420 button_->SetImage(views::LabelButton::STATE_NORMAL, | 516 button_->SetImage(views::LabelButton::STATE_NORMAL, |
421 CreateSquarePlaceholderImage(kIconSize)); | 517 CreateSquarePlaceholderImage(kIconSize)); |
422 button_->SetImage(views::LabelButton::STATE_HOVERED, | 518 button_->SetImage(views::LabelButton::STATE_HOVERED, |
423 gfx::CreateVectorIcon( | 519 gfx::CreateVectorIcon( |
424 gfx::VectorIconId::MODE_EDIT, kIconSize, | 520 gfx::VectorIconId::MODE_EDIT, kIconSize, |
425 SkColorSetRGB(0x33, 0x33, 0x33))); | 521 SkColorSetRGB(0x33, 0x33, 0x33))); |
426 button_->SetImage(views::LabelButton::STATE_PRESSED, | 522 button_->SetImage(views::LabelButton::STATE_PRESSED, |
427 gfx::CreateVectorIcon( | 523 gfx::CreateVectorIcon( |
428 gfx::VectorIconId::MODE_EDIT, kIconSize, | 524 gfx::VectorIconId::MODE_EDIT, kIconSize, |
429 SkColorSetRGB(0x20, 0x20, 0x20))); | 525 SkColorSetRGB(0x20, 0x20, 0x20))); |
430 // To center the text, we need to offest it by the width of the icon we | 526 // We need to add a left padding as well as a small top/bottom padding |
431 // are adding and its padding. We need to also add a small top/bottom | 527 // to the text to account for the textfield's border. |
432 // padding to account for the textfield's border. | 528 if (switches::IsMaterialDesignUserMenu()) { |
433 const int kIconTextLabelButtonSpacing = 5; | 529 button_->SetBorder(views::Border::CreateEmptyBorder( |
434 button_->SetBorder(views::Border::CreateEmptyBorder( | 530 textfield_border_insets + |
435 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 531 gfx::Insets(0, profile_name_textfield_->GetInsets().left(), 0, 0))); |
532 } else { | |
533 const int kIconTextLabelButtonSpacing = 5; | |
534 button_->SetBorder(views::Border::CreateEmptyBorder( | |
535 textfield_border_insets + | |
536 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); | |
537 } | |
436 AddChildView(button_); | 538 AddChildView(button_); |
437 | |
438 profile_name_textfield_ = new views::Textfield(); | |
439 // Textfield that overlaps the button. | |
440 profile_name_textfield_->set_controller(controller); | |
441 profile_name_textfield_->SetFontList(medium_font_list); | |
442 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
443 profile_name_textfield_->SetVisible(false); | |
444 AddChildView(profile_name_textfield_); | |
445 } | 539 } |
446 | 540 |
447 views::Textfield* profile_name_textfield() { | 541 views::Textfield* profile_name_textfield() { |
448 return profile_name_textfield_; | 542 return profile_name_textfield_; |
449 } | 543 } |
450 | 544 |
451 // Hide the editable textfield to show the profile name button instead. | 545 // Hide the editable textfield to show the profile name button instead. |
452 void ShowReadOnlyView() { | 546 void ShowReadOnlyView() { |
453 button_->SetVisible(true); | 547 button_->SetVisible(true); |
454 profile_name_textfield_->SetVisible(false); | 548 profile_name_textfield_->SetVisible(false); |
(...skipping 17 matching lines...) Expand all Loading... | |
472 // you press space and clicks it when you release space, as the space can be | 566 // you press space and clicks it when you release space, as the space can be |
473 // part of the new profile name typed in the textfield. | 567 // part of the new profile name typed in the textfield. |
474 return false; | 568 return false; |
475 } | 569 } |
476 | 570 |
477 // The label button which shows the profile name, and can handle the event to | 571 // The label button which shows the profile name, and can handle the event to |
478 // make it editable. Can be NULL if the profile name isn't allowed to be | 572 // make it editable. Can be NULL if the profile name isn't allowed to be |
479 // edited. | 573 // edited. |
480 RightAlignedIconLabelButton* button_; | 574 RightAlignedIconLabelButton* button_; |
481 | 575 |
482 // The label which shows when the profile name cannot be edited (e.g. for | |
483 // supervised user). Can be NULL if the profile name is allowed to be edited. | |
484 views::Label* label_; | |
485 | |
486 // Textfield that is shown when editing the profile name. Can be NULL if | 576 // Textfield that is shown when editing the profile name. Can be NULL if |
487 // the profile name isn't allowed to be edited (e.g. for guest profiles). | 577 // the profile name isn't allowed to be edited (e.g. for guest profiles). |
488 views::Textfield* profile_name_textfield_; | 578 views::Textfield* profile_name_textfield_; |
489 | 579 |
490 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | 580 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); |
491 }; | 581 }; |
492 | 582 |
493 // A title card with one back button right aligned and one label center aligned. | 583 // A title card with one back button right aligned and one label center aligned. |
494 class TitleCard : public views::View { | 584 class TitleCard : public views::View { |
495 public: | 585 public: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 } | 648 } |
559 | 649 |
560 views::ImageButton* back_button_; | 650 views::ImageButton* back_button_; |
561 views::Label* title_label_; | 651 views::Label* title_label_; |
562 | 652 |
563 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 653 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
564 }; | 654 }; |
565 | 655 |
566 // ProfileBadge -------------------------------------------------------- | 656 // ProfileBadge -------------------------------------------------------- |
567 | 657 |
568 const size_t kProfileBadgeSize = 30; | |
569 const size_t kProfileBadgeWhitePadding = 2; | |
570 | |
571 // Draws a white circle, then a light blue circle, then a dark blue icon. | 658 // Draws a white circle, then a light blue circle, then a dark blue icon. |
572 class ProfileBadge : public gfx::CanvasImageSource { | 659 class ProfileBadge : public gfx::CanvasImageSource { |
573 public: | 660 public: |
574 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | 661 ProfileBadge(gfx::VectorIconId id, size_t icon_size) |
575 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | 662 : CanvasImageSource( |
576 false), | 663 gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()), |
664 false), | |
577 id_(id), | 665 id_(id), |
578 icon_size_(icon_size) {} | 666 icon_size_(icon_size) {} |
579 | 667 |
580 ~ProfileBadge() override {} | 668 ~ProfileBadge() override {} |
581 | 669 |
582 // CanvasImageSource: | 670 // CanvasImageSource: |
583 void Draw(gfx::Canvas* canvas) override { | 671 void Draw(gfx::Canvas* canvas) override { |
584 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | 672 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); |
585 gfx::Rect bounds(0, 0, size.width(), size.height()); | 673 gfx::Rect bounds(0, 0, size.width(), size.height()); |
586 | 674 |
587 SkPaint paint; | 675 SkPaint paint; |
588 paint.setAntiAlias(true); | 676 paint.setAntiAlias(true); |
589 paint.setColor(SK_ColorWHITE); | 677 paint.setColor(SK_ColorWHITE); |
590 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | 678 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); |
591 | 679 |
592 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | 680 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); |
593 canvas->DrawCircle(bounds.CenterPoint(), | 681 canvas->DrawCircle(bounds.CenterPoint(), |
594 size.width() / 2 - kProfileBadgeWhitePadding, paint); | 682 size.width() / 2 - kProfileBadgeWhitePadding, paint); |
595 | 683 |
596 int offset = (kProfileBadgeSize - icon_size_) / 2; | 684 int offset = (GetProfileBadgeSize() - icon_size_) / 2; |
597 canvas->Translate(gfx::Vector2d(offset, offset)); | 685 canvas->Translate(gfx::Vector2d(offset, offset)); |
598 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | 686 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
599 } | 687 } |
600 | 688 |
601 private: | 689 private: |
602 const gfx::VectorIconId id_; | 690 const gfx::VectorIconId id_; |
603 const size_t icon_size_; | 691 const size_t icon_size_; |
604 | 692 |
605 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | 693 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); |
606 }; | 694 }; |
607 | 695 |
608 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | 696 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
Evan Stade
2016/06/30 13:32:38
is this still being used?
Jane
2016/06/30 14:06:30
Done. Removed this and ProfileBadge class.
| |
609 ProfileBadge* badge = | 697 ProfileBadge* badge = |
610 profile->IsChild() | 698 profile->IsChild() |
611 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 699 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
612 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 700 switches::IsMaterialDesignUserMenu() ? 21 : 26) |
613 | 701 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
702 switches::IsMaterialDesignUserMenu() ? 16 : 20); | |
614 return gfx::ImageSkia(badge, badge->size()); | 703 return gfx::ImageSkia(badge, badge->size()); |
615 } | 704 } |
616 | 705 |
617 // ProfileChooserView --------------------------------------------------------- | 706 // ProfileChooserView --------------------------------------------------------- |
618 | 707 |
619 // static | 708 // static |
620 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 709 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
621 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 710 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
622 | 711 |
623 // static | 712 // static |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 bool ProfileChooserView::IsShowing() { | 750 bool ProfileChooserView::IsShowing() { |
662 return profile_bubble_ != NULL; | 751 return profile_bubble_ != NULL; |
663 } | 752 } |
664 | 753 |
665 // static | 754 // static |
666 void ProfileChooserView::Hide() { | 755 void ProfileChooserView::Hide() { |
667 if (IsShowing()) | 756 if (IsShowing()) |
668 profile_bubble_->GetWidget()->Close(); | 757 profile_bubble_->GetWidget()->Close(); |
669 } | 758 } |
670 | 759 |
760 // static | |
761 int ProfileChooserView::GetFixedMenuWidth() { | |
762 return switches::IsMaterialDesignUserMenu() ? 240 : 250; | |
763 } | |
764 | |
671 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 765 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
672 Browser* browser, | 766 Browser* browser, |
673 profiles::BubbleViewMode view_mode, | 767 profiles::BubbleViewMode view_mode, |
674 profiles::TutorialMode tutorial_mode, | 768 profiles::TutorialMode tutorial_mode, |
675 signin::GAIAServiceType service_type, | 769 signin::GAIAServiceType service_type, |
676 signin_metrics::AccessPoint access_point) | 770 signin_metrics::AccessPoint access_point) |
677 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 771 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
678 browser_(browser), | 772 browser_(browser), |
679 view_mode_(view_mode), | 773 view_mode_(view_mode), |
680 tutorial_mode_(tutorial_mode), | 774 tutorial_mode_(tutorial_mode), |
(...skipping 10 matching lines...) Expand all Loading... | |
691 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 785 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
692 if (oauth2_token_service) | 786 if (oauth2_token_service) |
693 oauth2_token_service->RemoveObserver(this); | 787 oauth2_token_service->RemoveObserver(this); |
694 } | 788 } |
695 | 789 |
696 void ProfileChooserView::ResetView() { | 790 void ProfileChooserView::ResetView() { |
697 open_other_profile_indexes_map_.clear(); | 791 open_other_profile_indexes_map_.clear(); |
698 delete_account_button_map_.clear(); | 792 delete_account_button_map_.clear(); |
699 reauth_account_button_map_.clear(); | 793 reauth_account_button_map_.clear(); |
700 manage_accounts_link_ = nullptr; | 794 manage_accounts_link_ = nullptr; |
701 signin_current_profile_link_ = nullptr; | 795 signin_current_profile_button_ = nullptr; |
702 auth_error_email_button_ = nullptr; | 796 auth_error_email_button_ = nullptr; |
703 current_profile_photo_ = nullptr; | 797 current_profile_photo_ = nullptr; |
704 current_profile_name_ = nullptr; | 798 current_profile_name_ = nullptr; |
705 guest_profile_button_ = nullptr; | 799 guest_profile_button_ = nullptr; |
706 users_button_ = nullptr; | 800 users_button_ = nullptr; |
707 go_incognito_button_ = nullptr; | 801 go_incognito_button_ = nullptr; |
708 lock_button_ = nullptr; | 802 lock_button_ = nullptr; |
709 close_all_windows_button_ = nullptr; | 803 close_all_windows_button_ = nullptr; |
710 add_account_link_ = nullptr; | 804 add_account_link_ = nullptr; |
711 gaia_signin_cancel_button_ = nullptr; | 805 gaia_signin_cancel_button_ = nullptr; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 break; | 932 break; |
839 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 933 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
840 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 934 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
841 sub_view = CreateSwitchUserView(); | 935 sub_view = CreateSwitchUserView(); |
842 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 936 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
843 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 937 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
844 break; | 938 break; |
845 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 939 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
846 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 940 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
847 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 941 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
848 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 942 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
849 sub_view = CreateProfileChooserView(avatar_menu); | 943 sub_view = CreateProfileChooserView(avatar_menu); |
850 break; | 944 break; |
851 } | 945 } |
852 // Clears tutorial mode for all non-profile-chooser views. | 946 // Clears tutorial mode for all non-profile-chooser views. |
853 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 947 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
854 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 948 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
855 | 949 |
856 layout->StartRow(1, 0); | 950 layout->StartRow(1, 0); |
857 layout->AddView(sub_view); | 951 layout->AddView(sub_view); |
858 Layout(); | 952 Layout(); |
(...skipping 26 matching lines...) Expand all Loading... | |
885 if (accelerator.key_code() != ui::VKEY_DOWN && | 979 if (accelerator.key_code() != ui::VKEY_DOWN && |
886 accelerator.key_code() != ui::VKEY_UP) | 980 accelerator.key_code() != ui::VKEY_UP) |
887 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); | 981 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); |
888 | 982 |
889 // Move the focus up or down. | 983 // Move the focus up or down. |
890 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); | 984 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
891 return true; | 985 return true; |
892 } | 986 } |
893 | 987 |
894 views::View* ProfileChooserView::GetInitiallyFocusedView() { | 988 views::View* ProfileChooserView::GetInitiallyFocusedView() { |
895 return signin_current_profile_link_; | 989 return signin_current_profile_button_; |
896 } | 990 } |
897 | 991 |
898 int ProfileChooserView::GetDialogButtons() const { | 992 int ProfileChooserView::GetDialogButtons() const { |
899 return ui::DIALOG_BUTTON_NONE; | 993 return ui::DIALOG_BUTTON_NONE; |
900 } | 994 } |
901 | 995 |
902 bool ProfileChooserView::HandleContextMenu( | 996 bool ProfileChooserView::HandleContextMenu( |
903 const content::ContextMenuParams& params) { | 997 const content::ContextMenuParams& params) { |
904 // Suppresses the context menu because some features, such as inspecting | 998 // Suppresses the context menu because some features, such as inspecting |
905 // elements, are not appropriate in a bubble. | 999 // elements, are not appropriate in a bubble. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 bool account_management_available = | 1055 bool account_management_available = |
962 SigninManagerFactory::GetForProfile(browser_->profile())-> | 1056 SigninManagerFactory::GetForProfile(browser_->profile())-> |
963 IsAuthenticated() && | 1057 IsAuthenticated() && |
964 switches::IsEnableAccountConsistency(); | 1058 switches::IsEnableAccountConsistency(); |
965 ShowViewFromMode(account_management_available ? | 1059 ShowViewFromMode(account_management_available ? |
966 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 1060 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
967 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 1061 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
968 } else if (sender == current_profile_photo_) { | 1062 } else if (sender == current_profile_photo_) { |
969 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 1063 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
970 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 1064 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
971 } else if (sender == signin_current_profile_link_) { | 1065 } else if (sender == signin_current_profile_button_) { |
972 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 1066 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
973 } else if (sender == add_person_button_) { | 1067 } else if (sender == add_person_button_) { |
974 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1068 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
975 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 1069 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
976 UserManager::Show(base::FilePath(), | 1070 UserManager::Show(base::FilePath(), |
977 profiles::USER_MANAGER_NO_TUTORIAL, | 1071 profiles::USER_MANAGER_NO_TUTORIAL, |
978 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1072 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
979 } else if (sender == disconnect_button_) { | 1073 } else if (sender == disconnect_button_) { |
980 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1074 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
981 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 1075 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1099 views::View* tutorial_view = NULL; | 1193 views::View* tutorial_view = NULL; |
1100 views::View* current_profile_view = NULL; | 1194 views::View* current_profile_view = NULL; |
1101 views::View* current_profile_accounts = NULL; | 1195 views::View* current_profile_accounts = NULL; |
1102 views::View* option_buttons_view = NULL; | 1196 views::View* option_buttons_view = NULL; |
1103 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1197 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1104 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1198 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1105 if (item.active) { | 1199 if (item.active) { |
1106 option_buttons_view = CreateOptionsView( | 1200 option_buttons_view = CreateOptionsView( |
1107 item.signed_in && profiles::IsLockAvailable(browser_->profile()), | 1201 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
1108 avatar_menu); | 1202 avatar_menu); |
1109 current_profile_view = CreateCurrentProfileView(item, false); | 1203 current_profile_view = |
1204 switches::IsMaterialDesignUserMenu() | |
1205 ? CreateMaterialDesignCurrentProfileView(item, false) | |
1206 : CreateCurrentProfileView(item, false); | |
1110 if (IsProfileChooser(view_mode_)) { | 1207 if (IsProfileChooser(view_mode_)) { |
1111 tutorial_view = CreateTutorialViewIfNeeded(item); | 1208 tutorial_view = CreateTutorialViewIfNeeded(item); |
1112 } else { | 1209 } else { |
1113 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1210 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1114 } | 1211 } |
1115 } else { | 1212 } else { |
1116 other_profiles.push_back(i); | 1213 other_profiles.push_back(i); |
1117 } | 1214 } |
1118 } | 1215 } |
1119 | 1216 |
(...skipping 16 matching lines...) Expand all Loading... | |
1136 | 1233 |
1137 if (!IsProfileChooser(view_mode_)) { | 1234 if (!IsProfileChooser(view_mode_)) { |
1138 DCHECK(current_profile_accounts); | 1235 DCHECK(current_profile_accounts); |
1139 layout->StartRow(0, 0); | 1236 layout->StartRow(0, 0); |
1140 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1237 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1141 layout->StartRow(1, 0); | 1238 layout->StartRow(1, 0); |
1142 layout->AddView(current_profile_accounts); | 1239 layout->AddView(current_profile_accounts); |
1143 } | 1240 } |
1144 | 1241 |
1145 if (browser_->profile()->IsSupervised()) { | 1242 if (browser_->profile()->IsSupervised()) { |
1146 layout->StartRow(0, 0); | 1243 if (!switches::IsMaterialDesignUserMenu()) { |
1147 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1244 layout->StartRow(0, 0); |
1245 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
1246 } | |
1148 layout->StartRow(1, 0); | 1247 layout->StartRow(1, 0); |
1149 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1248 layout->AddView(CreateSupervisedUserDisclaimerView()); |
1150 } | 1249 } |
1151 | 1250 |
1152 layout->StartRow(0, 0); | 1251 layout->StartRow(0, 0); |
1153 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1252 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1154 | 1253 |
1155 if (option_buttons_view) { | 1254 if (option_buttons_view) { |
1156 layout->StartRow(0, 0); | 1255 layout->StartRow(0, 0); |
1157 layout->AddView(option_buttons_view); | 1256 layout->AddView(option_buttons_view); |
(...skipping 11 matching lines...) Expand all Loading... | |
1169 } | 1268 } |
1170 } | 1269 } |
1171 | 1270 |
1172 layout->StartRow(1, 0); | 1271 layout->StartRow(1, 0); |
1173 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1272 layout->AddView(CreateOtherProfilesView(other_profiles)); |
1174 } | 1273 } |
1175 | 1274 |
1176 views::View* ProfileChooserView::CreateProfileChooserView( | 1275 views::View* ProfileChooserView::CreateProfileChooserView( |
1177 AvatarMenu* avatar_menu) { | 1276 AvatarMenu* avatar_menu) { |
1178 views::View* view = new views::View(); | 1277 views::View* view = new views::View(); |
1179 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1278 views::GridLayout* layout = |
1279 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1180 | 1280 |
1181 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1281 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
1182 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1282 PopulateMinimalProfileChooserView(layout, avatar_menu); |
1183 // The user is using right-click switching, no need to tell them about it. | 1283 // The user is using right-click switching, no need to tell them about it. |
1184 PrefService* local_state = g_browser_process->local_state(); | 1284 PrefService* local_state = g_browser_process->local_state(); |
1185 local_state->SetBoolean( | 1285 local_state->SetBoolean( |
1186 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1286 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1187 } else { | 1287 } else { |
1188 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1288 PopulateCompleteProfileChooserView(layout, avatar_menu); |
1189 } | 1289 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 const base::string16& button_text, | 1344 const base::string16& button_text, |
1245 bool stack_button, | 1345 bool stack_button, |
1246 views::Link** link, | 1346 views::Link** link, |
1247 views::LabelButton** button, | 1347 views::LabelButton** button, |
1248 views::ImageButton** close_button) { | 1348 views::ImageButton** close_button) { |
1249 tutorial_mode_ = tutorial_mode; | 1349 tutorial_mode_ = tutorial_mode; |
1250 | 1350 |
1251 views::View* view = new views::View(); | 1351 views::View* view = new views::View(); |
1252 view->set_background(views::Background::CreateSolidBackground( | 1352 view->set_background(views::Background::CreateSolidBackground( |
1253 profiles::kAvatarTutorialBackgroundColor)); | 1353 profiles::kAvatarTutorialBackgroundColor)); |
1254 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1354 views::GridLayout* layout = CreateSingleColumnLayout( |
1255 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1355 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1256 // Creates a second column set for buttons and links. | 1356 // Creates a second column set for buttons and links. |
1257 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1357 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
1258 button_columns->AddColumn(views::GridLayout::LEADING, | 1358 button_columns->AddColumn(views::GridLayout::LEADING, |
1259 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1359 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1260 button_columns->AddPaddingColumn( | 1360 button_columns->AddPaddingColumn( |
1261 1, views::kUnrelatedControlHorizontalSpacing); | 1361 1, views::kUnrelatedControlHorizontalSpacing); |
1262 button_columns->AddColumn(views::GridLayout::TRAILING, | 1362 button_columns->AddColumn(views::GridLayout::TRAILING, |
1263 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1363 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1264 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1364 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1265 views::kButtonHEdgeMarginNew, | 1365 views::kButtonHEdgeMarginNew, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1347 layout->SkipColumns(1); | 1447 layout->SkipColumns(1); |
1348 } | 1448 } |
1349 | 1449 |
1350 return view; | 1450 return view; |
1351 } | 1451 } |
1352 | 1452 |
1353 views::View* ProfileChooserView::CreateCurrentProfileView( | 1453 views::View* ProfileChooserView::CreateCurrentProfileView( |
1354 const AvatarMenu::Item& avatar_item, | 1454 const AvatarMenu::Item& avatar_item, |
1355 bool is_guest) { | 1455 bool is_guest) { |
1356 views::View* view = new views::View(); | 1456 views::View* view = new views::View(); |
1357 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1457 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
1358 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1458 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
1359 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1459 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1360 views::kButtonHEdgeMarginNew, | 1460 views::kButtonHEdgeMarginNew, |
1361 views::kUnrelatedControlVerticalSpacing, | 1461 views::kUnrelatedControlVerticalSpacing, |
1362 views::kButtonHEdgeMarginNew); | 1462 views::kButtonHEdgeMarginNew); |
1363 | 1463 |
1364 // Profile icon, centered. | 1464 // Profile icon, centered. |
1365 int x_offset = (column_width - kLargeImageSide) / 2; | 1465 int x_offset = (column_width - kLargeImageSide) / 2; |
1366 current_profile_photo_ = new EditableProfilePhoto( | 1466 current_profile_photo_ = new EditableProfilePhoto( |
1367 this, avatar_item.icon, !is_guest, | 1467 this, avatar_item.icon, !is_guest, browser_->profile()); |
1368 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); | 1468 current_profile_photo_->SetX(x_offset); |
1369 SizedContainer* profile_icon_container = | 1469 SizedContainer* profile_icon_container = |
1370 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | 1470 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
1371 profile_icon_container->AddChildView(current_profile_photo_); | 1471 profile_icon_container->AddChildView(current_profile_photo_); |
1372 | 1472 |
1373 if (browser_->profile()->IsSupervised()) { | |
1374 views::ImageView* supervised_icon = new views::ImageView(); | |
1375 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); | |
1376 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | |
1377 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | |
1378 supervised_icon->SetBounds( | |
1379 parent_bounds.right() - preferred_size.width(), | |
1380 parent_bounds.bottom() - preferred_size.height(), | |
1381 preferred_size.width(), | |
1382 preferred_size.height()); | |
1383 profile_icon_container->AddChildView(supervised_icon); | |
1384 } | |
1385 | 1473 |
1386 layout->StartRow(1, 0); | 1474 layout->StartRow(1, 0); |
1387 layout->AddView(profile_icon_container); | 1475 layout->AddView(profile_icon_container); |
1388 | 1476 |
1389 // Profile name, centered. | 1477 // Profile name, centered. |
1390 bool editing_allowed = !is_guest && | 1478 bool editing_allowed = !is_guest && |
1391 !browser_->profile()->IsLegacySupervised(); | 1479 !browser_->profile()->IsLegacySupervised(); |
1392 current_profile_name_ = new EditableProfileName( | 1480 current_profile_name_ = new EditableProfileName( |
1393 this, | 1481 this, |
1394 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | 1482 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1445 if (signin_manager->IsSigninAllowed()) { | 1533 if (signin_manager->IsSigninAllowed()) { |
1446 views::Label* promo = new views::Label( | 1534 views::Label* promo = new views::Label( |
1447 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | 1535 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
1448 promo->SetMultiLine(true); | 1536 promo->SetMultiLine(true); |
1449 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1537 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1450 layout->StartRowWithPadding(1, 0, 0, | 1538 layout->StartRowWithPadding(1, 0, 0, |
1451 views::kRelatedControlSmallVerticalSpacing); | 1539 views::kRelatedControlSmallVerticalSpacing); |
1452 layout->StartRow(1, 0); | 1540 layout->StartRow(1, 0); |
1453 layout->AddView(promo); | 1541 layout->AddView(promo); |
1454 | 1542 |
1455 signin_current_profile_link_ = new views::BlueButton( | 1543 signin_current_profile_button_ = new views::BlueButton( |
1456 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 1544 this, l10n_util::GetStringFUTF16( |
1457 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 1545 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
1546 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1458 layout->StartRowWithPadding(1, 0, 0, | 1547 layout->StartRowWithPadding(1, 0, 0, |
1459 views::kRelatedControlVerticalSpacing); | 1548 views::kRelatedControlVerticalSpacing); |
1460 layout->StartRow(1, 0); | 1549 layout->StartRow(1, 0); |
1461 layout->AddView(signin_current_profile_link_); | 1550 layout->AddView(signin_current_profile_button_); |
1462 content::RecordAction( | 1551 content::RecordAction( |
1463 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1552 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
1464 } | 1553 } |
1465 } | 1554 } |
1466 | 1555 |
1467 return view; | 1556 return view; |
1468 } | 1557 } |
1469 | 1558 |
1559 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( | |
1560 const AvatarMenu::Item& avatar_item, | |
1561 bool is_guest) { | |
1562 views::View* view = new views::View(); | |
1563 view->SetLayoutManager( | |
1564 new views::BoxLayout(views::BoxLayout::kVertical, kMaterialMenuEdgeMargin, | |
1565 views::kRelatedControlVerticalSpacing, | |
1566 views::kRelatedControlVerticalSpacing)); | |
1567 | |
1568 // Profile container for the profile photo and avatar/user name. | |
1569 views::View* profile_container = new views::View(); | |
1570 | |
1571 // Profile picture, left-aligned. | |
1572 current_profile_photo_ = new EditableProfilePhoto( | |
1573 this, avatar_item.icon, !is_guest, browser_->profile()); | |
1574 | |
1575 // Profile name, left-aligned to the right of profile icon. | |
1576 bool editing_allowed = | |
1577 !is_guest && !browser_->profile()->IsLegacySupervised(); | |
1578 current_profile_name_ = new EditableProfileName( | |
1579 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | |
1580 editing_allowed); | |
1581 views::View* profile_name_container = new views::View(); | |
1582 int name_container_v_spacing = views::kRelatedControlSmallVerticalSpacing; | |
1583 if (!avatar_item.signed_in) | |
1584 name_container_v_spacing += views::kRelatedControlVerticalSpacing; | |
1585 profile_name_container->SetLayoutManager(new views::BoxLayout( | |
1586 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0)); | |
1587 profile_name_container->AddChildView(current_profile_name_); | |
1588 | |
1589 const int between_child_spacing = | |
1590 kMaterialMenuEdgeMargin - current_profile_photo_->badge_spacing; | |
1591 profile_container->SetLayoutManager(new views::BoxLayout( | |
1592 views::BoxLayout::kHorizontal, 0, | |
1593 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); | |
1594 profile_container->AddChildView(current_profile_photo_); | |
1595 profile_container->AddChildView(profile_name_container); | |
1596 view->AddChildView(profile_container); | |
1597 | |
1598 if (is_guest) | |
1599 return view; | |
1600 | |
1601 // The available links depend on the type of profile that is active. | |
1602 if (avatar_item.signed_in) { | |
1603 if (switches::IsEnableAccountConsistency()) { | |
1604 base::string16 link_title = l10n_util::GetStringUTF16( | |
1605 IsProfileChooser(view_mode_) | |
1606 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON | |
1607 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | |
1608 manage_accounts_link_ = CreateLink(link_title, this); | |
1609 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1610 profile_name_container->AddChildView(manage_accounts_link_); | |
1611 } else { | |
1612 views::Label* email_label = new views::Label(avatar_item.username); | |
1613 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); | |
1614 email_label->SetEnabled(false); | |
1615 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1616 profile_name_container->AddChildView(email_label); | |
1617 } | |
1618 return view; | |
1619 } | |
1620 | |
1621 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( | |
1622 browser_->profile()->GetOriginalProfile()); | |
1623 if (signin_manager->IsSigninAllowed()) { | |
1624 views::Label* promo = | |
1625 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | |
1626 promo->SetMultiLine(true); | |
1627 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1628 view->AddChildView(promo); | |
1629 | |
1630 signin_current_profile_button_ = | |
1631 views::MdTextButton::CreateSecondaryUiBlueButton( | |
1632 this, l10n_util::GetStringFUTF16( | |
1633 IDS_SYNC_START_SYNC_BUTTON_LABEL, | |
1634 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
1635 view->AddChildView(signin_current_profile_button_); | |
1636 content::RecordAction( | |
1637 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | |
1638 view->SetBorder(views::Border::CreateEmptyBorder( | |
1639 0, 0, views::kRelatedControlVerticalSpacing, 0)); | |
1640 } | |
1641 | |
1642 return view; | |
1643 } | |
1644 | |
1470 views::View* ProfileChooserView::CreateGuestProfileView() { | 1645 views::View* ProfileChooserView::CreateGuestProfileView() { |
1471 gfx::Image guest_icon = | 1646 gfx::Image guest_icon = |
1472 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1647 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
1473 profiles::GetPlaceholderAvatarIconResourceID()); | 1648 profiles::GetPlaceholderAvatarIconResourceID()); |
1474 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1649 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
1475 guest_avatar_item.active = true; | 1650 guest_avatar_item.active = true; |
1476 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1651 guest_avatar_item.name = l10n_util::GetStringUTF16( |
1477 IDS_PROFILES_GUEST_PROFILE_NAME); | 1652 IDS_PROFILES_GUEST_PROFILE_NAME); |
1478 guest_avatar_item.signed_in = false; | 1653 guest_avatar_item.signed_in = false; |
1479 | 1654 |
1480 return CreateCurrentProfileView(guest_avatar_item, true); | 1655 return switches::IsMaterialDesignUserMenu() |
1656 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) | |
1657 : CreateCurrentProfileView(guest_avatar_item, true); | |
1481 } | 1658 } |
1482 | 1659 |
1483 views::View* ProfileChooserView::CreateOtherProfilesView( | 1660 views::View* ProfileChooserView::CreateOtherProfilesView( |
1484 const Indexes& avatars_to_show) { | 1661 const Indexes& avatars_to_show) { |
1485 views::View* view = new views::View(); | 1662 views::View* view = new views::View(); |
1486 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1663 views::GridLayout* layout = |
1664 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1487 | 1665 |
1488 for (size_t index : avatars_to_show) { | 1666 for (size_t index : avatars_to_show) { |
1489 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1667 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
1490 const int kSmallImageSide = 32; | 1668 const int kSmallImageSide = 32; |
1491 | 1669 |
1492 // Use the low-res, small default avatars in the fast user switcher, like | 1670 // Use the low-res, small default avatars in the fast user switcher, like |
1493 // we do in the menu bar. | 1671 // we do in the menu bar. |
1494 gfx::Image item_icon; | 1672 gfx::Image item_icon; |
1495 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1673 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
1496 | 1674 |
(...skipping 11 matching lines...) Expand all Loading... | |
1508 layout->StartRow(1, 0); | 1686 layout->StartRow(1, 0); |
1509 layout->AddView(button); | 1687 layout->AddView(button); |
1510 } | 1688 } |
1511 | 1689 |
1512 return view; | 1690 return view; |
1513 } | 1691 } |
1514 | 1692 |
1515 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, | 1693 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
1516 AvatarMenu* avatar_menu) { | 1694 AvatarMenu* avatar_menu) { |
1517 views::View* view = new views::View(); | 1695 views::View* view = new views::View(); |
1518 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1696 views::GridLayout* layout = |
1697 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1519 | 1698 |
1520 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; | 1699 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; |
1521 if (switches::IsMaterialDesignUserMenu()) { | 1700 if (switches::IsMaterialDesignUserMenu()) { |
1522 // Add the user switching buttons | 1701 // Add the user switching buttons |
1523 const int kProfileIconSize = 18; | 1702 const int kProfileIconSize = 18; |
1524 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1703 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1525 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1704 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1526 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1705 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1527 if (!item.active) { | 1706 if (!item.active) { |
1528 gfx::Image image = profiles::GetSizedAvatarIcon( | 1707 gfx::Image image = profiles::GetSizedAvatarIcon( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1614 } | 1793 } |
1615 | 1794 |
1616 if (switches::IsMaterialDesignUserMenu()) | 1795 if (switches::IsMaterialDesignUserMenu()) |
1617 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1796 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1618 return view; | 1797 return view; |
1619 } | 1798 } |
1620 | 1799 |
1621 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1800 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1622 views::View* view = new views::View(); | 1801 views::View* view = new views::View(); |
1623 views::GridLayout* layout = CreateSingleColumnLayout( | 1802 views::GridLayout* layout = CreateSingleColumnLayout( |
1624 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1803 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1625 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1804 if (switches::IsMaterialDesignUserMenu()) { |
1626 views::kButtonHEdgeMarginNew, | 1805 layout->SetInsets(0, kMaterialMenuEdgeMargin, kMaterialMenuEdgeMargin, |
1627 views::kRelatedControlVerticalSpacing, | 1806 kMaterialMenuEdgeMargin); |
1628 views::kButtonHEdgeMarginNew); | 1807 } else { |
1808 layout->SetInsets( | |
1809 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, | |
1810 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); | |
1811 } | |
1812 | |
1629 views::Label* disclaimer = new views::Label( | 1813 views::Label* disclaimer = new views::Label( |
1630 avatar_menu_->GetSupervisedUserInformation()); | 1814 avatar_menu_->GetSupervisedUserInformation()); |
1631 disclaimer->SetMultiLine(true); | 1815 disclaimer->SetMultiLine(true); |
1632 disclaimer->SetAllowCharacterBreak(true); | 1816 disclaimer->SetAllowCharacterBreak(true); |
1633 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1817 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1634 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1818 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1635 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1819 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
1636 layout->StartRow(1, 0); | 1820 layout->StartRow(1, 0); |
1637 layout->AddView(disclaimer); | 1821 layout->AddView(disclaimer); |
1638 | 1822 |
1639 return view; | 1823 return view; |
1640 } | 1824 } |
1641 | 1825 |
1642 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1826 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
1643 const AvatarMenu::Item& avatar_item) { | 1827 const AvatarMenu::Item& avatar_item) { |
1644 DCHECK(avatar_item.signed_in); | 1828 DCHECK(avatar_item.signed_in); |
1645 views::View* view = new views::View(); | 1829 views::View* view = new views::View(); |
1646 view->set_background(views::Background::CreateSolidBackground( | 1830 view->set_background(views::Background::CreateSolidBackground( |
1647 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1831 profiles::kAvatarBubbleAccountsBackgroundColor)); |
1648 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1832 views::GridLayout* layout = |
1833 CreateSingleColumnLayout(view, GetFixedMenuWidth()); | |
1649 | 1834 |
1650 Profile* profile = browser_->profile(); | 1835 Profile* profile = browser_->profile(); |
1651 std::string primary_account = | 1836 std::string primary_account = |
1652 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1837 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
1653 DCHECK(!primary_account.empty()); | 1838 DCHECK(!primary_account.empty()); |
1654 std::vector<std::string>accounts = | 1839 std::vector<std::string>accounts = |
1655 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1840 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
1656 | 1841 |
1657 // Get state of authentication error, if any. | 1842 // Get state of authentication error, if any. |
1658 std::string error_account_id = GetAuthErrorAccountId(profile); | 1843 std::string error_account_id = GetAuthErrorAccountId(profile); |
1659 | 1844 |
1660 // The primary account should always be listed first. | 1845 // The primary account should always be listed first. |
1661 // TODO(rogerta): we still need to further differentiate the primary account | 1846 // TODO(rogerta): we still need to further differentiate the primary account |
1662 // from the others in the UI, so more work is likely required here: | 1847 // from the others in the UI, so more work is likely required here: |
1663 // crbug.com/311124. | 1848 // crbug.com/311124. |
1664 CreateAccountButton(layout, primary_account, true, | 1849 CreateAccountButton(layout, primary_account, true, |
1665 error_account_id == primary_account, kFixedMenuWidth); | 1850 error_account_id == primary_account, GetFixedMenuWidth()); |
1666 for (size_t i = 0; i < accounts.size(); ++i) | 1851 for (size_t i = 0; i < accounts.size(); ++i) |
1667 CreateAccountButton(layout, accounts[i], false, | 1852 CreateAccountButton(layout, accounts[i], false, |
1668 error_account_id == accounts[i], kFixedMenuWidth); | 1853 error_account_id == accounts[i], GetFixedMenuWidth()); |
1669 | 1854 |
1670 if (!profile->IsSupervised()) { | 1855 if (!profile->IsSupervised()) { |
1671 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1856 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1672 | 1857 |
1673 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1858 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
1674 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1859 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
1675 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1860 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
1676 0, views::kButtonVEdgeMarginNew, | 1861 0, views::kButtonVEdgeMarginNew, |
1677 views::kRelatedControlVerticalSpacing, 0)); | 1862 views::kRelatedControlVerticalSpacing, 0)); |
1678 layout->StartRow(1, 0); | 1863 layout->StartRow(1, 0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2153 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1969 IncognitoModePrefs::DISABLED; | 2154 IncognitoModePrefs::DISABLED; |
1970 return incognito_available && !browser_->profile()->IsGuestSession(); | 2155 return incognito_available && !browser_->profile()->IsGuestSession(); |
1971 } | 2156 } |
1972 | 2157 |
1973 void ProfileChooserView::PostActionPerformed( | 2158 void ProfileChooserView::PostActionPerformed( |
1974 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2159 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1975 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2160 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1976 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2161 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1977 } | 2162 } |
OLD | NEW |