Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/profiles/profile_info_util.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove junk from list_model.h Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/profiles/profile_info_util.h" 5 #include "chrome/browser/profiles/profile_info_util.h"
6 6
7 #include "base/command_line.h"
8 #include "chrome/browser/profiles/profile_info_cache.h"
9 #include "chrome/common/chrome_switches.h"
10 #include "grit/generated_resources.h"
7 #include "skia/ext/image_operations.h" 11 #include "skia/ext/image_operations.h"
12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/profile_selector/avatar_menu_item_model.h"
8 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
9 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
10 16
11 namespace profiles { 17 namespace profiles {
12 18
13 const int kAvatarIconWidth = 38; 19 const int kAvatarIconWidth = 38;
14 const int kAvatarIconHeight = 31; 20 const int kAvatarIconHeight = 31;
15 const int kAvatarIconBorder = 2; 21 const int kAvatarIconBorder = 2;
16 22
17 gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image, 23 gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 canvas.DrawLine(gfx::Point(x1, y1), gfx::Point(x2, y1), shadow_color); 101 canvas.DrawLine(gfx::Point(x1, y1), gfx::Point(x2, y1), shadow_color);
96 // Left shadow. 102 // Left shadow.
97 canvas.DrawLine(gfx::Point(x1, y1 + 1), gfx::Point(x1, y2 - 1), shadow_color); 103 canvas.DrawLine(gfx::Point(x1, y1 + 1), gfx::Point(x1, y2 - 1), shadow_color);
98 // Right shadow. 104 // Right shadow.
99 canvas.DrawLine(gfx::Point(x2 - 1, y1 + 1), gfx::Point(x2 - 1, y2 - 1), 105 canvas.DrawLine(gfx::Point(x2 - 1, y1 + 1), gfx::Point(x2 - 1, y2 - 1),
100 shadow_color); 106 shadow_color);
101 107
102 return gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())); 108 return gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep()));
103 } 109 }
104 110
105 } // namespace 111 void PopulateAvatarMenuItemModels(
112 const ProfileInfoInterface* cache,
113 const base::FilePath& active_profile_path,
114 std::vector<ui::AvatarMenuItemModel*>* items) {
115 const size_t count = cache->GetNumberOfProfiles();
116 for (size_t i = 0; i < count; ++i) {
117 bool is_gaia_picture =
118 cache->IsUsingGAIAPictureOfProfileAtIndex(i) &&
119 cache->GetGAIAPictureOfProfileAtIndex(i);
120
121 gfx::Image icon = cache->GetAvatarIconOfProfileAtIndex(i);
122 if (!CommandLine::ForCurrentProcess()->HasSwitch(
123 switches::kNewProfileManagement)) {
124 // old avatar menu uses resized-small images
tapted 2013/08/05 03:01:39 nit: This comment should be turned into a sentence
calamity 2013/08/08 04:52:12 Done.
125 icon = GetAvatarIconForMenu(icon, is_gaia_picture);
126 }
127
128 ui::AvatarMenuItemModel* item = new ui::AvatarMenuItemModel(i, icon);
129 item->name = cache->GetNameOfProfileAtIndex(i);
130 item->sync_state = cache->GetUserNameOfProfileAtIndex(i);
131 item->signed_in = !item->sync_state.empty();
132 if (!item->signed_in) {
133 item->sync_state = l10n_util::GetStringUTF16(
134 cache->ProfileIsManagedAtIndex(i) ?
135 IDS_MANAGED_USER_AVATAR_LABEL : IDS_PROFILES_LOCAL_PROFILE_STATE);
136 }
137 item->profile_path = cache->GetPathOfProfileAtIndex(i);
138 item->active = item->profile_path == active_profile_path;
139 item->signin_required = cache->ProfileIsSigninRequiredAtIndex(i);
140 items->push_back(item);
141 }
142 }
143
144 } // namespace profiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698