Chromium Code Reviews| 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; |