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

Unified Diff: chrome/browser/chromeos/launcher_search_provider/service.cc

Issue 1043373002: Implement onQueryEnded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/launcher_search_provider/service.cc
diff --git a/chrome/browser/chromeos/launcher_search_provider/service.cc b/chrome/browser/chromeos/launcher_search_provider/service.cc
index f2b55bb047367a3eb9591f6c00e9d467e291f121..eadb11d82e05e7c9b2e2c472f7203f55c99c94ed 100644
--- a/chrome/browser/chromeos/launcher_search_provider/service.cc
+++ b/chrome/browser/chromeos/launcher_search_provider/service.cc
@@ -20,7 +20,10 @@ namespace launcher_search_provider {
Service::Service(Profile* profile,
extensions::ExtensionRegistry* extension_registry)
- : profile_(profile), extension_registry_(extension_registry), query_id_(0) {
+ : profile_(profile),
+ extension_registry_(extension_registry),
+ query_id_(0),
+ is_query_running_(false) {
}
Service::~Service() {
@@ -32,6 +35,9 @@ Service* Service::Get(content::BrowserContext* context) {
}
void Service::OnQueryStarted(const std::string& query, const int max_result) {
+ DCHECK(!is_query_running_);
+ is_query_running_ = true;
+
++query_id_;
extensions::EventRouter* event_router =
@@ -48,6 +54,29 @@ void Service::OnQueryStarted(const std::string& query, const int max_result) {
}
}
+void Service::OnQueryEnded() {
+ DCHECK(is_query_running_);
+
+ extensions::EventRouter* event_router =
+ extensions::EventRouter::Get(profile_);
+
+ std::set<ExtensionId> extension_ids = GetListenerExtensionIds();
+ for (const ExtensionId extension_id : extension_ids) {
+ event_router->DispatchEventToExtension(
+ extension_id,
+ make_scoped_ptr(new extensions::Event(
Matt Giuca 2015/04/01 07:49:23 This can probably be abstracted into a private met
yawano 2015/04/01 11:26:20 Since DispatchEventToExtension takes scoped_ptr, i
Matt Giuca 2015/04/01 23:05:04 Yes, you can return scoped_ptrs from functions jus
yawano 2015/04/02 02:34:37 As far as I understand correctly, I think Dispatch
satorux1 2015/04/02 03:50:36 I guess the two loops are small enough so we don't
calamity 2015/04/02 05:50:04 You can use Value::DeepCopy? Also, you should prob
yawano 2015/04/02 06:42:19 Yes, but I'm not sure it's okay to deep copy event
+ api_launcher_search_provider::OnQueryEnded::kEventName,
+ api_launcher_search_provider::OnQueryEnded::Create(
+ std::to_string(query_id_)))));
+ }
+
+ is_query_running_ = false;
+}
+
+bool Service::IsQueryRunning() const {
+ return is_query_running_;
+}
+
std::set<ExtensionId> Service::GetListenerExtensionIds() {
std::set<ExtensionId> extension_ids;

Powered by Google App Engine
This is Rietveld 408576698