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

Unified Diff: chrome/browser/ui/webui/settings/profile_info_handler.cc

Issue 2671813003: MD Settings: Cros Users: Use display name for non gaia accounts (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/profile_info_handler.cc
diff --git a/chrome/browser/ui/webui/settings/profile_info_handler.cc b/chrome/browser/ui/webui/settings/profile_info_handler.cc
index cd7151484ffe2892d7a04d3204c2dbe0d86353bc..83f2e48f603a3df9f29799f0dc11e7b830e89a7b 100644
--- a/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
@@ -21,7 +22,6 @@
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h"
#else
-#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_statistics.h"
#include "chrome/browser/profiles/profile_statistics_factory.h"
@@ -189,18 +189,23 @@ ProfileInfoHandler::GetAccountNameAndIcon() const {
#if defined(OS_CHROMEOS)
name = profile_->GetProfileUserName();
+ std::string user_email;
if (name.empty()) {
+ // User is not associated with a gaia account, use the display name.
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
- if (user && (user->GetType() != user_manager::USER_TYPE_GUEST))
- name = user->GetAccountId().GetUserEmail();
- }
- if (!name.empty())
+ // Note: We don't show the User section in Guest mode.
+ DCHECK(user && (user->GetType() != user_manager::USER_TYPE_GUEST));
+ name = base::UTF16ToUTF8(user->GetDisplayName());
+ user_email = user->GetAccountId().GetUserEmail();
+ } else {
name = gaia::SanitizeEmail(gaia::CanonicalizeEmail(name));
+ user_email = name;
+ }
// Get image as data URL instead of using chrome://userimage source to avoid
// issues with caching.
- const AccountId account_id(AccountId::FromUserEmail(name));
+ const AccountId account_id(AccountId::FromUserEmail(user_email));
scoped_refptr<base::RefCountedMemory> image =
chromeos::options::UserImageSource::GetUserImage(account_id);
icon_url = webui::GetPngDataUrl(image->front(), image->size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698