OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/app_list/search/people/people_result.h" | 5 #include "chrome/browser/ui/app_list/search/people/people_result.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 17 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
18 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h" | 18 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 namespace app_list { | 55 namespace app_list { |
56 | 56 |
57 PeopleResult::PeopleResult(Profile* profile, | 57 PeopleResult::PeopleResult(Profile* profile, |
58 AppListControllerDelegate* controller, | 58 AppListControllerDelegate* controller, |
59 scoped_ptr<Person> person) | 59 scoped_ptr<Person> person) |
60 : profile_(profile), | 60 : profile_(profile), |
61 controller_(controller), | 61 controller_(controller), |
62 person_(person.Pass()), | 62 person_(std::move(person)), |
63 weak_factory_(this) { | 63 weak_factory_(this) { |
64 set_id(person_->id); | 64 set_id(person_->id); |
65 set_title(base::UTF8ToUTF16(person_->display_name)); | 65 set_title(base::UTF8ToUTF16(person_->display_name)); |
66 set_relevance(person_->interaction_rank); | 66 set_relevance(person_->interaction_rank); |
67 set_details(base::UTF8ToUTF16(person_->email)); | 67 set_details(base::UTF8ToUTF16(person_->email)); |
68 | 68 |
69 RefreshHangoutsExtensionId(); | 69 RefreshHangoutsExtensionId(); |
70 SetDefaultActions(); | 70 SetDefaultActions(); |
71 | 71 |
72 int icon_size = GetPreferredIconDimension(); | 72 int icon_size = GetPreferredIconDimension(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 SendEmail(); | 105 SendEmail(); |
106 break; | 106 break; |
107 default: | 107 default: |
108 LOG(ERROR) << "Invalid people search action: " << action_index; | 108 LOG(ERROR) << "Invalid people search action: " << action_index; |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 scoped_ptr<SearchResult> PeopleResult::Duplicate() const { | 113 scoped_ptr<SearchResult> PeopleResult::Duplicate() const { |
114 return scoped_ptr<SearchResult>( | 114 return scoped_ptr<SearchResult>( |
115 new PeopleResult(profile_, controller_, person_->Duplicate().Pass())); | 115 new PeopleResult(profile_, controller_, person_->Duplicate())); |
116 } | 116 } |
117 | 117 |
118 void PeopleResult::OnIconLoaded() { | 118 void PeopleResult::OnIconLoaded() { |
119 // Remove the existing image reps since the icon data is loaded and they | 119 // Remove the existing image reps since the icon data is loaded and they |
120 // need to be re-created. | 120 // need to be re-created. |
121 const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps(); | 121 const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps(); |
122 for (size_t i = 0; i < image_reps.size(); ++i) | 122 for (size_t i = 0; i < image_reps.size(); ++i) |
123 image_.RemoveRepresentation(image_reps[i].scale()); | 123 image_.RemoveRepresentation(image_reps[i].scale()); |
124 | 124 |
125 SetIcon(image_); | 125 SetIcon(image_); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 target->id = person_->owner_id; | 160 target->id = person_->owner_id; |
161 request.to.push_back(target); | 161 request.to.push_back(target); |
162 | 162 |
163 scoped_ptr<extensions::Event> event(new extensions::Event( | 163 scoped_ptr<extensions::Event> event(new extensions::Event( |
164 extensions::events::HANGOUTS_PRIVATE_ON_HANGOUT_REQUESTED, | 164 extensions::events::HANGOUTS_PRIVATE_ON_HANGOUT_REQUESTED, |
165 OnHangoutRequested::kEventName, OnHangoutRequested::Create(request))); | 165 OnHangoutRequested::kEventName, OnHangoutRequested::Create(request))); |
166 | 166 |
167 // TODO(rkc): Change this once we remove the hangoutsPrivate API. | 167 // TODO(rkc): Change this once we remove the hangoutsPrivate API. |
168 // See crbug.com/306672 | 168 // See crbug.com/306672 |
169 extensions::EventRouter::Get(profile_) | 169 extensions::EventRouter::Get(profile_) |
170 ->DispatchEventToExtension(hangouts_extension_id_, event.Pass()); | 170 ->DispatchEventToExtension(hangouts_extension_id_, std::move(event)); |
171 | 171 |
172 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat")); | 172 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat")); |
173 } | 173 } |
174 | 174 |
175 void PeopleResult::SendEmail() { | 175 void PeopleResult::SendEmail() { |
176 controller_->OpenURL(profile_, | 176 controller_->OpenURL(profile_, |
177 GURL(kEmailUrlPrefix + person_->email), | 177 GURL(kEmailUrlPrefix + person_->email), |
178 ui::PAGE_TRANSITION_LINK, | 178 ui::PAGE_TRANSITION_LINK, |
179 NEW_FOREGROUND_TAB); | 179 NEW_FOREGROUND_TAB); |
180 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail")); | 180 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail")); |
181 } | 181 } |
182 | 182 |
183 void PeopleResult::RefreshHangoutsExtensionId() { | 183 void PeopleResult::RefreshHangoutsExtensionId() { |
184 for (const char* id : extension_misc::kHangoutsExtensionIds) { | 184 for (const char* id : extension_misc::kHangoutsExtensionIds) { |
185 if (extensions::EventRouter::Get(profile_) | 185 if (extensions::EventRouter::Get(profile_) |
186 ->ExtensionHasEventListener(id, OnHangoutRequested::kEventName)) { | 186 ->ExtensionHasEventListener(id, OnHangoutRequested::kEventName)) { |
187 hangouts_extension_id_ = id; | 187 hangouts_extension_id_ = id; |
188 return; | 188 return; |
189 } | 189 } |
190 } | 190 } |
191 hangouts_extension_id_.clear(); | 191 hangouts_extension_id_.clear(); |
192 } | 192 } |
193 | 193 |
194 } // namespace app_list | 194 } // namespace app_list |
OLD | NEW |