OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 AddChildView(image_view_); | 243 AddChildView(image_view_); |
244 | 244 |
245 // Add a label to show the profile name. | 245 // Add a label to show the profile name. |
246 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 246 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
247 const gfx::Font base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 247 const gfx::Font base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
248 const int style = item_.active ? gfx::Font::BOLD : 0; | 248 const int style = item_.active ? gfx::Font::BOLD : 0; |
249 const int kNameFontDelta = 1; | 249 const int kNameFontDelta = 1; |
250 name_label_ = new views::Label(item_.name, | 250 name_label_ = new views::Label(item_.name, |
251 base_font.DeriveFont(kNameFontDelta, style)); | 251 base_font.DeriveFont(kNameFontDelta, style)); |
252 name_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 252 name_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
253 AddChildView(name_label_); | 253 AddChildView(name_label_); |
254 | 254 |
255 // Add a label to show the sync state. | 255 // Add a label to show the sync state. |
256 const int kStateFontDelta = -1; | 256 const int kStateFontDelta = -1; |
257 sync_state_label_ = new views::Label(item_.sync_state); | 257 sync_state_label_ = new views::Label(item_.sync_state); |
258 if (item_.signed_in) | 258 if (item_.signed_in) |
259 sync_state_label_->SetElideBehavior(views::Label::ELIDE_AS_EMAIL); | 259 sync_state_label_->SetElideBehavior(views::Label::ELIDE_AS_EMAIL); |
260 sync_state_label_->SetFont(base_font.DeriveFont(kStateFontDelta)); | 260 sync_state_label_->SetFont(base_font.DeriveFont(kStateFontDelta)); |
261 sync_state_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 261 sync_state_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
262 sync_state_label_->SetEnabled(false); | 262 sync_state_label_->SetEnabled(false); |
263 AddChildView(sync_state_label_); | 263 AddChildView(sync_state_label_); |
264 | 264 |
265 // Add an edit profile link. | 265 // Add an edit profile link. |
266 edit_link_ = new EditProfileLink( | 266 edit_link_ = new EditProfileLink( |
267 l10n_util::GetStringUTF16(IDS_PROFILES_EDIT_PROFILE_LINK), this); | 267 l10n_util::GetStringUTF16(IDS_PROFILES_EDIT_PROFILE_LINK), this); |
268 edit_link_->set_listener(edit_profile_listener); | 268 edit_link_->set_listener(edit_profile_listener); |
269 edit_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 269 edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
270 edit_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); | 270 edit_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); |
271 edit_link_->SetHasFocusBorder(true); | 271 edit_link_->SetHasFocusBorder(true); |
272 AddChildView(edit_link_); | 272 AddChildView(edit_link_); |
273 | 273 |
274 OnHighlightStateChanged(); | 274 OnHighlightStateChanged(); |
275 } | 275 } |
276 | 276 |
277 gfx::Size ProfileItemView::GetPreferredSize() { | 277 gfx::Size ProfileItemView::GetPreferredSize() { |
278 int text_width = std::max(name_label_->GetPreferredSize().width(), | 278 int text_width = std::max(name_label_->GetPreferredSize().width(), |
279 sync_state_label_->GetPreferredSize().width()); | 279 sync_state_label_->GetPreferredSize().width()); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 AddChildView(item_view); | 539 AddChildView(item_view); |
540 item_views_.push_back(item_view); | 540 item_views_.push_back(item_view); |
541 } | 541 } |
542 | 542 |
543 separator_ = new views::Separator(); | 543 separator_ = new views::Separator(); |
544 AddChildView(separator_); | 544 AddChildView(separator_); |
545 | 545 |
546 add_profile_link_ = new views::Link( | 546 add_profile_link_ = new views::Link( |
547 l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)); | 547 l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)); |
548 add_profile_link_->set_listener(this); | 548 add_profile_link_->set_listener(this); |
549 add_profile_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 549 add_profile_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
550 add_profile_link_->SetBackgroundColor(color()); | 550 add_profile_link_->SetBackgroundColor(color()); |
551 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); | 551 add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6)); |
552 AddChildView(add_profile_link_); | 552 AddChildView(add_profile_link_); |
553 | 553 |
554 // If the bubble has already been shown then resize and reposition the bubble. | 554 // If the bubble has already been shown then resize and reposition the bubble. |
555 Layout(); | 555 Layout(); |
556 if (GetBubbleFrameView()) | 556 if (GetBubbleFrameView()) |
557 SizeToContents(); | 557 SizeToContents(); |
558 } | 558 } |
OLD | NEW |