OLD | NEW |
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/chromeos/login/user.h" | 5 #include "chrome/browser/chromeos/login/user.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "chrome/browser/chromeos/login/default_user_images.h" | 11 #include "chrome/browser/chromeos/login/default_user_images.h" |
12 #include "chrome/browser/chromeos/login/user_manager.h" | 12 #include "chrome/browser/chromeos/login/user_manager.h" |
13 #include "google_apis/gaia/gaia_auth_util.h" | |
14 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
16 | 15 |
17 namespace chromeos { | 16 namespace chromeos { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 // Returns account name portion of an email. | 20 // Returns account name portion of an email. |
22 std::string GetUserName(const std::string& email) { | 21 std::string GetUserName(const std::string& email) { |
23 std::string::size_type i = email.find('@'); | 22 std::string::size_type i = email.find('@'); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 username = other.username; | 161 username = other.username; |
163 password = other.password; | 162 password = other.password; |
164 key_label = other.key_label; | 163 key_label = other.key_label; |
165 need_password_hashing = other.need_password_hashing; | 164 need_password_hashing = other.need_password_hashing; |
166 auth_code = other.auth_code; | 165 auth_code = other.auth_code; |
167 username_hash = other.username_hash; | 166 username_hash = other.username_hash; |
168 using_oauth = other.using_oauth; | 167 using_oauth = other.using_oauth; |
169 auth_flow = other.auth_flow; | 168 auth_flow = other.auth_flow; |
170 } | 169 } |
171 | 170 |
172 std::string User::GetEmail() const { | |
173 return display_email(); | |
174 } | |
175 | |
176 base::string16 User::GetDisplayName() const { | 171 base::string16 User::GetDisplayName() const { |
177 // Fallback to the email account name in case display name haven't been set. | 172 // Fallback to the email account name in case display name haven't been set. |
178 return display_name_.empty() ? | 173 return display_name_.empty() ? |
179 base::UTF8ToUTF16(GetAccountName(true)) : | 174 base::UTF8ToUTF16(GetAccountName(true)) : |
180 display_name_; | 175 display_name_; |
181 } | 176 } |
182 | 177 |
183 base::string16 User::GetGivenName() const { | |
184 return given_name_; | |
185 } | |
186 | |
187 const gfx::ImageSkia& User::GetImage() const { | |
188 return user_image_.image(); | |
189 } | |
190 | |
191 std::string User::GetUserID() const { | |
192 return gaia::CanonicalizeEmail(gaia::SanitizeEmail( | |
193 email())); | |
194 } | |
195 | |
196 std::string User::GetAccountName(bool use_display_email) const { | 178 std::string User::GetAccountName(bool use_display_email) const { |
197 if (use_display_email && !display_email_.empty()) | 179 if (use_display_email && !display_email_.empty()) |
198 return GetUserName(display_email_); | 180 return GetUserName(display_email_); |
199 else | 181 else |
200 return GetUserName(email_); | 182 return GetUserName(email_); |
201 } | 183 } |
202 | 184 |
203 bool User::HasDefaultImage() const { | 185 bool User::HasDefaultImage() const { |
204 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; | 186 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; |
205 } | 187 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 case USER_TYPE_LOCALLY_MANAGED: | 355 case USER_TYPE_LOCALLY_MANAGED: |
374 case USER_TYPE_KIOSK_APP: | 356 case USER_TYPE_KIOSK_APP: |
375 return false; | 357 return false; |
376 default: | 358 default: |
377 NOTREACHED(); | 359 NOTREACHED(); |
378 } | 360 } |
379 return false; | 361 return false; |
380 } | 362 } |
381 | 363 |
382 } // namespace chromeos | 364 } // namespace chromeos |
OLD | NEW |