| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 void OnPaint(gfx::Canvas* canvas) override { | 403 void OnPaint(gfx::Canvas* canvas) override { |
| 404 canvas->Save(); | 404 canvas->Save(); |
| 405 // Display the profile picture as a circle. | 405 // Display the profile picture as a circle. |
| 406 canvas->ClipPath(circular_mask_, true); | 406 canvas->ClipPath(circular_mask_, true); |
| 407 views::LabelButton::OnPaint(canvas); | 407 views::LabelButton::OnPaint(canvas); |
| 408 canvas->Restore(); | 408 canvas->Restore(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void PaintChildren(const ui::PaintContext& context) override { | 411 void PaintChildren(const ui::PaintContext& context) override { |
| 412 // Display any children (the "change photo" overlay) as a circle. | |
| 413 { | 412 { |
| 413 // Display any children (the "change photo" overlay) as a circle. |
| 414 ui::ClipRecorder clip_recorder(context); | 414 ui::ClipRecorder clip_recorder(context); |
| 415 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); | 415 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); |
| 416 View::PaintChildren(context); | 416 View::PaintChildren(context); |
| 417 } | 417 } |
| 418 | 418 |
| 419 ui::PaintRecorder paint_recorder( | 419 ui::PaintRecorder paint_recorder( |
| 420 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); | 420 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); |
| 421 gfx::Canvas* canvas = paint_recorder.canvas(); | 421 gfx::Canvas* canvas = paint_recorder.canvas(); |
| 422 if (profile_->IsSupervised()) { | 422 if (profile_->IsSupervised()) { |
| 423 gfx::VectorIconId icon_id; | |
| 424 size_t icon_size; | |
| 425 // TODO(janeliulwq): Replace the following two profile badge icons when | |
| 426 // new versions of them are ready, which be inverted as silhouettes. Also, | |
| 427 // remove the code below for painting the background for the badges as | |
| 428 // they won't be necessary. | |
| 429 if (profile_->IsChild()) { | |
| 430 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT; | |
| 431 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26; | |
| 432 } else { | |
| 433 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
| 434 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20; | |
| 435 } | |
| 436 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); | 423 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); |
| 437 | |
| 438 int badge_offset = | 424 int badge_offset = |
| 439 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); | 425 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); |
| 440 gfx::Vector2d badge_offset_vector = gfx::Vector2d( | 426 gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
| 441 badge_offset, | 427 badge_offset, |
| 442 badge_offset + (switches::IsMaterialDesignUserMenu() | 428 badge_offset + (switches::IsMaterialDesignUserMenu() |
| 443 ? views::kRelatedControlSmallVerticalSpacing | 429 ? views::kRelatedControlSmallVerticalSpacing |
| 444 : 0)); | 430 : 0)); |
| 445 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | 431 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| 446 | 432 |
| 433 // Paint the circular background. |
| 447 SkPaint paint; | 434 SkPaint paint; |
| 448 paint.setAntiAlias(true); | 435 paint.setAntiAlias(true); |
| 449 paint.setColor(GetNativeTheme()->GetSystemColor( | 436 paint.setColor(GetNativeTheme()->GetSystemColor( |
| 450 ui::NativeTheme::kColorId_BubbleBackground)); | 437 ui::NativeTheme::kColorId_BubbleBackground)); |
| 451 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); | 438 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); |
| 452 | 439 |
| 453 if (!switches::IsMaterialDesignUserMenu()) { | 440 gfx::VectorIconId icon_id; |
| 441 size_t icon_size; |
| 442 SkColor icon_color; |
| 443 if (switches::IsMaterialDesignUserMenu()) { |
| 444 icon_id = profile_->IsChild() |
| 445 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE |
| 446 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; |
| 447 icon_size = 22; |
| 448 icon_color = gfx::kChromeIconGrey; |
| 449 } else { |
| 450 // Paint the light blue circle. |
| 454 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); | 451 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); |
| 455 canvas->DrawCircle( | 452 canvas->DrawCircle( |
| 456 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | 453 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, |
| 457 paint); | 454 paint); |
| 455 |
| 456 icon_id = profile_->IsChild() |
| 457 ? gfx::VectorIconId::ACCOUNT_CHILD |
| 458 : gfx::VectorIconId::SUPERVISOR_ACCOUNT; |
| 459 icon_size = profile_->IsChild() ? 26 : 20; |
| 460 icon_color = SkColorSetRGB(0, 0x66, 0xff); |
| 458 } | 461 } |
| 459 | 462 |
| 463 // Paint the badge icon. |
| 460 int offset = (GetProfileBadgeSize() - icon_size) / 2; | 464 int offset = (GetProfileBadgeSize() - icon_size) / 2; |
| 461 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); | 465 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); |
| 462 const SkColor badge_color = switches::IsMaterialDesignUserMenu() | 466 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color); |
| 463 ? gfx::kChromeIconGrey | |
| 464 : SkColorSetRGB(0, 0x66, 0xff); | |
| 465 gfx::PaintVectorIcon(canvas, icon_id, icon_size, badge_color); | |
| 466 } | 467 } |
| 467 } | 468 } |
| 468 | 469 |
| 469 static int icon_image_side() { | 470 static int icon_image_side() { |
| 470 return switches::IsMaterialDesignUserMenu() ? kMdImageSide | 471 return switches::IsMaterialDesignUserMenu() ? kMdImageSide |
| 471 : kLargeImageSide; | 472 : kLargeImageSide; |
| 472 } | 473 } |
| 473 | 474 |
| 474 static int badge_spacing() { | 475 static int badge_spacing() { |
| 475 // The space between the right/bottom edge of the profile badge and the | 476 // The space between the right/bottom edge of the profile badge and the |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2299 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2299 IncognitoModePrefs::DISABLED; | 2300 IncognitoModePrefs::DISABLED; |
| 2300 return incognito_available && !browser_->profile()->IsGuestSession(); | 2301 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2301 } | 2302 } |
| 2302 | 2303 |
| 2303 void ProfileChooserView::PostActionPerformed( | 2304 void ProfileChooserView::PostActionPerformed( |
| 2304 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2305 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2305 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2306 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2306 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2307 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2307 } | 2308 } |
| OLD | NEW |