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

Side by Side Diff: chrome/browser/chromeos/launcher_search_provider/service.cc

Issue 1095793002: Implement onOpenResult. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add extension id check. Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/launcher_search_provider/service.h" 5 #include "chrome/browser/chromeos/launcher_search_provider/service.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h" 9 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h"
10 #include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_prov ider.h" 10 #include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_prov ider.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 extension_id, 77 extension_id,
78 make_scoped_ptr(new extensions::Event( 78 make_scoped_ptr(new extensions::Event(
79 api_launcher_search_provider::OnQueryEnded::kEventName, 79 api_launcher_search_provider::OnQueryEnded::kEventName,
80 api_launcher_search_provider::OnQueryEnded::Create( 80 api_launcher_search_provider::OnQueryEnded::Create(
81 std::to_string(query_id_))))); 81 std::to_string(query_id_)))));
82 } 82 }
83 83
84 is_query_running_ = false; 84 is_query_running_ = false;
85 } 85 }
86 86
87 void Service::OnOpenResult(const ExtensionId& extension_id,
88 const std::string& item_id) {
89 DCHECK(ContainsValue(GetListenerExtensionIds(), extension_id));
90
91 extensions::EventRouter* event_router =
92 extensions::EventRouter::Get(profile_);
93 event_router->DispatchEventToExtension(
94 extension_id,
95 make_scoped_ptr(new extensions::Event(
96 api_launcher_search_provider::OnOpenResult::kEventName,
97 api_launcher_search_provider::OnOpenResult::Create(item_id))));
98 }
99
87 void Service::SetSearchResults( 100 void Service::SetSearchResults(
88 const extensions::Extension* extension, 101 const extensions::Extension* extension,
89 const std::string& query_id, 102 const std::string& query_id,
90 const std::vector<linked_ptr< 103 const std::vector<linked_ptr<
91 extensions::api::launcher_search_provider::SearchResult>>& results) { 104 extensions::api::launcher_search_provider::SearchResult>>& results) {
92 // If query is not running or query_id is different from current query id, 105 // If query is not running or query_id is different from current query id,
93 // discard the results. 106 // discard the results.
94 if (!is_query_running_ || query_id != std::to_string(query_id_)) 107 if (!is_query_running_ || query_id != std::to_string(query_id_))
95 return; 108 return;
96 109
110 // If |extension| is not in the listener extensions list, ignore it.
111 if (!ContainsValue(GetListenerExtensionIds(), extension->id()))
yawano 2015/04/20 04:02:36 I noticed that we haven't checked extension id her
112 return;
113
97 // Set search results to provider. 114 // Set search results to provider.
98 DCHECK(provider_); 115 DCHECK(provider_);
99 ScopedVector<app_list::LauncherSearchResult> search_results; 116 ScopedVector<app_list::LauncherSearchResult> search_results;
100 for (const auto& result : results) { 117 for (const auto& result : results) {
101 const int relevance = 118 const int relevance =
102 std::min(kMaxSearchResultScore, std::max(result->relevance, 0)); 119 std::min(kMaxSearchResultScore, std::max(result->relevance, 0));
103 const GURL icon_url = 120 const GURL icon_url =
104 result->icon_url ? GURL(*result->icon_url.get()) : GURL(); 121 result->icon_url ? GURL(*result->icon_url.get()) : GURL();
105 122
106 app_list::LauncherSearchResult* search_result = 123 app_list::LauncherSearchResult* search_result =
(...skipping 20 matching lines...) Expand all
127 extensions::APIPermission::kLauncherSearchProvider); 144 extensions::APIPermission::kLauncherSearchProvider);
128 if (has_permission) 145 if (has_permission)
129 extension_ids.insert(extension->id()); 146 extension_ids.insert(extension->id());
130 } 147 }
131 148
132 return extension_ids; 149 return extension_ids;
133 } 150 }
134 151
135 } // namespace launcher_search_provider 152 } // namespace launcher_search_provider
136 } // namespace chromeos 153 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698