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

Unified Diff: chrome/browser/profiles/profile_info_entry.cc

Issue 8539043: Refactor ProfileInfoCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « chrome/browser/profiles/profile_info_entry.h ('k') | chrome/browser/profiles/profile_info_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « chrome/browser/profiles/profile_info_entry.h ('k') | chrome/browser/profiles/profile_info_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698