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

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

Issue 9489011: Elide long emails in the wrench and profile menus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rev2 Created 8 years, 9 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/avatar_menu_model.h" 5 #include "chrome/browser/profiles/avatar_menu_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/avatar_menu_model_observer.h" 11 #include "chrome/browser/profiles/avatar_menu_model_observer.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_info_cache.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
14 #include "chrome/browser/profiles/profile_info_util.h" 14 #include "chrome/browser/profiles/profile_info_util.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/profiles/profile_metrics.h" 16 #include "chrome/browser/profiles/profile_metrics.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_init.h" 18 #include "chrome/browser/ui/browser_init.h"
19 #include "chrome/browser/ui/browser_list.h" 19 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/text/text_elider.h"
26 27
27 using content::BrowserThread; 28 using content::BrowserThread;
28 29
29 namespace { 30 namespace {
30 31
31 void OnProfileCreated(bool always_create, 32 void OnProfileCreated(bool always_create,
32 Profile* profile, 33 Profile* profile,
33 Profile::CreateStatus status) { 34 Profile::CreateStatus status) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 36
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 profile_info_->GetGAIAPictureOfProfileAtIndex(i); 155 profile_info_->GetGAIAPictureOfProfileAtIndex(i);
155 gfx::Image icon = profiles::GetAvatarIconForMenu( 156 gfx::Image icon = profiles::GetAvatarIconForMenu(
156 profile_info_->GetAvatarIconOfProfileAtIndex(i), is_gaia_picture); 157 profile_info_->GetAvatarIconOfProfileAtIndex(i), is_gaia_picture);
157 158
158 Item* item = new Item(i, icon); 159 Item* item = new Item(i, icon);
159 item->name = profile_info_->GetNameOfProfileAtIndex(i); 160 item->name = profile_info_->GetNameOfProfileAtIndex(i);
160 item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i); 161 item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i);
161 if (item->sync_state.empty()) { 162 if (item->sync_state.empty()) {
162 item->sync_state = l10n_util::GetStringUTF16( 163 item->sync_state = l10n_util::GetStringUTF16(
163 IDS_PROFILES_LOCAL_PROFILE_STATE); 164 IDS_PROFILES_LOCAL_PROFILE_STATE);
165 } else {
166 item->sync_state = ui::ElideEmail(item->sync_state,
167 ui::kMaxProfileUsernameLength);
164 } 168 }
165 if (browser_) { 169 if (browser_) {
166 FilePath path = profile_info_->GetPathOfProfileAtIndex(i); 170 FilePath path = profile_info_->GetPathOfProfileAtIndex(i);
167 item->active = browser_->profile()->GetPath() == path; 171 item->active = browser_->profile()->GetPath() == path;
168 } 172 }
169 items_.push_back(item); 173 items_.push_back(item);
170 } 174 }
171 } 175 }
172 176
173 void AvatarMenuModel::ClearMenu() { 177 void AvatarMenuModel::ClearMenu() {
174 STLDeleteContainerPointers(items_.begin(), items_.end()); 178 STLDeleteContainerPointers(items_.begin(), items_.end());
175 items_.clear(); 179 items_.clear();
176 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698