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 "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile_info_util.h" | 9 #include "chrome/browser/profiles/profile_info_util.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #endif | 41 #endif |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Helpers -------------------------------------------------------------------- | 45 // Helpers -------------------------------------------------------------------- |
46 | 46 |
47 const int kLargeImageSide = 64; | 47 const int kLargeImageSide = 64; |
48 const int kSmallImageSide = 32; | 48 const int kSmallImageSide = 32; |
49 const int kMinMenuWidth = 250; | 49 const int kMinMenuWidth = 250; |
50 const int kButtonHeight = 29; | 50 const int kButtonHeight = 29; |
| 51 const int kArrowHeight = 10; |
51 | 52 |
52 // Current profile avatar image. | 53 // Current profile avatar image. |
53 views::View* CreateProfileImageView(const gfx::Image& icon) { | 54 views::View* CreateProfileImageView(const gfx::Image& icon) { |
54 views::ImageView* view = new views::ImageView(); | 55 views::ImageView* view = new views::ImageView(); |
55 | 56 |
56 gfx::Image image = profiles::GetSizedAvatarIconWithBorder( | 57 gfx::Image image = profiles::GetSizedAvatarIconWithBorder( |
57 icon, true, | 58 icon, true, |
58 kLargeImageSide + profiles::kAvatarIconBorder, | 59 kLargeImageSide + profiles::kAvatarIconBorder, |
59 kLargeImageSide + profiles::kAvatarIconBorder); | 60 kLargeImageSide + profiles::kAvatarIconBorder); |
60 view->SetImage(image.ToImageSkia()); | 61 view->SetImage(image.ToImageSkia()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (IsShowing()) | 193 if (IsShowing()) |
193 // TODO(bcwhite): handle case where we should show on different window | 194 // TODO(bcwhite): handle case where we should show on different window |
194 return; | 195 return; |
195 | 196 |
196 profile_bubble_ = new ProfileChooserView( | 197 profile_bubble_ = new ProfileChooserView( |
197 anchor_view, arrow, anchor_rect, browser); | 198 anchor_view, arrow, anchor_rect, browser); |
198 views::BubbleDelegateView::CreateBubble(profile_bubble_); | 199 views::BubbleDelegateView::CreateBubble(profile_bubble_); |
199 profile_bubble_->set_close_on_deactivate(close_on_deactivate_); | 200 profile_bubble_->set_close_on_deactivate(close_on_deactivate_); |
200 profile_bubble_->SetAlignment(border_alignment); | 201 profile_bubble_->SetAlignment(border_alignment); |
201 profile_bubble_->GetWidget()->Show(); | 202 profile_bubble_->GetWidget()->Show(); |
| 203 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
202 } | 204 } |
203 | 205 |
204 // static | 206 // static |
205 bool ProfileChooserView::IsShowing() { | 207 bool ProfileChooserView::IsShowing() { |
206 return profile_bubble_ != NULL; | 208 return profile_bubble_ != NULL; |
207 } | 209 } |
208 | 210 |
209 // static | 211 // static |
210 void ProfileChooserView::Hide() { | 212 void ProfileChooserView::Hide() { |
211 if (IsShowing()) | 213 if (IsShowing()) |
212 profile_bubble_->GetWidget()->Close(); | 214 profile_bubble_->GetWidget()->Close(); |
213 } | 215 } |
214 | 216 |
215 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 217 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
216 views::BubbleBorder::Arrow arrow, | 218 views::BubbleBorder::Arrow arrow, |
217 const gfx::Rect& anchor_rect, | 219 const gfx::Rect& anchor_rect, |
218 Browser* browser) | 220 Browser* browser) |
219 : BubbleDelegateView(anchor_view, arrow), | 221 : BubbleDelegateView(anchor_view, arrow), |
220 browser_(browser) { | 222 browser_(browser) { |
221 // Reset the default margins inherited from the BubbleDelegateView. | 223 // Reset the default margins inherited from the BubbleDelegateView. |
222 set_margins(gfx::Insets()); | 224 set_margins(gfx::Insets()); |
| 225 // Compensate for built-in vertical padding in the anchor view's image. |
| 226 set_anchor_view_insets(gfx::Insets(kArrowHeight, 0, kArrowHeight, 0)); |
223 | 227 |
224 ResetLinksAndButtons(); | 228 ResetLinksAndButtons(); |
225 | 229 |
226 avatar_menu_.reset(new AvatarMenu( | 230 avatar_menu_.reset(new AvatarMenu( |
227 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 231 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
228 this, | 232 this, |
229 browser_)); | 233 browser_)); |
230 avatar_menu_->RebuildMenu(); | 234 avatar_menu_->RebuildMenu(); |
231 } | 235 } |
232 | 236 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 598 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
595 | 599 |
596 views::BlueButton* add_account_button = new views::BlueButton( | 600 views::BlueButton* add_account_button = new views::BlueButton( |
597 NULL, | 601 NULL, |
598 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, | 602 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, |
599 avatar_item.name)); | 603 avatar_item.name)); |
600 layout->StartRow(1, 0); | 604 layout->StartRow(1, 0); |
601 layout->AddView(add_account_button); | 605 layout->AddView(add_account_button); |
602 return view; | 606 return view; |
603 } | 607 } |
OLD | NEW |