| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/avatar_menu_model.h" | 10 #include "chrome/browser/profiles/avatar_menu_model.h" |
| 11 #include "chrome/browser/profiles/profile_info_util.h" | 11 #include "chrome/browser/profiles/profile_info_util.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/models/avatar_menu_item_model.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 18 #include "ui/views/controls/button/label_button.h" | 19 #include "ui/views/controls/button/label_button.h" |
| 19 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| 20 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/controls/link.h" | 22 #include "ui/views/controls/link.h" |
| 22 #include "ui/views/controls/separator.h" | 23 #include "ui/views/controls/separator.h" |
| 23 #include "ui/views/layout/box_layout.h" | 24 #include "ui/views/layout/box_layout.h" |
| 24 #include "ui/views/layout/grid_layout.h" | 25 #include "ui/views/layout/grid_layout.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 views::GridLayout* layout = new views::GridLayout(this); | 135 views::GridLayout* layout = new views::GridLayout(this); |
| 135 SetLayoutManager(layout); | 136 SetLayoutManager(layout); |
| 136 | 137 |
| 137 views::ColumnSet* columns = layout->AddColumnSet(0); | 138 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 138 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 139 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 139 views::GridLayout::USE_PREF, 0, 0); | 140 views::GridLayout::USE_PREF, 0, 0); |
| 140 | 141 |
| 141 // Seprate items into active and alternatives. | 142 // Seprate items into active and alternatives. |
| 142 Indexes other_profiles; | 143 Indexes other_profiles; |
| 143 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { | 144 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { |
| 144 const AvatarMenuModel::Item& item = avatar_menu_model->GetItemAt(i); | 145 const AvatarMenuItemModel& item = avatar_menu_model->GetItemAt(i); |
| 145 if (item.active) { | 146 if (item.active) { |
| 146 DCHECK(!current_profile_view_); | 147 DCHECK(!current_profile_view_); |
| 147 current_profile_view_ = CreateCurrentProfileView(i); | 148 current_profile_view_ = CreateCurrentProfileView(i); |
| 148 } else { | 149 } else { |
| 149 other_profiles.push_back(i); | 150 other_profiles.push_back(i); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 DCHECK(current_profile_view_); | 153 DCHECK(current_profile_view_); |
| 153 | 154 |
| 154 layout->StartRow(1, 0); | 155 layout->StartRow(1, 0); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // TODO(bcwhite): image alterations | 189 // TODO(bcwhite): image alterations |
| 189 view->SetImage(image.ToImageSkia()); | 190 view->SetImage(image.ToImageSkia()); |
| 190 | 191 |
| 191 return view; | 192 return view; |
| 192 } | 193 } |
| 193 | 194 |
| 194 views::View* ProfileChooserView::CreateProfileCardView(size_t avatar_to_show) { | 195 views::View* ProfileChooserView::CreateProfileCardView(size_t avatar_to_show) { |
| 195 views::View* view = new views::View(); | 196 views::View* view = new views::View(); |
| 196 | 197 |
| 197 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 198 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 198 const AvatarMenuModel::Item& avatar_item = | 199 const AvatarMenuItemModel& avatar_item = |
| 199 avatar_menu_model_->GetItemAt(avatar_to_show); | 200 avatar_menu_model_->GetItemAt(avatar_to_show); |
| 200 | 201 |
| 201 const int kLargeImageSide = 64; | 202 const int kLargeImageSide = 64; |
| 202 views::View* photo_image = | 203 views::View* photo_image = |
| 203 CreateProfileImageView(avatar_item.icon, kLargeImageSide); | 204 CreateProfileImageView(avatar_item.icon, kLargeImageSide); |
| 204 view->SetBoundsRect(photo_image->bounds()); | 205 view->SetBoundsRect(photo_image->bounds()); |
| 205 | 206 |
| 206 views::Label* name_label = | 207 views::Label* name_label = |
| 207 new views::Label(avatar_item.name, | 208 new views::Label(avatar_item.name, |
| 208 rb.GetFont(ui::ResourceBundle::MediumFont)); | 209 rb.GetFont(ui::ResourceBundle::MediumFont)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 layout->AddView(users_button, 1, 1, | 327 layout->AddView(users_button, 1, 1, |
| 327 views::GridLayout::FILL, views::GridLayout::FILL, | 328 views::GridLayout::FILL, views::GridLayout::FILL, |
| 328 0, kButtonHeight); | 329 0, kButtonHeight); |
| 329 layout->AddView(new views::Separator(views::Separator::VERTICAL)); | 330 layout->AddView(new views::Separator(views::Separator::VERTICAL)); |
| 330 layout->AddView(guest_button, 1, 1, | 331 layout->AddView(guest_button, 1, 1, |
| 331 views::GridLayout::FILL, views::GridLayout::FILL, | 332 views::GridLayout::FILL, views::GridLayout::FILL, |
| 332 0, kButtonHeight); | 333 0, kButtonHeight); |
| 333 | 334 |
| 334 return view; | 335 return view; |
| 335 } | 336 } |
| OLD | NEW |