| 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 "chrome/browser/ui/singleton_tabs.h" | 13 #include "chrome/browser/ui/singleton_tabs.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/profile_selector/avatar_menu_item_model.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/views/controls/button/label_button.h" | 21 #include "ui/views/controls/button/label_button.h" |
| 21 #include "ui/views/controls/image_view.h" | 22 #include "ui/views/controls/image_view.h" |
| 22 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/controls/link.h" | 24 #include "ui/views/controls/link.h" |
| 24 #include "ui/views/controls/separator.h" | 25 #include "ui/views/controls/separator.h" |
| 25 #include "ui/views/layout/box_layout.h" | 26 #include "ui/views/layout/box_layout.h" |
| 26 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 views::GridLayout* layout = new views::GridLayout(this); | 142 views::GridLayout* layout = new views::GridLayout(this); |
| 142 SetLayoutManager(layout); | 143 SetLayoutManager(layout); |
| 143 | 144 |
| 144 views::ColumnSet* columns = layout->AddColumnSet(0); | 145 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 145 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 146 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| 146 views::GridLayout::USE_PREF, 0, 0); | 147 views::GridLayout::USE_PREF, 0, 0); |
| 147 | 148 |
| 148 // Seprate items into active and alternatives. | 149 // Seprate items into active and alternatives. |
| 149 Indexes other_profiles; | 150 Indexes other_profiles; |
| 150 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { | 151 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { |
| 151 const AvatarMenuModel::Item& item = avatar_menu_model->GetItemAt(i); | 152 const ui::AvatarMenuItemModel& item = avatar_menu_model->GetItemAt(i); |
| 152 if (item.active) { | 153 if (item.active) { |
| 153 DCHECK(!current_profile_view_); | 154 DCHECK(!current_profile_view_); |
| 154 current_profile_view_ = CreateCurrentProfileView(i); | 155 current_profile_view_ = CreateCurrentProfileView(i); |
| 155 } else { | 156 } else { |
| 156 other_profiles.push_back(i); | 157 other_profiles.push_back(i); |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 DCHECK(current_profile_view_); | 160 DCHECK(current_profile_view_); |
| 160 | 161 |
| 161 layout->StartRow(1, 0); | 162 layout->StartRow(1, 0); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // TODO(bcwhite): image alterations | 196 // TODO(bcwhite): image alterations |
| 196 view->SetImage(image.ToImageSkia()); | 197 view->SetImage(image.ToImageSkia()); |
| 197 | 198 |
| 198 return view; | 199 return view; |
| 199 } | 200 } |
| 200 | 201 |
| 201 views::View* ProfileChooserView::CreateProfileCardView(size_t avatar_to_show) { | 202 views::View* ProfileChooserView::CreateProfileCardView(size_t avatar_to_show) { |
| 202 views::View* view = new views::View(); | 203 views::View* view = new views::View(); |
| 203 | 204 |
| 204 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 205 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 205 const AvatarMenuModel::Item& avatar_item = | 206 const ui::AvatarMenuItemModel& avatar_item = |
| 206 avatar_menu_model_->GetItemAt(avatar_to_show); | 207 avatar_menu_model_->GetItemAt(avatar_to_show); |
| 207 | 208 |
| 208 const int kLargeImageSide = 64; | 209 const int kLargeImageSide = 64; |
| 209 views::View* photo_image = | 210 views::View* photo_image = |
| 210 CreateProfileImageView(avatar_item.icon, kLargeImageSide); | 211 CreateProfileImageView(avatar_item.icon, kLargeImageSide); |
| 211 view->SetBoundsRect(photo_image->bounds()); | 212 view->SetBoundsRect(photo_image->bounds()); |
| 212 | 213 |
| 213 views::Label* name_label = | 214 views::Label* name_label = |
| 214 new views::Label(avatar_item.name, | 215 new views::Label(avatar_item.name, |
| 215 rb.GetFont(ui::ResourceBundle::MediumFont)); | 216 rb.GetFont(ui::ResourceBundle::MediumFont)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 layout->AddView(users_button_view_, 1, 1, | 331 layout->AddView(users_button_view_, 1, 1, |
| 331 views::GridLayout::FILL, views::GridLayout::FILL, | 332 views::GridLayout::FILL, views::GridLayout::FILL, |
| 332 0, kButtonHeight); | 333 0, kButtonHeight); |
| 333 layout->AddView(new views::Separator(views::Separator::VERTICAL)); | 334 layout->AddView(new views::Separator(views::Separator::VERTICAL)); |
| 334 layout->AddView(guest_button_view_, 1, 1, | 335 layout->AddView(guest_button_view_, 1, 1, |
| 335 views::GridLayout::FILL, views::GridLayout::FILL, | 336 views::GridLayout::FILL, views::GridLayout::FILL, |
| 336 0, kButtonHeight); | 337 0, kButtonHeight); |
| 337 | 338 |
| 338 return view; | 339 return view; |
| 339 } | 340 } |
| OLD | NEW |