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 GetFixedMenuWidth() { |
| 110 return switches::IsMaterialDesignUserMenu() ? 240 : 250; |
| 111 } |
| 112 |
| 113 int GetProfileBadgeSize() { |
| 114 return switches::IsMaterialDesignUserMenu() ? 24 : 30; |
| 115 } |
| 116 |
| 117 // DEPRECATED: New user menu components should use views::BoxLayout instead. |
104 // Creates a GridLayout with a single column. This ensures that all the child | 118 // 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. | 119 // views added get auto-expanded to fill the full width of the bubble. |
106 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 120 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
107 views::GridLayout* layout = new views::GridLayout(view); | 121 views::GridLayout* layout = new views::GridLayout(view); |
108 view->SetLayoutManager(layout); | 122 view->SetLayoutManager(layout); |
109 | 123 |
110 views::ColumnSet* columns = layout->AddColumnSet(0); | 124 views::ColumnSet* columns = layout->AddColumnSet(0); |
111 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 125 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
112 views::GridLayout::FIXED, width, width); | 126 views::GridLayout::FIXED, width, width); |
113 return layout; | 127 return layout; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 gfx::Rect bounds(title_view_->GetPreferredSize()); | 271 gfx::Rect bounds(title_view_->GetPreferredSize()); |
258 title_view_->SetBoundsRect(bounds); | 272 title_view_->SetBoundsRect(bounds); |
259 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); | 273 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); |
260 title_widget_->SetBounds(bounds); | 274 title_widget_->SetBounds(bounds); |
261 } | 275 } |
262 | 276 |
263 } // namespace | 277 } // namespace |
264 | 278 |
265 // RightAlignedIconLabelButton ------------------------------------------------- | 279 // RightAlignedIconLabelButton ------------------------------------------------- |
266 | 280 |
267 // A custom LabelButton that has a centered text and right aligned icon. | 281 // A custom LabelButton that has a left-aligned text and right aligned icon. |
| 282 // For non-material-design user menu, it has centered text instead. |
268 class RightAlignedIconLabelButton : public views::LabelButton { | 283 class RightAlignedIconLabelButton : public views::LabelButton { |
269 public: | 284 public: |
270 RightAlignedIconLabelButton(views::ButtonListener* listener, | 285 RightAlignedIconLabelButton(views::ButtonListener* listener, |
271 const base::string16& text) | 286 const base::string16& text) |
272 : views::LabelButton(listener, text) { | 287 : views::LabelButton(listener, text) { |
273 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 288 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
274 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 289 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
| 290 ? gfx::ALIGN_LEFT |
| 291 : gfx::ALIGN_CENTER); |
275 } | 292 } |
276 | 293 |
277 protected: | 294 protected: |
278 void Layout() override { | 295 void Layout() override { |
279 views::LabelButton::Layout(); | 296 views::LabelButton::Layout(); |
280 | 297 |
281 // Keep the text centered and the icon right-aligned by stretching the label | 298 // 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. | 299 // to take up more of the content area and centering its contents. |
283 gfx::Rect content_bounds = GetContentsBounds(); | 300 gfx::Rect content_bounds = GetContentsBounds(); |
284 gfx::Rect label_bounds = label()->bounds(); | 301 gfx::Rect label_bounds = label()->bounds(); |
285 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); | 302 label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); |
286 label()->SetBoundsRect(label_bounds); | 303 label()->SetBoundsRect(label_bounds); |
287 } | 304 } |
288 | 305 |
289 private: | 306 private: |
290 void OnFocus() override { | 307 void OnFocus() override { |
291 SetState(STATE_HOVERED); | 308 SetState(STATE_HOVERED); |
292 } | 309 } |
293 | 310 |
294 void OnBlur() override { | 311 void OnBlur() override { |
295 SetState(STATE_NORMAL); | 312 SetState(STATE_NORMAL); |
296 } | 313 } |
297 | 314 |
298 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | 315 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
299 }; | 316 }; |
300 | 317 |
301 // EditableProfilePhoto ------------------------------------------------- | 318 // EditableProfilePhoto ------------------------------------------------- |
302 | 319 |
| 320 const size_t kProfileBadgeWhitePadding = 2; |
| 321 |
303 // A custom Image control that shows a "change" button when moused over. | 322 // A custom Image control that shows a "change" button when moused over. |
304 class EditableProfilePhoto : public views::LabelButton { | 323 class EditableProfilePhoto : public views::LabelButton { |
305 public: | 324 public: |
306 EditableProfilePhoto(views::ButtonListener* listener, | 325 EditableProfilePhoto(views::ButtonListener* listener, |
307 const gfx::Image& icon, | 326 const gfx::Image& icon, |
308 bool is_editing_allowed, | 327 bool is_editing_allowed, |
309 const gfx::Rect& bounds) | 328 Profile* profile) |
310 : views::LabelButton(listener, base::string16()), | 329 : views::LabelButton(listener, base::string16()), |
311 photo_overlay_(NULL) { | 330 photo_overlay_(nullptr), |
| 331 profile_(profile) { |
312 gfx::Image image = profiles::GetSizedAvatarIcon( | 332 gfx::Image image = profiles::GetSizedAvatarIcon( |
313 icon, true, kLargeImageSide, kLargeImageSide); | 333 icon, true, icon_image_side(), icon_image_side()); |
314 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); | 334 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
315 SetBorder(views::Border::NullBorder()); | 335 SetBorder(views::Border::NullBorder()); |
316 SetBoundsRect(bounds); | 336 if (switches::IsMaterialDesignUserMenu()) { |
| 337 SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), |
| 338 GetPreferredSize().height() + badge_spacing() + |
| 339 views::kRelatedControlSmallVerticalSpacing)); |
| 340 } else { |
| 341 SetSize(GetPreferredSize()); |
| 342 } |
317 | 343 |
318 // Calculate the circular mask that will be used to display the photo. | 344 // Calculate the circular mask that will be used to display the photo. |
319 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), | 345 circular_mask_.addCircle( |
320 SkIntToScalar(bounds.height() / 2), | 346 SkIntToScalar(icon_image_side() / 2), |
321 SkIntToScalar(bounds.width() / 2)); | 347 SkIntToScalar(icon_image_side() / 2) + badge_spacing(), |
| 348 SkIntToScalar(icon_image_side() / 2)); |
322 | 349 |
323 if (!is_editing_allowed) { | 350 if (!is_editing_allowed) { |
324 SetEnabled(false); | 351 SetEnabled(false); |
325 return; | 352 return; |
326 } | 353 } |
327 | 354 |
328 set_notify_enter_exit_on_child(true); | 355 set_notify_enter_exit_on_child(true); |
329 | 356 |
330 // Photo overlay that appears when hovering over the button. | 357 // Photo overlay that appears when hovering over the button. |
331 photo_overlay_ = new views::ImageView(); | 358 photo_overlay_ = new views::ImageView(); |
332 | 359 |
333 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 360 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
334 photo_overlay_->set_background( | 361 photo_overlay_->set_background( |
335 views::Background::CreateSolidBackground(kBackgroundColor)); | 362 views::Background::CreateSolidBackground(kBackgroundColor)); |
336 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 363 photo_overlay_->SetImage( |
337 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 364 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA, |
| 365 switches::IsMaterialDesignUserMenu() ? 22u : 48u, |
| 366 SkColorSetRGB(0x33, 0x33, 0x33))); |
338 | 367 |
339 photo_overlay_->SetSize(bounds.size()); | 368 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); |
| 369 photo_overlay_->SetY(badge_spacing()); |
340 photo_overlay_->SetVisible(false); | 370 photo_overlay_->SetVisible(false); |
341 AddChildView(photo_overlay_); | 371 AddChildView(photo_overlay_); |
342 } | 372 } |
343 | 373 |
344 void OnPaint(gfx::Canvas* canvas) override { | 374 void OnPaint(gfx::Canvas* canvas) override { |
| 375 canvas->Save(); |
345 // Display the profile picture as a circle. | 376 // Display the profile picture as a circle. |
346 canvas->ClipPath(circular_mask_, true); | 377 canvas->ClipPath(circular_mask_, true); |
347 views::LabelButton::OnPaint(canvas); | 378 views::LabelButton::OnPaint(canvas); |
| 379 canvas->Restore(); |
348 } | 380 } |
349 | 381 |
350 void PaintChildren(const ui::PaintContext& context) override { | 382 void PaintChildren(const ui::PaintContext& context) override { |
351 // Display any children (the "change photo" overlay) as a circle. | 383 // Display any children (the "change photo" overlay) as a circle. |
352 ui::ClipRecorder clip_recorder(context); | 384 { |
353 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); | 385 ui::ClipRecorder clip_recorder(context); |
354 View::PaintChildren(context); | 386 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); |
| 387 View::PaintChildren(context); |
| 388 } |
| 389 |
| 390 ui::PaintRecorder paint_recorder( |
| 391 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); |
| 392 gfx::Canvas* canvas = paint_recorder.canvas(); |
| 393 if (profile_->IsSupervised()) { |
| 394 gfx::VectorIconId icon_id; |
| 395 size_t icon_size; |
| 396 // TODO(janeliulwq): Replace the following two profile badge icons when |
| 397 // new versions of them are ready, which be inverted as silhouettes. Also, |
| 398 // remove the code below for painting the background for the badges as |
| 399 // they won't be necessary. |
| 400 if (profile_->IsChild()) { |
| 401 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT; |
| 402 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26; |
| 403 } else { |
| 404 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT; |
| 405 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20; |
| 406 } |
| 407 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); |
| 408 |
| 409 int badge_offset = |
| 410 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); |
| 411 gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
| 412 badge_offset, |
| 413 badge_offset + (switches::IsMaterialDesignUserMenu() |
| 414 ? views::kRelatedControlSmallVerticalSpacing |
| 415 : 0)); |
| 416 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| 417 |
| 418 SkPaint paint; |
| 419 paint.setAntiAlias(true); |
| 420 paint.setColor(GetNativeTheme()->GetSystemColor( |
| 421 ui::NativeTheme::kColorId_BubbleBackground)); |
| 422 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); |
| 423 |
| 424 if (!switches::IsMaterialDesignUserMenu()) { |
| 425 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); |
| 426 canvas->DrawCircle( |
| 427 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, |
| 428 paint); |
| 429 } |
| 430 |
| 431 int offset = (GetProfileBadgeSize() - icon_size) / 2; |
| 432 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); |
| 433 const SkColor badge_color = switches::IsMaterialDesignUserMenu() |
| 434 ? gfx::kChromeIconGrey |
| 435 : SkColorSetRGB(0, 0x66, 0xff); |
| 436 gfx::PaintVectorIcon(canvas, icon_id, icon_size, badge_color); |
| 437 } |
| 438 } |
| 439 |
| 440 static int icon_image_side() { |
| 441 return switches::IsMaterialDesignUserMenu() ? kMdImageSide |
| 442 : kLargeImageSide; |
| 443 } |
| 444 |
| 445 static int badge_spacing() { |
| 446 // The space between the right/bottom edge of the profile badge and the |
| 447 // right/bottom edge of the profile icon. |
| 448 return switches::IsMaterialDesignUserMenu() ? 4 : 0; |
355 } | 449 } |
356 | 450 |
357 private: | 451 private: |
358 // views::CustomButton: | 452 // views::CustomButton: |
359 void StateChanged() override { | 453 void StateChanged() override { |
360 bool show_overlay = | 454 bool show_overlay = |
361 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); | 455 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); |
362 if (photo_overlay_) | 456 if (photo_overlay_) |
363 photo_overlay_->SetVisible(show_overlay); | 457 photo_overlay_->SetVisible(show_overlay); |
364 } | 458 } |
(...skipping 10 matching lines...) Expand all Loading... |
375 if (photo_overlay_ && state() != STATE_HOVERED) | 469 if (photo_overlay_ && state() != STATE_HOVERED) |
376 photo_overlay_->SetVisible(false); | 470 photo_overlay_->SetVisible(false); |
377 } | 471 } |
378 | 472 |
379 gfx::Path circular_mask_; | 473 gfx::Path circular_mask_; |
380 | 474 |
381 // Image that is shown when hovering over the image button. Can be NULL if | 475 // 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). | 476 // the photo isn't allowed to be edited (e.g. for guest profiles). |
383 views::ImageView* photo_overlay_; | 477 views::ImageView* photo_overlay_; |
384 | 478 |
| 479 Profile* profile_; |
| 480 |
385 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); | 481 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
386 }; | 482 }; |
387 | 483 |
388 // EditableProfileName ------------------------------------------------- | 484 // EditableProfileName ------------------------------------------------- |
389 | 485 |
390 // A custom text control that turns into a textfield for editing when clicked. | 486 // A custom text control that turns into a textfield for editing when clicked. |
391 class EditableProfileName : public views::View, | 487 class EditableProfileName : public views::View, |
392 public views::ButtonListener { | 488 public views::ButtonListener { |
393 public: | 489 public: |
394 EditableProfileName(views::TextfieldController* controller, | 490 EditableProfileName(views::TextfieldController* controller, |
395 const base::string16& text, | 491 const base::string16& text, |
396 bool is_editing_allowed) | 492 bool is_editing_allowed) |
397 : button_(nullptr), label_(nullptr), profile_name_textfield_(nullptr) { | 493 : button_(nullptr), profile_name_textfield_(nullptr) { |
398 SetLayoutManager( | 494 SetLayoutManager( |
399 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 495 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
400 | 496 |
401 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 497 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
402 const gfx::FontList& medium_font_list = | 498 const gfx::FontList& medium_font_list = |
403 rb->GetFontList(ui::ResourceBundle::MediumFont); | 499 rb->GetFontList(ui::ResourceBundle::MediumFont); |
| 500 const gfx::Insets textfield_border_insets = |
| 501 views::Textfield().border()->GetInsets(); |
404 | 502 |
405 if (!is_editing_allowed) { | 503 if (!is_editing_allowed) { |
406 label_ = new views::Label(text); | 504 views::Label* name_label = new views::Label(text); |
407 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); | 505 name_label->SetBorder( |
408 label_->SetFontList(medium_font_list); | 506 views::Border::CreateEmptyBorder(textfield_border_insets)); |
409 AddChildView(label_); | 507 name_label->SetFontList(medium_font_list); |
| 508 if (switches::IsMaterialDesignUserMenu()) |
| 509 name_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 510 AddChildView(name_label); |
410 return; | 511 return; |
411 } | 512 } |
412 | 513 |
| 514 profile_name_textfield_ = new views::Textfield(); |
| 515 // Textfield that overlaps the button. |
| 516 profile_name_textfield_->set_controller(controller); |
| 517 profile_name_textfield_->SetFontList(medium_font_list); |
| 518 profile_name_textfield_->SetHorizontalAlignment( |
| 519 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT |
| 520 : gfx::ALIGN_CENTER); |
| 521 profile_name_textfield_->SetVisible(false); |
| 522 AddChildView(profile_name_textfield_); |
| 523 |
413 button_ = new RightAlignedIconLabelButton(this, text); | 524 button_ = new RightAlignedIconLabelButton(this, text); |
414 button_->SetFontList(medium_font_list); | 525 button_->SetFontList(medium_font_list); |
415 // Show an "edit" pencil icon when hovering over. In the default state, | 526 // 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 | 527 // 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. | 528 // the text doesn't jump around when the hovered icon appears. |
418 // TODO(estade): revisit colors and press effect. | 529 // TODO(estade): revisit colors and press effect. |
419 const int kIconSize = 16; | 530 const int kIconSize = 16; |
420 button_->SetImage(views::LabelButton::STATE_NORMAL, | 531 button_->SetImage(views::LabelButton::STATE_NORMAL, |
421 CreateSquarePlaceholderImage(kIconSize)); | 532 CreateSquarePlaceholderImage(kIconSize)); |
422 button_->SetImage(views::LabelButton::STATE_HOVERED, | 533 button_->SetImage(views::LabelButton::STATE_HOVERED, |
423 gfx::CreateVectorIcon( | 534 gfx::CreateVectorIcon( |
424 gfx::VectorIconId::MODE_EDIT, kIconSize, | 535 gfx::VectorIconId::MODE_EDIT, kIconSize, |
425 SkColorSetRGB(0x33, 0x33, 0x33))); | 536 SkColorSetRGB(0x33, 0x33, 0x33))); |
426 button_->SetImage(views::LabelButton::STATE_PRESSED, | 537 button_->SetImage(views::LabelButton::STATE_PRESSED, |
427 gfx::CreateVectorIcon( | 538 gfx::CreateVectorIcon( |
428 gfx::VectorIconId::MODE_EDIT, kIconSize, | 539 gfx::VectorIconId::MODE_EDIT, kIconSize, |
429 SkColorSetRGB(0x20, 0x20, 0x20))); | 540 SkColorSetRGB(0x20, 0x20, 0x20))); |
430 // To center the text, we need to offest it by the width of the icon we | 541 // 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 | 542 // to the text to account for the textfield's border. |
432 // padding to account for the textfield's border. | 543 if (switches::IsMaterialDesignUserMenu()) { |
433 const int kIconTextLabelButtonSpacing = 5; | 544 button_->SetBorder(views::Border::CreateEmptyBorder( |
434 button_->SetBorder(views::Border::CreateEmptyBorder( | 545 textfield_border_insets + |
435 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); | 546 gfx::Insets(0, profile_name_textfield_->GetInsets().left(), 0, 0))); |
| 547 } else { |
| 548 const int kIconTextLabelButtonSpacing = 5; |
| 549 button_->SetBorder(views::Border::CreateEmptyBorder( |
| 550 textfield_border_insets + |
| 551 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); |
| 552 } |
436 AddChildView(button_); | 553 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 } | 554 } |
446 | 555 |
447 views::Textfield* profile_name_textfield() { | 556 views::Textfield* profile_name_textfield() { |
448 return profile_name_textfield_; | 557 return profile_name_textfield_; |
449 } | 558 } |
450 | 559 |
451 // Hide the editable textfield to show the profile name button instead. | 560 // Hide the editable textfield to show the profile name button instead. |
452 void ShowReadOnlyView() { | 561 void ShowReadOnlyView() { |
453 button_->SetVisible(true); | 562 button_->SetVisible(true); |
454 profile_name_textfield_->SetVisible(false); | 563 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 | 581 // 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. | 582 // part of the new profile name typed in the textfield. |
474 return false; | 583 return false; |
475 } | 584 } |
476 | 585 |
477 // The label button which shows the profile name, and can handle the event to | 586 // 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 | 587 // make it editable. Can be NULL if the profile name isn't allowed to be |
479 // edited. | 588 // edited. |
480 RightAlignedIconLabelButton* button_; | 589 RightAlignedIconLabelButton* button_; |
481 | 590 |
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 | 591 // 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). | 592 // the profile name isn't allowed to be edited (e.g. for guest profiles). |
488 views::Textfield* profile_name_textfield_; | 593 views::Textfield* profile_name_textfield_; |
489 | 594 |
490 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); | 595 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); |
491 }; | 596 }; |
492 | 597 |
493 // A title card with one back button right aligned and one label center aligned. | 598 // A title card with one back button right aligned and one label center aligned. |
494 class TitleCard : public views::View { | 599 class TitleCard : public views::View { |
495 public: | 600 public: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 back_button_->GetPreferredSize().height()); | 661 back_button_->GetPreferredSize().height()); |
557 return gfx::Size(width(), height); | 662 return gfx::Size(width(), height); |
558 } | 663 } |
559 | 664 |
560 views::ImageButton* back_button_; | 665 views::ImageButton* back_button_; |
561 views::Label* title_label_; | 666 views::Label* title_label_; |
562 | 667 |
563 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 668 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
564 }; | 669 }; |
565 | 670 |
566 // ProfileBadge -------------------------------------------------------- | |
567 | |
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. | |
572 class ProfileBadge : public gfx::CanvasImageSource { | |
573 public: | |
574 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | |
575 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | |
576 false), | |
577 id_(id), | |
578 icon_size_(icon_size) {} | |
579 | |
580 ~ProfileBadge() override {} | |
581 | |
582 // CanvasImageSource: | |
583 void Draw(gfx::Canvas* canvas) override { | |
584 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); | |
585 gfx::Rect bounds(0, 0, size.width(), size.height()); | |
586 | |
587 SkPaint paint; | |
588 paint.setAntiAlias(true); | |
589 paint.setColor(SK_ColorWHITE); | |
590 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | |
591 | |
592 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | |
593 canvas->DrawCircle(bounds.CenterPoint(), | |
594 size.width() / 2 - kProfileBadgeWhitePadding, paint); | |
595 | |
596 int offset = (kProfileBadgeSize - icon_size_) / 2; | |
597 canvas->Translate(gfx::Vector2d(offset, offset)); | |
598 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | |
599 } | |
600 | |
601 private: | |
602 const gfx::VectorIconId id_; | |
603 const size_t icon_size_; | |
604 | |
605 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | |
606 }; | |
607 | |
608 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | |
609 ProfileBadge* badge = | |
610 profile->IsChild() | |
611 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | |
612 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | |
613 | |
614 return gfx::ImageSkia(badge, badge->size()); | |
615 } | |
616 | |
617 // ProfileChooserView --------------------------------------------------------- | 671 // ProfileChooserView --------------------------------------------------------- |
618 | 672 |
619 // static | 673 // static |
620 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 674 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
621 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 675 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
622 | 676 |
623 // static | 677 // static |
624 void ProfileChooserView::ShowBubble( | 678 void ProfileChooserView::ShowBubble( |
625 profiles::BubbleViewMode view_mode, | 679 profiles::BubbleViewMode view_mode, |
626 profiles::TutorialMode tutorial_mode, | 680 profiles::TutorialMode tutorial_mode, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 745 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
692 if (oauth2_token_service) | 746 if (oauth2_token_service) |
693 oauth2_token_service->RemoveObserver(this); | 747 oauth2_token_service->RemoveObserver(this); |
694 } | 748 } |
695 | 749 |
696 void ProfileChooserView::ResetView() { | 750 void ProfileChooserView::ResetView() { |
697 open_other_profile_indexes_map_.clear(); | 751 open_other_profile_indexes_map_.clear(); |
698 delete_account_button_map_.clear(); | 752 delete_account_button_map_.clear(); |
699 reauth_account_button_map_.clear(); | 753 reauth_account_button_map_.clear(); |
700 manage_accounts_link_ = nullptr; | 754 manage_accounts_link_ = nullptr; |
701 signin_current_profile_link_ = nullptr; | 755 signin_current_profile_button_ = nullptr; |
702 auth_error_email_button_ = nullptr; | 756 auth_error_email_button_ = nullptr; |
703 current_profile_photo_ = nullptr; | 757 current_profile_photo_ = nullptr; |
704 current_profile_name_ = nullptr; | 758 current_profile_name_ = nullptr; |
705 guest_profile_button_ = nullptr; | 759 guest_profile_button_ = nullptr; |
706 users_button_ = nullptr; | 760 users_button_ = nullptr; |
707 go_incognito_button_ = nullptr; | 761 go_incognito_button_ = nullptr; |
708 lock_button_ = nullptr; | 762 lock_button_ = nullptr; |
709 close_all_windows_button_ = nullptr; | 763 close_all_windows_button_ = nullptr; |
710 add_account_link_ = nullptr; | 764 add_account_link_ = nullptr; |
711 gaia_signin_cancel_button_ = nullptr; | 765 gaia_signin_cancel_button_ = nullptr; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 break; | 892 break; |
839 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 893 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
840 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 894 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
841 sub_view = CreateSwitchUserView(); | 895 sub_view = CreateSwitchUserView(); |
842 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 896 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
843 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 897 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
844 break; | 898 break; |
845 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 899 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
846 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 900 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
847 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | 901 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
848 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 902 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
849 sub_view = CreateProfileChooserView(avatar_menu); | 903 sub_view = CreateProfileChooserView(avatar_menu); |
850 break; | 904 break; |
851 } | 905 } |
852 // Clears tutorial mode for all non-profile-chooser views. | 906 // Clears tutorial mode for all non-profile-chooser views. |
853 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 907 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
854 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 908 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
855 | 909 |
856 layout->StartRow(1, 0); | 910 layout->StartRow(1, 0); |
857 layout->AddView(sub_view); | 911 layout->AddView(sub_view); |
858 Layout(); | 912 Layout(); |
(...skipping 26 matching lines...) Expand all Loading... |
885 if (accelerator.key_code() != ui::VKEY_DOWN && | 939 if (accelerator.key_code() != ui::VKEY_DOWN && |
886 accelerator.key_code() != ui::VKEY_UP) | 940 accelerator.key_code() != ui::VKEY_UP) |
887 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); | 941 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); |
888 | 942 |
889 // Move the focus up or down. | 943 // Move the focus up or down. |
890 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); | 944 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
891 return true; | 945 return true; |
892 } | 946 } |
893 | 947 |
894 views::View* ProfileChooserView::GetInitiallyFocusedView() { | 948 views::View* ProfileChooserView::GetInitiallyFocusedView() { |
895 return signin_current_profile_link_; | 949 return signin_current_profile_button_; |
896 } | 950 } |
897 | 951 |
898 int ProfileChooserView::GetDialogButtons() const { | 952 int ProfileChooserView::GetDialogButtons() const { |
899 return ui::DIALOG_BUTTON_NONE; | 953 return ui::DIALOG_BUTTON_NONE; |
900 } | 954 } |
901 | 955 |
902 bool ProfileChooserView::HandleContextMenu( | 956 bool ProfileChooserView::HandleContextMenu( |
903 const content::ContextMenuParams& params) { | 957 const content::ContextMenuParams& params) { |
904 // Suppresses the context menu because some features, such as inspecting | 958 // Suppresses the context menu because some features, such as inspecting |
905 // elements, are not appropriate in a bubble. | 959 // 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 = | 1015 bool account_management_available = |
962 SigninManagerFactory::GetForProfile(browser_->profile())-> | 1016 SigninManagerFactory::GetForProfile(browser_->profile())-> |
963 IsAuthenticated() && | 1017 IsAuthenticated() && |
964 switches::IsEnableAccountConsistency(); | 1018 switches::IsEnableAccountConsistency(); |
965 ShowViewFromMode(account_management_available ? | 1019 ShowViewFromMode(account_management_available ? |
966 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 1020 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
967 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 1021 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
968 } else if (sender == current_profile_photo_) { | 1022 } else if (sender == current_profile_photo_) { |
969 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 1023 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
970 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 1024 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
971 } else if (sender == signin_current_profile_link_) { | 1025 } else if (sender == signin_current_profile_button_) { |
972 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 1026 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
973 } else if (sender == add_person_button_) { | 1027 } else if (sender == add_person_button_) { |
974 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1028 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
975 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 1029 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
976 UserManager::Show(base::FilePath(), | 1030 UserManager::Show(base::FilePath(), |
977 profiles::USER_MANAGER_NO_TUTORIAL, | 1031 profiles::USER_MANAGER_NO_TUTORIAL, |
978 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1032 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
979 } else if (sender == disconnect_button_) { | 1033 } else if (sender == disconnect_button_) { |
980 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 1034 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
981 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 1035 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; | 1153 views::View* tutorial_view = NULL; |
1100 views::View* current_profile_view = NULL; | 1154 views::View* current_profile_view = NULL; |
1101 views::View* current_profile_accounts = NULL; | 1155 views::View* current_profile_accounts = NULL; |
1102 views::View* option_buttons_view = NULL; | 1156 views::View* option_buttons_view = NULL; |
1103 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1157 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1104 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1158 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1105 if (item.active) { | 1159 if (item.active) { |
1106 option_buttons_view = CreateOptionsView( | 1160 option_buttons_view = CreateOptionsView( |
1107 item.signed_in && profiles::IsLockAvailable(browser_->profile()), | 1161 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
1108 avatar_menu); | 1162 avatar_menu); |
1109 current_profile_view = CreateCurrentProfileView(item, false); | 1163 current_profile_view = |
| 1164 switches::IsMaterialDesignUserMenu() |
| 1165 ? CreateMaterialDesignCurrentProfileView(item, false) |
| 1166 : CreateCurrentProfileView(item, false); |
1110 if (IsProfileChooser(view_mode_)) { | 1167 if (IsProfileChooser(view_mode_)) { |
1111 tutorial_view = CreateTutorialViewIfNeeded(item); | 1168 tutorial_view = CreateTutorialViewIfNeeded(item); |
1112 } else { | 1169 } else { |
1113 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1170 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1114 } | 1171 } |
1115 } else { | 1172 } else { |
1116 other_profiles.push_back(i); | 1173 other_profiles.push_back(i); |
1117 } | 1174 } |
1118 } | 1175 } |
1119 | 1176 |
(...skipping 16 matching lines...) Expand all Loading... |
1136 | 1193 |
1137 if (!IsProfileChooser(view_mode_)) { | 1194 if (!IsProfileChooser(view_mode_)) { |
1138 DCHECK(current_profile_accounts); | 1195 DCHECK(current_profile_accounts); |
1139 layout->StartRow(0, 0); | 1196 layout->StartRow(0, 0); |
1140 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1197 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1141 layout->StartRow(1, 0); | 1198 layout->StartRow(1, 0); |
1142 layout->AddView(current_profile_accounts); | 1199 layout->AddView(current_profile_accounts); |
1143 } | 1200 } |
1144 | 1201 |
1145 if (browser_->profile()->IsSupervised()) { | 1202 if (browser_->profile()->IsSupervised()) { |
1146 layout->StartRow(0, 0); | 1203 if (!switches::IsMaterialDesignUserMenu()) { |
1147 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1204 layout->StartRow(0, 0); |
| 1205 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
| 1206 } |
1148 layout->StartRow(1, 0); | 1207 layout->StartRow(1, 0); |
1149 layout->AddView(CreateSupervisedUserDisclaimerView()); | 1208 layout->AddView(CreateSupervisedUserDisclaimerView()); |
1150 } | 1209 } |
1151 | 1210 |
1152 layout->StartRow(0, 0); | 1211 layout->StartRow(0, 0); |
1153 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1212 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1154 | 1213 |
1155 if (option_buttons_view) { | 1214 if (option_buttons_view) { |
1156 layout->StartRow(0, 0); | 1215 layout->StartRow(0, 0); |
1157 layout->AddView(option_buttons_view); | 1216 layout->AddView(option_buttons_view); |
(...skipping 11 matching lines...) Expand all Loading... |
1169 } | 1228 } |
1170 } | 1229 } |
1171 | 1230 |
1172 layout->StartRow(1, 0); | 1231 layout->StartRow(1, 0); |
1173 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1232 layout->AddView(CreateOtherProfilesView(other_profiles)); |
1174 } | 1233 } |
1175 | 1234 |
1176 views::View* ProfileChooserView::CreateProfileChooserView( | 1235 views::View* ProfileChooserView::CreateProfileChooserView( |
1177 AvatarMenu* avatar_menu) { | 1236 AvatarMenu* avatar_menu) { |
1178 views::View* view = new views::View(); | 1237 views::View* view = new views::View(); |
1179 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1238 views::GridLayout* layout = |
| 1239 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
1180 | 1240 |
1181 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | 1241 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
1182 PopulateMinimalProfileChooserView(layout, avatar_menu); | 1242 PopulateMinimalProfileChooserView(layout, avatar_menu); |
1183 // The user is using right-click switching, no need to tell them about it. | 1243 // The user is using right-click switching, no need to tell them about it. |
1184 PrefService* local_state = g_browser_process->local_state(); | 1244 PrefService* local_state = g_browser_process->local_state(); |
1185 local_state->SetBoolean( | 1245 local_state->SetBoolean( |
1186 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1246 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1187 } else { | 1247 } else { |
1188 PopulateCompleteProfileChooserView(layout, avatar_menu); | 1248 PopulateCompleteProfileChooserView(layout, avatar_menu); |
1189 } | 1249 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 const base::string16& button_text, | 1304 const base::string16& button_text, |
1245 bool stack_button, | 1305 bool stack_button, |
1246 views::Link** link, | 1306 views::Link** link, |
1247 views::LabelButton** button, | 1307 views::LabelButton** button, |
1248 views::ImageButton** close_button) { | 1308 views::ImageButton** close_button) { |
1249 tutorial_mode_ = tutorial_mode; | 1309 tutorial_mode_ = tutorial_mode; |
1250 | 1310 |
1251 views::View* view = new views::View(); | 1311 views::View* view = new views::View(); |
1252 view->set_background(views::Background::CreateSolidBackground( | 1312 view->set_background(views::Background::CreateSolidBackground( |
1253 profiles::kAvatarTutorialBackgroundColor)); | 1313 profiles::kAvatarTutorialBackgroundColor)); |
1254 views::GridLayout* layout = CreateSingleColumnLayout(view, | 1314 views::GridLayout* layout = CreateSingleColumnLayout( |
1255 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1315 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1256 // Creates a second column set for buttons and links. | 1316 // Creates a second column set for buttons and links. |
1257 views::ColumnSet* button_columns = layout->AddColumnSet(1); | 1317 views::ColumnSet* button_columns = layout->AddColumnSet(1); |
1258 button_columns->AddColumn(views::GridLayout::LEADING, | 1318 button_columns->AddColumn(views::GridLayout::LEADING, |
1259 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1319 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1260 button_columns->AddPaddingColumn( | 1320 button_columns->AddPaddingColumn( |
1261 1, views::kUnrelatedControlHorizontalSpacing); | 1321 1, views::kUnrelatedControlHorizontalSpacing); |
1262 button_columns->AddColumn(views::GridLayout::TRAILING, | 1322 button_columns->AddColumn(views::GridLayout::TRAILING, |
1263 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 1323 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
1264 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1324 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1265 views::kButtonHEdgeMarginNew, | 1325 views::kButtonHEdgeMarginNew, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 layout->SkipColumns(1); | 1407 layout->SkipColumns(1); |
1348 } | 1408 } |
1349 | 1409 |
1350 return view; | 1410 return view; |
1351 } | 1411 } |
1352 | 1412 |
1353 views::View* ProfileChooserView::CreateCurrentProfileView( | 1413 views::View* ProfileChooserView::CreateCurrentProfileView( |
1354 const AvatarMenu::Item& avatar_item, | 1414 const AvatarMenu::Item& avatar_item, |
1355 bool is_guest) { | 1415 bool is_guest) { |
1356 views::View* view = new views::View(); | 1416 views::View* view = new views::View(); |
1357 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1417 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
1358 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1418 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
1359 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1419 layout->SetInsets(views::kButtonVEdgeMarginNew, |
1360 views::kButtonHEdgeMarginNew, | 1420 views::kButtonHEdgeMarginNew, |
1361 views::kUnrelatedControlVerticalSpacing, | 1421 views::kUnrelatedControlVerticalSpacing, |
1362 views::kButtonHEdgeMarginNew); | 1422 views::kButtonHEdgeMarginNew); |
1363 | 1423 |
1364 // Profile icon, centered. | 1424 // Profile icon, centered. |
1365 int x_offset = (column_width - kLargeImageSide) / 2; | 1425 int x_offset = (column_width - kLargeImageSide) / 2; |
1366 current_profile_photo_ = new EditableProfilePhoto( | 1426 current_profile_photo_ = new EditableProfilePhoto( |
1367 this, avatar_item.icon, !is_guest, | 1427 this, avatar_item.icon, !is_guest, browser_->profile()); |
1368 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); | 1428 current_profile_photo_->SetX(x_offset); |
1369 SizedContainer* profile_icon_container = | 1429 SizedContainer* profile_icon_container = |
1370 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | 1430 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
1371 profile_icon_container->AddChildView(current_profile_photo_); | 1431 profile_icon_container->AddChildView(current_profile_photo_); |
1372 | 1432 |
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 | 1433 |
1386 layout->StartRow(1, 0); | 1434 layout->StartRow(1, 0); |
1387 layout->AddView(profile_icon_container); | 1435 layout->AddView(profile_icon_container); |
1388 | 1436 |
1389 // Profile name, centered. | 1437 // Profile name, centered. |
1390 bool editing_allowed = !is_guest && | 1438 bool editing_allowed = !is_guest && |
1391 !browser_->profile()->IsLegacySupervised(); | 1439 !browser_->profile()->IsLegacySupervised(); |
1392 current_profile_name_ = new EditableProfileName( | 1440 current_profile_name_ = new EditableProfileName( |
1393 this, | 1441 this, |
1394 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), | 1442 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 if (signin_manager->IsSigninAllowed()) { | 1493 if (signin_manager->IsSigninAllowed()) { |
1446 views::Label* promo = new views::Label( | 1494 views::Label* promo = new views::Label( |
1447 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); | 1495 l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
1448 promo->SetMultiLine(true); | 1496 promo->SetMultiLine(true); |
1449 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1497 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1450 layout->StartRowWithPadding(1, 0, 0, | 1498 layout->StartRowWithPadding(1, 0, 0, |
1451 views::kRelatedControlSmallVerticalSpacing); | 1499 views::kRelatedControlSmallVerticalSpacing); |
1452 layout->StartRow(1, 0); | 1500 layout->StartRow(1, 0); |
1453 layout->AddView(promo); | 1501 layout->AddView(promo); |
1454 | 1502 |
1455 signin_current_profile_link_ = new views::BlueButton( | 1503 signin_current_profile_button_ = new views::BlueButton( |
1456 this, l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 1504 this, l10n_util::GetStringFUTF16( |
1457 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 1505 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| 1506 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
1458 layout->StartRowWithPadding(1, 0, 0, | 1507 layout->StartRowWithPadding(1, 0, 0, |
1459 views::kRelatedControlVerticalSpacing); | 1508 views::kRelatedControlVerticalSpacing); |
1460 layout->StartRow(1, 0); | 1509 layout->StartRow(1, 0); |
1461 layout->AddView(signin_current_profile_link_); | 1510 layout->AddView(signin_current_profile_button_); |
1462 content::RecordAction( | 1511 content::RecordAction( |
1463 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); | 1512 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
1464 } | 1513 } |
1465 } | 1514 } |
1466 | 1515 |
1467 return view; | 1516 return view; |
1468 } | 1517 } |
1469 | 1518 |
| 1519 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| 1520 const AvatarMenu::Item& avatar_item, |
| 1521 bool is_guest) { |
| 1522 views::View* view = new views::View(); |
| 1523 view->SetLayoutManager( |
| 1524 new views::BoxLayout(views::BoxLayout::kVertical, kMaterialMenuEdgeMargin, |
| 1525 views::kRelatedControlVerticalSpacing, |
| 1526 views::kRelatedControlVerticalSpacing)); |
| 1527 |
| 1528 // Profile container for the profile photo and avatar/user name. |
| 1529 views::View* profile_container = new views::View(); |
| 1530 |
| 1531 // Profile picture, left-aligned. |
| 1532 current_profile_photo_ = new EditableProfilePhoto( |
| 1533 this, avatar_item.icon, !is_guest, browser_->profile()); |
| 1534 |
| 1535 // Profile name, left-aligned to the right of profile icon. |
| 1536 bool editing_allowed = |
| 1537 !is_guest && !browser_->profile()->IsLegacySupervised(); |
| 1538 current_profile_name_ = new EditableProfileName( |
| 1539 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), |
| 1540 editing_allowed); |
| 1541 views::View* profile_name_container = new views::View(); |
| 1542 int name_container_v_spacing = views::kRelatedControlSmallVerticalSpacing; |
| 1543 if (!avatar_item.signed_in) |
| 1544 name_container_v_spacing += views::kRelatedControlVerticalSpacing; |
| 1545 profile_name_container->SetLayoutManager(new views::BoxLayout( |
| 1546 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0)); |
| 1547 profile_name_container->AddChildView(current_profile_name_); |
| 1548 |
| 1549 const int between_child_spacing = |
| 1550 kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); |
| 1551 profile_container->SetLayoutManager(new views::BoxLayout( |
| 1552 views::BoxLayout::kHorizontal, 0, |
| 1553 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); |
| 1554 profile_container->AddChildView(current_profile_photo_); |
| 1555 profile_container->AddChildView(profile_name_container); |
| 1556 view->AddChildView(profile_container); |
| 1557 |
| 1558 if (is_guest) |
| 1559 return view; |
| 1560 |
| 1561 // The available links depend on the type of profile that is active. |
| 1562 if (avatar_item.signed_in) { |
| 1563 if (switches::IsEnableAccountConsistency()) { |
| 1564 base::string16 link_title = l10n_util::GetStringUTF16( |
| 1565 IsProfileChooser(view_mode_) |
| 1566 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON |
| 1567 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); |
| 1568 manage_accounts_link_ = CreateLink(link_title, this); |
| 1569 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1570 profile_name_container->AddChildView(manage_accounts_link_); |
| 1571 } else { |
| 1572 views::Label* email_label = new views::Label(avatar_item.username); |
| 1573 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); |
| 1574 email_label->SetEnabled(false); |
| 1575 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1576 profile_name_container->AddChildView(email_label); |
| 1577 } |
| 1578 return view; |
| 1579 } |
| 1580 |
| 1581 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( |
| 1582 browser_->profile()->GetOriginalProfile()); |
| 1583 if (signin_manager->IsSigninAllowed()) { |
| 1584 views::Label* promo = |
| 1585 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
| 1586 promo->SetMultiLine(true); |
| 1587 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1588 view->AddChildView(promo); |
| 1589 |
| 1590 signin_current_profile_button_ = |
| 1591 views::MdTextButton::CreateSecondaryUiBlueButton( |
| 1592 this, l10n_util::GetStringFUTF16( |
| 1593 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| 1594 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 1595 view->AddChildView(signin_current_profile_button_); |
| 1596 content::RecordAction( |
| 1597 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
| 1598 view->SetBorder(views::Border::CreateEmptyBorder( |
| 1599 0, 0, views::kRelatedControlVerticalSpacing, 0)); |
| 1600 } |
| 1601 |
| 1602 return view; |
| 1603 } |
| 1604 |
1470 views::View* ProfileChooserView::CreateGuestProfileView() { | 1605 views::View* ProfileChooserView::CreateGuestProfileView() { |
1471 gfx::Image guest_icon = | 1606 gfx::Image guest_icon = |
1472 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1607 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
1473 profiles::GetPlaceholderAvatarIconResourceID()); | 1608 profiles::GetPlaceholderAvatarIconResourceID()); |
1474 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); | 1609 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); |
1475 guest_avatar_item.active = true; | 1610 guest_avatar_item.active = true; |
1476 guest_avatar_item.name = l10n_util::GetStringUTF16( | 1611 guest_avatar_item.name = l10n_util::GetStringUTF16( |
1477 IDS_PROFILES_GUEST_PROFILE_NAME); | 1612 IDS_PROFILES_GUEST_PROFILE_NAME); |
1478 guest_avatar_item.signed_in = false; | 1613 guest_avatar_item.signed_in = false; |
1479 | 1614 |
1480 return CreateCurrentProfileView(guest_avatar_item, true); | 1615 return switches::IsMaterialDesignUserMenu() |
| 1616 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) |
| 1617 : CreateCurrentProfileView(guest_avatar_item, true); |
1481 } | 1618 } |
1482 | 1619 |
1483 views::View* ProfileChooserView::CreateOtherProfilesView( | 1620 views::View* ProfileChooserView::CreateOtherProfilesView( |
1484 const Indexes& avatars_to_show) { | 1621 const Indexes& avatars_to_show) { |
1485 views::View* view = new views::View(); | 1622 views::View* view = new views::View(); |
1486 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1623 views::GridLayout* layout = |
| 1624 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
1487 | 1625 |
1488 for (size_t index : avatars_to_show) { | 1626 for (size_t index : avatars_to_show) { |
1489 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); | 1627 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
1490 const int kSmallImageSide = 32; | 1628 const int kSmallImageSide = 32; |
1491 | 1629 |
1492 // Use the low-res, small default avatars in the fast user switcher, like | 1630 // Use the low-res, small default avatars in the fast user switcher, like |
1493 // we do in the menu bar. | 1631 // we do in the menu bar. |
1494 gfx::Image item_icon; | 1632 gfx::Image item_icon; |
1495 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); | 1633 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); |
1496 | 1634 |
(...skipping 11 matching lines...) Expand all Loading... |
1508 layout->StartRow(1, 0); | 1646 layout->StartRow(1, 0); |
1509 layout->AddView(button); | 1647 layout->AddView(button); |
1510 } | 1648 } |
1511 | 1649 |
1512 return view; | 1650 return view; |
1513 } | 1651 } |
1514 | 1652 |
1515 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, | 1653 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
1516 AvatarMenu* avatar_menu) { | 1654 AvatarMenu* avatar_menu) { |
1517 views::View* view = new views::View(); | 1655 views::View* view = new views::View(); |
1518 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1656 views::GridLayout* layout = |
| 1657 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
1519 | 1658 |
1520 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; | 1659 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; |
1521 if (switches::IsMaterialDesignUserMenu()) { | 1660 if (switches::IsMaterialDesignUserMenu()) { |
1522 // Add the user switching buttons | 1661 // Add the user switching buttons |
1523 const int kProfileIconSize = 18; | 1662 const int kProfileIconSize = 18; |
1524 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1663 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1525 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1664 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1526 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1665 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1527 if (!item.active) { | 1666 if (!item.active) { |
1528 gfx::Image image = profiles::GetSizedAvatarIcon( | 1667 gfx::Image image = profiles::GetSizedAvatarIcon( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 } | 1753 } |
1615 | 1754 |
1616 if (switches::IsMaterialDesignUserMenu()) | 1755 if (switches::IsMaterialDesignUserMenu()) |
1617 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1756 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1618 return view; | 1757 return view; |
1619 } | 1758 } |
1620 | 1759 |
1621 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1760 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1622 views::View* view = new views::View(); | 1761 views::View* view = new views::View(); |
1623 views::GridLayout* layout = CreateSingleColumnLayout( | 1762 views::GridLayout* layout = CreateSingleColumnLayout( |
1624 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1763 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
1625 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1764 if (switches::IsMaterialDesignUserMenu()) { |
1626 views::kButtonHEdgeMarginNew, | 1765 layout->SetInsets(0, kMaterialMenuEdgeMargin, kMaterialMenuEdgeMargin, |
1627 views::kRelatedControlVerticalSpacing, | 1766 kMaterialMenuEdgeMargin); |
1628 views::kButtonHEdgeMarginNew); | 1767 } else { |
| 1768 layout->SetInsets( |
| 1769 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, |
| 1770 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); |
| 1771 } |
| 1772 |
1629 views::Label* disclaimer = new views::Label( | 1773 views::Label* disclaimer = new views::Label( |
1630 avatar_menu_->GetSupervisedUserInformation()); | 1774 avatar_menu_->GetSupervisedUserInformation()); |
1631 disclaimer->SetMultiLine(true); | 1775 disclaimer->SetMultiLine(true); |
1632 disclaimer->SetAllowCharacterBreak(true); | 1776 disclaimer->SetAllowCharacterBreak(true); |
1633 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1777 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1634 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1778 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1635 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); | 1779 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); |
1636 layout->StartRow(1, 0); | 1780 layout->StartRow(1, 0); |
1637 layout->AddView(disclaimer); | 1781 layout->AddView(disclaimer); |
1638 | 1782 |
1639 return view; | 1783 return view; |
1640 } | 1784 } |
1641 | 1785 |
1642 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( | 1786 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
1643 const AvatarMenu::Item& avatar_item) { | 1787 const AvatarMenu::Item& avatar_item) { |
1644 DCHECK(avatar_item.signed_in); | 1788 DCHECK(avatar_item.signed_in); |
1645 views::View* view = new views::View(); | 1789 views::View* view = new views::View(); |
1646 view->set_background(views::Background::CreateSolidBackground( | 1790 view->set_background(views::Background::CreateSolidBackground( |
1647 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1791 profiles::kAvatarBubbleAccountsBackgroundColor)); |
1648 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1792 views::GridLayout* layout = |
| 1793 CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
1649 | 1794 |
1650 Profile* profile = browser_->profile(); | 1795 Profile* profile = browser_->profile(); |
1651 std::string primary_account = | 1796 std::string primary_account = |
1652 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); | 1797 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
1653 DCHECK(!primary_account.empty()); | 1798 DCHECK(!primary_account.empty()); |
1654 std::vector<std::string>accounts = | 1799 std::vector<std::string>accounts = |
1655 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1800 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
1656 | 1801 |
1657 // Get state of authentication error, if any. | 1802 // Get state of authentication error, if any. |
1658 std::string error_account_id = GetAuthErrorAccountId(profile); | 1803 std::string error_account_id = GetAuthErrorAccountId(profile); |
1659 | 1804 |
1660 // The primary account should always be listed first. | 1805 // The primary account should always be listed first. |
1661 // TODO(rogerta): we still need to further differentiate the primary account | 1806 // 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: | 1807 // from the others in the UI, so more work is likely required here: |
1663 // crbug.com/311124. | 1808 // crbug.com/311124. |
1664 CreateAccountButton(layout, primary_account, true, | 1809 CreateAccountButton(layout, primary_account, true, |
1665 error_account_id == primary_account, kFixedMenuWidth); | 1810 error_account_id == primary_account, GetFixedMenuWidth()); |
1666 for (size_t i = 0; i < accounts.size(); ++i) | 1811 for (size_t i = 0; i < accounts.size(); ++i) |
1667 CreateAccountButton(layout, accounts[i], false, | 1812 CreateAccountButton(layout, accounts[i], false, |
1668 error_account_id == accounts[i], kFixedMenuWidth); | 1813 error_account_id == accounts[i], GetFixedMenuWidth()); |
1669 | 1814 |
1670 if (!profile->IsSupervised()) { | 1815 if (!profile->IsSupervised()) { |
1671 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1816 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1672 | 1817 |
1673 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1818 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
1674 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1819 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
1675 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1820 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
1676 0, views::kButtonVEdgeMarginNew, | 1821 0, views::kButtonVEdgeMarginNew, |
1677 views::kRelatedControlVerticalSpacing, 0)); | 1822 views::kRelatedControlVerticalSpacing, 0)); |
1678 layout->StartRow(1, 0); | 1823 layout->StartRow(1, 0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2113 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1969 IncognitoModePrefs::DISABLED; | 2114 IncognitoModePrefs::DISABLED; |
1970 return incognito_available && !browser_->profile()->IsGuestSession(); | 2115 return incognito_available && !browser_->profile()->IsGuestSession(); |
1971 } | 2116 } |
1972 | 2117 |
1973 void ProfileChooserView::PostActionPerformed( | 2118 void ProfileChooserView::PostActionPerformed( |
1974 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2119 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1975 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2120 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1976 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2121 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1977 } | 2122 } |
OLD | NEW |