Index: chrome/browser/profiles/profile_info_entry.cc |
diff --git a/chrome/browser/profiles/profile_info_entry.cc b/chrome/browser/profiles/profile_info_entry.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..58f2c4c5a45c790f0adc7b6ef0fca71e2434e307 |
--- /dev/null |
+++ b/chrome/browser/profiles/profile_info_entry.cc |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/profiles/profile_info_entry.h" |
+ |
+#include "base/values.h" |
+#include "chrome/browser/profiles/profile_info_util.h" |
+#include "ui/gfx/image/image.h" |
+ |
+namespace { |
+ |
+const char kNameKey[] = "name"; |
+const char kUserNameKey[] = "user_name"; |
+const char kAvatarIconKey[] = "avatar_icon"; |
+const char kBackgroundAppsKey[] = "background_apps"; |
+ |
+} // namespace |
+ |
+ProfileInfoEntry::ProfileInfoEntry() |
+ : icon_index_(0), |
+ is_running_background_apps_(false) { |
+} |
+ |
+ProfileInfoEntry::ProfileInfoEntry(const ProfileInfoEntry& entry) |
+ : path_(entry.path_), |
+ name_(entry.name_), |
+ user_name_(entry.user_name_), |
+ icon_index_(entry.icon_index_), |
+ is_running_background_apps_(entry.is_running_background_apps_) { |
+} |
+ |
+ProfileInfoEntry::ProfileInfoEntry(const FilePath& path, |
+ const base::DictionaryValue& info) |
+ : path_(path), |
+ icon_index_(0), |
+ is_running_background_apps_(false) { |
+ info.GetString(kNameKey, &name_); |
+ |
+ info.GetString(kUserNameKey, &user_name_); |
+ |
+ std::string icon_url; |
+ info.GetString(kAvatarIconKey, &icon_url); |
+ size_t icon_index = 0; |
+ if (profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) |
+ icon_index_ = icon_index; |
+ |
+ info.GetBoolean(kBackgroundAppsKey, &is_running_background_apps_); |
+} |
+ |
+ProfileInfoEntry& ProfileInfoEntry::operator=(const ProfileInfoEntry& entry) { |
+ name_ = entry.name_; |
+ user_name_ = entry.user_name_; |
+ icon_index_ = entry.icon_index_; |
+ is_running_background_apps_ = entry.is_running_background_apps_; |
+ return *this; |
+} |
+ |
+bool ProfileInfoEntry::operator<(const ProfileInfoEntry& rhs) const { |
+ int compare = name_.compare(rhs.name()); |
+ if (compare < 0) |
+ return true; |
+ if (compare > 0) |
+ return false; |
+ return icon_index_ < rhs.icon_index_; |
+} |
+ |
+base::DictionaryValue* ProfileInfoEntry::GetEntryAsDictionary() const { |
+ base::DictionaryValue* info = new base::DictionaryValue; |
+ info->SetString(kNameKey, name_); |
+ info->SetString(kUserNameKey, user_name_); |
+ info->SetString(kAvatarIconKey, |
+ profiles::GetDefaultAvatarIconUrl(icon_index_)); |
+ info->SetBoolean(kBackgroundAppsKey, is_running_background_apps_); |
+ |
+ return info; |
+} |
+ |
+const gfx::Image& ProfileInfoEntry::GetIcon() const { |
+ // TODO(sail) |
+ gfx::Image* image = NULL; |
+ return *image; |
+} |