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

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

Issue 238963002: Use EventRouter instead of ExtensionSystem::Get->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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/search/common/url_icon_source.h" 15 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h"
16 #include "chrome/browser/ui/app_list/search/people/person.h" 16 #include "chrome/browser/ui/app_list/search/people/person.h"
17 #include "chrome/browser/ui/browser_navigator.h" 17 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/common/extensions/api/hangouts_private.h" 18 #include "chrome/common/extensions/api/hangouts_private.h"
19 #include "components/signin/core/browser/profile_oauth2_token_service.h" 19 #include "components/signin/core/browser/profile_oauth2_token_service.h"
20 #include "components/signin/core/browser/signin_manager.h" 20 #include "components/signin/core/browser/signin_manager.h"
21 #include "content/public/browser/user_metrics.h" 21 #include "content/public/browser/user_metrics.h"
22 #include "extensions/browser/event_router.h" 22 #include "extensions/browser/event_router.h"
23 #include "extensions/browser/extension_system.h"
24 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
25 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
28 27
29 namespace OnHangoutRequested = 28 namespace OnHangoutRequested =
30 extensions::api::hangouts_private::OnHangoutRequested; 29 extensions::api::hangouts_private::OnHangoutRequested;
31 30
32 using extensions::api::hangouts_private::User; 31 using extensions::api::hangouts_private::User;
33 using extensions::api::hangouts_private::HangoutRequest; 32 using extensions::api::hangouts_private::HangoutRequest;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 linked_ptr<User> target(new User()); 156 linked_ptr<User> target(new User());
158 target->id = person_->owner_id; 157 target->id = person_->owner_id;
159 request.to.push_back(target); 158 request.to.push_back(target);
160 159
161 scoped_ptr<extensions::Event> event( 160 scoped_ptr<extensions::Event> event(
162 new extensions::Event(OnHangoutRequested::kEventName, 161 new extensions::Event(OnHangoutRequested::kEventName,
163 OnHangoutRequested::Create(request))); 162 OnHangoutRequested::Create(request)));
164 163
165 // TODO(rkc): Change this once we remove the hangoutsPrivate API. 164 // TODO(rkc): Change this once we remove the hangoutsPrivate API.
166 // See crbug.com/306672 165 // See crbug.com/306672
167 extensions::ExtensionSystem::Get( 166 extensions::EventRouter::Get(profile_)
168 profile_)->event_router()->DispatchEventToExtension( 167 ->DispatchEventToExtension(hangouts_extension_id_, event.Pass());
169 hangouts_extension_id_, event.Pass());
170 168
171 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat")); 169 content::RecordAction(base::UserMetricsAction("PeopleSearch_OpenChat"));
172 } 170 }
173 171
174 void PeopleResult::SendEmail() { 172 void PeopleResult::SendEmail() {
175 chrome::NavigateParams params(profile_, 173 chrome::NavigateParams params(profile_,
176 GURL(kEmailUrlPrefix + person_->email), 174 GURL(kEmailUrlPrefix + person_->email),
177 content::PAGE_TRANSITION_LINK); 175 content::PAGE_TRANSITION_LINK);
178 // If no window exists, this will open a new window this one tab. 176 // If no window exists, this will open a new window this one tab.
179 params.disposition = NEW_FOREGROUND_TAB; 177 params.disposition = NEW_FOREGROUND_TAB;
180 chrome::Navigate(&params); 178 chrome::Navigate(&params);
181 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail")); 179 content::RecordAction(base::UserMetricsAction("PeopleSearch_SendEmail"));
182 } 180 }
183 181
184 void PeopleResult::RefreshHangoutsExtensionId() { 182 void PeopleResult::RefreshHangoutsExtensionId() {
185 // TODO(rkc): Change this once we remove the hangoutsPrivate API. 183 // TODO(rkc): Change this once we remove the hangoutsPrivate API.
186 // See crbug.com/306672 184 // See crbug.com/306672
187 for (size_t i = 0; i < arraysize(kHangoutsExtensionIds); ++i) { 185 for (size_t i = 0; i < arraysize(kHangoutsExtensionIds); ++i) {
188 if (extensions::ExtensionSystem::Get( 186 if (extensions::EventRouter::Get(profile_)->ExtensionHasEventListener(
189 profile_)->event_router()->ExtensionHasEventListener(
190 kHangoutsExtensionIds[i], OnHangoutRequested::kEventName)) { 187 kHangoutsExtensionIds[i], OnHangoutRequested::kEventName)) {
191 hangouts_extension_id_ = kHangoutsExtensionIds[i]; 188 hangouts_extension_id_ = kHangoutsExtensionIds[i];
192 return; 189 return;
193 } 190 }
194 } 191 }
195 hangouts_extension_id_.clear(); 192 hangouts_extension_id_.clear();
196 } 193 }
197 194
198 ChromeSearchResultType PeopleResult::GetType() { 195 ChromeSearchResultType PeopleResult::GetType() {
199 return SEARCH_PEOPLE_SEARCH_RESULT; 196 return SEARCH_PEOPLE_SEARCH_RESULT;
200 } 197 }
201 198
202 } // namespace app_list 199 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698