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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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/ui/app_list/search/people/people_result.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h"
14 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16
17 namespace {
18
19 const int kIconSize = 32;
20
21 } // namespace
22
23 namespace app_list {
24
25 PeopleResult::PeopleResult(Profile* profile,
26 const std::string& id,
27 const std::string& display_name,
28 double interaction_rank,
29 const GURL& image_url)
30 : profile_(profile),
31 id_(id),
32 display_name_(display_name),
33 interaction_rank_(interaction_rank),
34 image_url_(image_url),
35 weak_factory_(this) {
36 set_id(id_);
37 set_title(UTF8ToUTF16(display_name_));
38 set_relevance(interaction_rank_);
39
40 image_ = gfx::ImageSkia(
41 new UrlIconSource(base::Bind(&PeopleResult::OnIconLoaded,
42 weak_factory_.GetWeakPtr()),
43 profile_->GetRequestContext(),
44 image_url_,
45 kIconSize,
46 IDR_PROFILE_PICTURE_LOADING),
47 gfx::Size(kIconSize, kIconSize));
48 SetIcon(image_);
49 }
50
51 PeopleResult::~PeopleResult() {
52 }
53
54 void PeopleResult::Open(int event_flags) {
55 // TODO(rkc): Navigate to the person's profile?
56 }
57
58 void PeopleResult::InvokeAction(int action_index, int event_flags) {
59 DCHECK_EQ(0, action_index);
60 // TODO(rkc): Decide what to do here.
61 }
62
63 scoped_ptr<ChromeSearchResult> PeopleResult::Duplicate() {
64 return scoped_ptr<ChromeSearchResult>(new PeopleResult(profile_, id_,
65 display_name_,
66 interaction_rank_,
67 image_url_)).Pass();
68 }
69
70 void PeopleResult::OnIconLoaded() {
71 // Remove the existing image reps since the icon data is loaded and they
72 // need to be re-created.
73 const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps();
74 for (size_t i = 0; i < image_reps.size(); ++i)
75 image_.RemoveRepresentation(image_reps[i].scale_factor());
76
77 SetIcon(image_);
78 }
79
80 ChromeSearchResultType PeopleResult::GetType() {
81 return SEARCH_PEOPLE_SEARCH_RESULT;
82 }
83
84 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698