OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/profiles/profile_info_entry.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "chrome/browser/profiles/profile_info_util.h" |
| 9 #include "ui/gfx/image/image.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 const char kNameKey[] = "name"; |
| 14 const char kUserNameKey[] = "user_name"; |
| 15 const char kAvatarIconKey[] = "avatar_icon"; |
| 16 const char kBackgroundAppsKey[] = "background_apps"; |
| 17 |
| 18 } // namespace |
| 19 |
| 20 ProfileInfoEntry::ProfileInfoEntry() |
| 21 : icon_index_(0), |
| 22 is_running_background_apps_(false) { |
| 23 } |
| 24 |
| 25 ProfileInfoEntry::ProfileInfoEntry(const ProfileInfoEntry& entry) |
| 26 : path_(entry.path_), |
| 27 name_(entry.name_), |
| 28 user_name_(entry.user_name_), |
| 29 icon_index_(entry.icon_index_), |
| 30 is_running_background_apps_(entry.is_running_background_apps_) { |
| 31 } |
| 32 |
| 33 ProfileInfoEntry::ProfileInfoEntry(const FilePath& path, |
| 34 const base::DictionaryValue& info) |
| 35 : path_(path), |
| 36 icon_index_(0), |
| 37 is_running_background_apps_(false) { |
| 38 info.GetString(kNameKey, &name_); |
| 39 |
| 40 info.GetString(kUserNameKey, &user_name_); |
| 41 |
| 42 std::string icon_url; |
| 43 info.GetString(kAvatarIconKey, &icon_url); |
| 44 size_t icon_index = 0; |
| 45 if (profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) |
| 46 icon_index_ = icon_index; |
| 47 |
| 48 info.GetBoolean(kBackgroundAppsKey, &is_running_background_apps_); |
| 49 } |
| 50 |
| 51 ProfileInfoEntry& ProfileInfoEntry::operator=(const ProfileInfoEntry& entry) { |
| 52 name_ = entry.name_; |
| 53 user_name_ = entry.user_name_; |
| 54 icon_index_ = entry.icon_index_; |
| 55 is_running_background_apps_ = entry.is_running_background_apps_; |
| 56 return *this; |
| 57 } |
| 58 |
| 59 bool ProfileInfoEntry::operator<(const ProfileInfoEntry& rhs) const { |
| 60 int compare = name_.compare(rhs.name()); |
| 61 if (compare < 0) |
| 62 return true; |
| 63 if (compare > 0) |
| 64 return false; |
| 65 return icon_index_ < rhs.icon_index_; |
| 66 } |
| 67 |
| 68 base::DictionaryValue* ProfileInfoEntry::GetEntryAsDictionary() const { |
| 69 base::DictionaryValue* info = new base::DictionaryValue; |
| 70 info->SetString(kNameKey, name_); |
| 71 info->SetString(kUserNameKey, user_name_); |
| 72 info->SetString(kAvatarIconKey, |
| 73 profiles::GetDefaultAvatarIconUrl(icon_index_)); |
| 74 info->SetBoolean(kBackgroundAppsKey, is_running_background_apps_); |
| 75 |
| 76 return info; |
| 77 } |
| 78 |
| 79 const gfx::Image& ProfileInfoEntry::GetIcon() const { |
| 80 // TODO(sail) |
| 81 gfx::Image* image = NULL; |
| 82 return *image; |
| 83 } |
OLD | NEW |