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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 #include "components/signin/core/browser/signin_header_helper.h" | 39 #include "components/signin/core/browser/signin_header_helper.h" |
40 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/signin/core/browser/signin_manager.h" |
41 #include "components/signin/core/common/profile_management_switches.h" | 41 #include "components/signin/core/common/profile_management_switches.h" |
42 #include "content/public/browser/render_widget_host_view.h" | 42 #include "content/public/browser/render_widget_host_view.h" |
43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
44 #include "third_party/skia/include/core/SkColor.h" | 44 #include "third_party/skia/include/core/SkColor.h" |
45 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
46 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
47 #include "ui/compositor/clip_transform_recorder.h" | 47 #include "ui/compositor/clip_transform_recorder.h" |
48 #include "ui/gfx/canvas.h" | 48 #include "ui/gfx/canvas.h" |
49 #include "ui/gfx/image/canvas_image_source.h" | |
49 #include "ui/gfx/image/image.h" | 50 #include "ui/gfx/image/image.h" |
50 #include "ui/gfx/image/image_skia.h" | 51 #include "ui/gfx/image/image_skia.h" |
51 #include "ui/gfx/paint_vector_icon.h" | 52 #include "ui/gfx/paint_vector_icon.h" |
52 #include "ui/gfx/path.h" | 53 #include "ui/gfx/path.h" |
53 #include "ui/gfx/skia_util.h" | 54 #include "ui/gfx/skia_util.h" |
54 #include "ui/gfx/text_elider.h" | 55 #include "ui/gfx/text_elider.h" |
55 #include "ui/gfx/vector_icons_public2.h" | 56 #include "ui/gfx/vector_icons_public2.h" |
56 #include "ui/native_theme/native_theme.h" | 57 #include "ui/native_theme/native_theme.h" |
57 #include "ui/views/controls/button/blue_button.h" | 58 #include "ui/views/controls/button/blue_button.h" |
58 #include "ui/views/controls/button/image_button.h" | 59 #include "ui/views/controls/button/image_button.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 back_button_->GetPreferredSize().height()); | 468 back_button_->GetPreferredSize().height()); |
468 return gfx::Size(width(), height); | 469 return gfx::Size(width(), height); |
469 } | 470 } |
470 | 471 |
471 views::ImageButton* back_button_; | 472 views::ImageButton* back_button_; |
472 views::Label* title_label_; | 473 views::Label* title_label_; |
473 | 474 |
474 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 475 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
475 }; | 476 }; |
476 | 477 |
478 // ProfileBadge -------------------------------------------------------- | |
479 | |
480 const size_t kProfileBadgeSize = 30; | |
481 const size_t kProfileBadgeWhitePadding = 2; | |
482 | |
483 // Draws a white circle, then a light blue circle, then a dark blue icon. | |
484 class ProfileBadge : public gfx::CanvasImageSource { | |
Evan Stade
2015/07/24 22:51:15
Depending on how much of this kind of customizatio
| |
485 public: | |
486 ProfileBadge(gfx::VectorIconId id, size_t icon_size) | |
487 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), | |
488 false), | |
489 id_(id), | |
490 icon_size_(icon_size) {} | |
491 | |
492 ~ProfileBadge() override {} | |
493 | |
494 // CanvasImageSource: | |
495 void Draw(gfx::Canvas* canvas) override { | |
496 const SkISize size = canvas->sk_canvas()->getDeviceSize(); | |
497 gfx::Rect bounds(0, 0, size.width(), size.height()); | |
498 | |
499 SkPaint paint; | |
500 paint.setAntiAlias(true); | |
501 paint.setColor(SK_ColorWHITE); | |
502 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); | |
503 | |
504 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); | |
505 canvas->DrawCircle(bounds.CenterPoint(), | |
506 size.width() / 2 - kProfileBadgeWhitePadding, paint); | |
507 | |
508 int offset = (kProfileBadgeSize - icon_size_) / 2; | |
509 canvas->Translate(gfx::Vector2d(offset, offset)); | |
510 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); | |
511 } | |
512 | |
513 private: | |
514 const gfx::VectorIconId id_; | |
515 const size_t icon_size_; | |
516 | |
517 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); | |
518 }; | |
519 | |
520 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { | |
521 ProfileBadge* badge; | |
522 if (profile->IsChild()) | |
523 badge = new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26); | |
524 else | |
525 badge = new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | |
526 | |
527 return gfx::ImageSkia(badge, badge->size()); | |
528 } | |
529 | |
477 // ProfileChooserView --------------------------------------------------------- | 530 // ProfileChooserView --------------------------------------------------------- |
478 | 531 |
479 // static | 532 // static |
480 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; | 533 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; |
481 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 534 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
482 | 535 |
483 // static | 536 // static |
484 void ProfileChooserView::ShowBubble( | 537 void ProfileChooserView::ShowBubble( |
485 profiles::BubbleViewMode view_mode, | 538 profiles::BubbleViewMode view_mode, |
486 profiles::TutorialMode tutorial_mode, | 539 profiles::TutorialMode tutorial_mode, |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1176 current_profile_photo_ = new EditableProfilePhoto( | 1229 current_profile_photo_ = new EditableProfilePhoto( |
1177 this, avatar_item.icon, !is_guest, | 1230 this, avatar_item.icon, !is_guest, |
1178 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); | 1231 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); |
1179 SizedContainer* profile_icon_container = | 1232 SizedContainer* profile_icon_container = |
1180 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); | 1233 new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
1181 profile_icon_container->AddChildView(current_profile_photo_); | 1234 profile_icon_container->AddChildView(current_profile_photo_); |
1182 | 1235 |
1183 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1236 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1184 if (browser_->profile()->IsSupervised()) { | 1237 if (browser_->profile()->IsSupervised()) { |
1185 views::ImageView* supervised_icon = new views::ImageView(); | 1238 views::ImageView* supervised_icon = new views::ImageView(); |
1186 int image_id = browser_->profile()->IsChild() | 1239 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); |
1187 ? IDR_ICON_PROFILES_MENU_CHILD | |
1188 : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED; | |
1189 supervised_icon->SetImage(rb->GetImageSkiaNamed(image_id)); | |
1190 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); | 1240 gfx::Size preferred_size = supervised_icon->GetPreferredSize(); |
1191 gfx::Rect parent_bounds = current_profile_photo_->bounds(); | 1241 gfx::Rect parent_bounds = current_profile_photo_->bounds(); |
1192 supervised_icon->SetBounds( | 1242 supervised_icon->SetBounds( |
1193 parent_bounds.right() - preferred_size.width(), | 1243 parent_bounds.right() - preferred_size.width(), |
1194 parent_bounds.bottom() - preferred_size.height(), | 1244 parent_bounds.bottom() - preferred_size.height(), |
1195 preferred_size.width(), | 1245 preferred_size.width(), |
1196 preferred_size.height()); | 1246 preferred_size.height()); |
1197 profile_icon_container->AddChildView(supervised_icon); | 1247 profile_icon_container->AddChildView(supervised_icon); |
1198 } | 1248 } |
1199 | 1249 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1732 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1782 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1733 IncognitoModePrefs::DISABLED; | 1783 IncognitoModePrefs::DISABLED; |
1734 return incognito_available && !browser_->profile()->IsGuestSession(); | 1784 return incognito_available && !browser_->profile()->IsGuestSession(); |
1735 } | 1785 } |
1736 | 1786 |
1737 void ProfileChooserView::PostActionPerformed( | 1787 void ProfileChooserView::PostActionPerformed( |
1738 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1788 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1739 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1789 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1740 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1790 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1741 } | 1791 } |
OLD | NEW |