| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.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/profiles/profile_info_util.h" | 10 #include "chrome/browser/profiles/profile_info_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Helpers -------------------------------------------------------------------- | 48 // Helpers -------------------------------------------------------------------- |
| 49 | 49 |
| 50 const int kLargeImageSide = 64; | 50 const int kLargeImageSide = 64; |
| 51 const int kSmallImageSide = 32; | 51 const int kSmallImageSide = 32; |
| 52 const int kMinMenuWidth = 250; | 52 const int kMinMenuWidth = 250; |
| 53 const int kButtonHeight = 29; | 53 const int kButtonHeight = 29; |
| 54 const int kArrowHeight = 10; | |
| 55 | 54 |
| 56 // Current profile avatar image. | 55 // Current profile avatar image. |
| 57 views::View* CreateProfileImageView(const gfx::Image& icon) { | 56 views::View* CreateProfileImageView(const gfx::Image& icon) { |
| 58 views::ImageView* view = new views::ImageView(); | 57 views::ImageView* view = new views::ImageView(); |
| 59 | 58 |
| 60 gfx::Image image = profiles::GetSizedAvatarIconWithBorder( | 59 gfx::Image image = profiles::GetSizedAvatarIconWithBorder( |
| 61 icon, true, | 60 icon, true, |
| 62 kLargeImageSide + profiles::kAvatarIconPadding, | 61 kLargeImageSide + profiles::kAvatarIconPadding, |
| 63 kLargeImageSide + profiles::kAvatarIconPadding); | 62 kLargeImageSide + profiles::kAvatarIconPadding); |
| 64 view->SetImage(image.ToImageSkia()); | 63 view->SetImage(image.ToImageSkia()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 217 } |
| 219 | 218 |
| 220 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 219 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
| 221 views::BubbleBorder::Arrow arrow, | 220 views::BubbleBorder::Arrow arrow, |
| 222 const gfx::Rect& anchor_rect, | 221 const gfx::Rect& anchor_rect, |
| 223 Browser* browser) | 222 Browser* browser) |
| 224 : BubbleDelegateView(anchor_view, arrow), | 223 : BubbleDelegateView(anchor_view, arrow), |
| 225 browser_(browser) { | 224 browser_(browser) { |
| 226 // Reset the default margins inherited from the BubbleDelegateView. | 225 // Reset the default margins inherited from the BubbleDelegateView. |
| 227 set_margins(gfx::Insets()); | 226 set_margins(gfx::Insets()); |
| 228 // Compensate for built-in vertical padding in the anchor view's image. | |
| 229 set_anchor_view_insets(gfx::Insets(kArrowHeight, 0, kArrowHeight, 0)); | |
| 230 | 227 |
| 231 ResetLinksAndButtons(); | 228 ResetLinksAndButtons(); |
| 232 | 229 |
| 233 avatar_menu_.reset(new AvatarMenu( | 230 avatar_menu_.reset(new AvatarMenu( |
| 234 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 231 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
| 235 this, | 232 this, |
| 236 browser_)); | 233 browser_)); |
| 237 avatar_menu_->RebuildMenu(); | 234 avatar_menu_->RebuildMenu(); |
| 238 } | 235 } |
| 239 | 236 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 631 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 635 | 632 |
| 636 add_account_button_ = new views::BlueButton( | 633 add_account_button_ = new views::BlueButton( |
| 637 this, | 634 this, |
| 638 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, | 635 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, |
| 639 avatar_item.name)); | 636 avatar_item.name)); |
| 640 layout->StartRow(1, 0); | 637 layout->StartRow(1, 0); |
| 641 layout->AddView(add_account_button_); | 638 layout->AddView(add_account_button_); |
| 642 return view; | 639 return view; |
| 643 } | 640 } |
| OLD | NEW |