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

Unified Diff: chrome/browser/ui/app_list/search/people/people_result.cc

Issue 23874015: Implement people search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
Index: chrome/browser/ui/app_list/search/people/people_result.cc
diff --git a/chrome/browser/ui/app_list/search/people/people_result.cc b/chrome/browser/ui/app_list/search/people/people_result.cc
new file mode 100644
index 0000000000000000000000000000000000000000..adac861d6d843085ec98ef469404f3944b067bda
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/people/people_result.cc
@@ -0,0 +1,84 @@
+// Copyright 2013 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/ui/app_list/search/people/people_result.h"
+
+#include <vector>
+
+#include "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/search/common/url_icon_source.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+const int kIconSize = 32;
+
+} // namespace
+
+namespace app_list {
+
+PeopleResult::PeopleResult(Profile* profile,
+ const std::string& id,
+ const std::string& display_name,
+ double interaction_rank,
+ const GURL& image_url)
+ : profile_(profile),
+ id_(id),
+ display_name_(display_name),
+ interaction_rank_(interaction_rank),
+ image_url_(image_url),
+ weak_factory_(this) {
+ set_id(id_);
+ set_title(UTF8ToUTF16(display_name_));
+ set_relevance(interaction_rank_);
+
+ image_ = gfx::ImageSkia(
+ new UrlIconSource(base::Bind(&PeopleResult::OnIconLoaded,
+ weak_factory_.GetWeakPtr()),
+ profile_->GetRequestContext(),
+ image_url_,
+ kIconSize,
+ IDR_PROFILE_PICTURE_LOADING),
+ gfx::Size(kIconSize, kIconSize));
+ SetIcon(image_);
+}
+
+PeopleResult::~PeopleResult() {
+}
+
+void PeopleResult::Open(int event_flags) {
+ // TODO(rkc): Navigate to the person's profile?
+}
+
+void PeopleResult::InvokeAction(int action_index, int event_flags) {
+ DCHECK_EQ(0, action_index);
+ // TODO(rkc): Decide what to do here.
+}
+
+scoped_ptr<ChromeSearchResult> PeopleResult::Duplicate() {
+ return scoped_ptr<ChromeSearchResult>(new PeopleResult(profile_, id_,
+ display_name_,
+ interaction_rank_,
+ image_url_)).Pass();
+}
+
+void PeopleResult::OnIconLoaded() {
+ // Remove the existing image reps since the icon data is loaded and they
+ // need to be re-created.
+ const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps();
+ for (size_t i = 0; i < image_reps.size(); ++i)
+ image_.RemoveRepresentation(image_reps[i].scale_factor());
+
+ SetIcon(image_);
+}
+
+ChromeSearchResultType PeopleResult::GetType() {
+ return SEARCH_PEOPLE_SEARCH_RESULT;
+}
+
+} // namespace app_list

Powered by Google App Engine
This is Rietveld 408576698