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

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

Issue 644863002: Introduce OpenURL to AppListControllerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 2 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
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
15 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h" 16 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h"
16 #include "chrome/browser/ui/app_list/search/people/person.h" 17 #include "chrome/browser/ui/app_list/search/people/person.h"
17 #include "chrome/browser/ui/app_list/search/search_util.h" 18 #include "chrome/browser/ui/app_list/search/search_util.h"
18 #include "chrome/browser/ui/browser_navigator.h"
19 #include "chrome/common/extensions/api/hangouts_private.h" 19 #include "chrome/common/extensions/api/hangouts_private.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "components/signin/core/browser/profile_oauth2_token_service.h" 21 #include "components/signin/core/browser/profile_oauth2_token_service.h"
22 #include "components/signin/core/browser/signin_manager.h" 22 #include "components/signin/core/browser/signin_manager.h"
23 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
24 #include "extensions/browser/event_router.h" 24 #include "extensions/browser/event_router.h"
25 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 28
(...skipping 25 matching lines...) Expand all
54 if (image_filename.empty()) 54 if (image_filename.empty())
55 return url; 55 return url;
56 56
57 return url.Resolve(kImageSizePath + image_filename); 57 return url.Resolve(kImageSizePath + image_filename);
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 namespace app_list { 62 namespace app_list {
63 63
64 PeopleResult::PeopleResult(Profile* profile, scoped_ptr<Person> person) 64 PeopleResult::PeopleResult(Profile* profile,
65 : profile_(profile), person_(person.Pass()), weak_factory_(this) { 65 AppListControllerDelegate* controller,
66 scoped_ptr<Person> person)
67 : profile_(profile),
68 controller_(controller),
69 person_(person.Pass()),
70 weak_factory_(this) {
66 set_id(person_->id); 71 set_id(person_->id);
67 set_title(base::UTF8ToUTF16(person_->display_name)); 72 set_title(base::UTF8ToUTF16(person_->display_name));
68 set_relevance(person_->interaction_rank); 73 set_relevance(person_->interaction_rank);
69 set_details(base::UTF8ToUTF16(person_->email)); 74 set_details(base::UTF8ToUTF16(person_->email));
70 75
71 RefreshHangoutsExtensionId(); 76 RefreshHangoutsExtensionId();
72 SetDefaultActions(); 77 SetDefaultActions();
73 78
74 int icon_size = GetPreferredIconDimension(); 79 int icon_size = GetPreferredIconDimension();
75 image_ = gfx::ImageSkia( 80 image_ = gfx::ImageSkia(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 SendEmail(); 112 SendEmail();
108 break; 113 break;
109 default: 114 default:
110 LOG(ERROR) << "Invalid people search action: " << action_index; 115 LOG(ERROR) << "Invalid people search action: " << action_index;
111 } 116 }
112 } 117 }
113 } 118 }
114 119
115 scoped_ptr<SearchResult> PeopleResult::Duplicate() { 120 scoped_ptr<SearchResult> PeopleResult::Duplicate() {
116 return scoped_ptr<SearchResult>( 121 return scoped_ptr<SearchResult>(
117 new PeopleResult(profile_, person_->Duplicate().Pass())); 122 new PeopleResult(profile_, controller_, person_->Duplicate().Pass()));
118 } 123 }
119 124
120 void PeopleResult::OnIconLoaded() { 125 void PeopleResult::OnIconLoaded() {
121 // Remove the existing image reps since the icon data is loaded and they 126 // Remove the existing image reps since the icon data is loaded and they
122 // need to be re-created. 127 // need to be re-created.
123 const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps(); 128 const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps();
124 for (size_t i = 0; i < image_reps.size(); ++i) 129 for (size_t i = 0; i < image_reps.size(); ++i)
125 image_.RemoveRepresentation(image_reps[i].scale()); 130 image_.RemoveRepresentation(image_reps[i].scale());
126 131
127 SetIcon(image_); 132 SetIcon(image_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 173
169 // TODO(rkc): Change this once we remove the hangoutsPrivate API. 174 // TODO(rkc): Change this once we remove the hangoutsPrivate API.
170 // See crbug.com/306672 175 // See crbug.com/306672
171 extensions::EventRouter::Get(profile_) 176 extensions::EventRouter::Get(profile_)
172 ->DispatchEventToExtension(hangouts_extension_id_, event.Pass()); 177 ->DispatchEventToExtension(hangouts_extension_id_, event.Pass());
173 178
174 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat")); 179 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat"));
175 } 180 }
176 181
177 void PeopleResult::SendEmail() { 182 void PeopleResult::SendEmail() {
178 chrome::NavigateParams params(profile_, 183 controller_->OpenURL(profile_,
179 GURL(kEmailUrlPrefix + person_->email), 184 GURL(kEmailUrlPrefix + person_->email),
180 ui::PAGE_TRANSITION_LINK); 185 ui::PAGE_TRANSITION_LINK,
181 // If no window exists, this will open a new window this one tab. 186 NEW_FOREGROUND_TAB);
182 params.disposition = NEW_FOREGROUND_TAB;
183 chrome::Navigate(&params);
184 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail")); 187 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail"));
185 } 188 }
186 189
187 void PeopleResult::RefreshHangoutsExtensionId() { 190 void PeopleResult::RefreshHangoutsExtensionId() {
188 // TODO(rkc): Change this once we remove the hangoutsPrivate API. 191 // TODO(rkc): Change this once we remove the hangoutsPrivate API.
189 // See crbug.com/306672 192 // See crbug.com/306672
190 for (size_t i = 0; i < arraysize(kHangoutsExtensionIds); ++i) { 193 for (size_t i = 0; i < arraysize(kHangoutsExtensionIds); ++i) {
191 if (extensions::EventRouter::Get(profile_)->ExtensionHasEventListener( 194 if (extensions::EventRouter::Get(profile_)->ExtensionHasEventListener(
192 kHangoutsExtensionIds[i], OnHangoutRequested::kEventName)) { 195 kHangoutsExtensionIds[i], OnHangoutRequested::kEventName)) {
193 hangouts_extension_id_ = kHangoutsExtensionIds[i]; 196 hangouts_extension_id_ = kHangoutsExtensionIds[i];
194 return; 197 return;
195 } 198 }
196 } 199 }
197 hangouts_extension_id_.clear(); 200 hangouts_extension_id_.clear();
198 } 201 }
199 202
200 } // namespace app_list 203 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698