| OLD | NEW |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 extensions::EventRouter* event_router = | 52 extensions::EventRouter* event_router = |
| 53 extensions::EventRouter::Get(profile_); | 53 extensions::EventRouter::Get(profile_); |
| 54 | 54 |
| 55 CacheListenerExtensionIds(); | 55 CacheListenerExtensionIds(); |
| 56 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { | 56 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { |
| 57 // Convert query_id_ to string here since queryId is defined as string in | 57 // Convert query_id_ to string here since queryId is defined as string in |
| 58 // javascript side API while we use uint32 internally to generate it. | 58 // javascript side API while we use uint32 internally to generate it. |
| 59 event_router->DispatchEventToExtension( | 59 event_router->DispatchEventToExtension( |
| 60 extension_id, | 60 extension_id, |
| 61 make_scoped_ptr(new extensions::Event( | 61 make_scoped_ptr(new extensions::Event( |
| 62 extensions::events::UNKNOWN, |
| 62 api_launcher_search_provider::OnQueryStarted::kEventName, | 63 api_launcher_search_provider::OnQueryStarted::kEventName, |
| 63 api_launcher_search_provider::OnQueryStarted::Create( | 64 api_launcher_search_provider::OnQueryStarted::Create( |
| 64 query_id_, query, max_result)))); | 65 query_id_, query, max_result)))); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 | 68 |
| 68 void Service::OnQueryEnded() { | 69 void Service::OnQueryEnded() { |
| 69 DCHECK(is_query_running_); | 70 DCHECK(is_query_running_); |
| 70 provider_ = nullptr; | 71 provider_ = nullptr; |
| 71 | 72 |
| 72 extensions::EventRouter* event_router = | 73 extensions::EventRouter* event_router = |
| 73 extensions::EventRouter::Get(profile_); | 74 extensions::EventRouter::Get(profile_); |
| 74 | 75 |
| 75 CacheListenerExtensionIds(); | 76 CacheListenerExtensionIds(); |
| 76 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { | 77 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { |
| 77 event_router->DispatchEventToExtension( | 78 event_router->DispatchEventToExtension( |
| 78 extension_id, | 79 extension_id, |
| 79 make_scoped_ptr(new extensions::Event( | 80 make_scoped_ptr(new extensions::Event( |
| 81 extensions::events::UNKNOWN, |
| 80 api_launcher_search_provider::OnQueryEnded::kEventName, | 82 api_launcher_search_provider::OnQueryEnded::kEventName, |
| 81 api_launcher_search_provider::OnQueryEnded::Create(query_id_)))); | 83 api_launcher_search_provider::OnQueryEnded::Create(query_id_)))); |
| 82 } | 84 } |
| 83 | 85 |
| 84 is_query_running_ = false; | 86 is_query_running_ = false; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void Service::OnOpenResult(const ExtensionId& extension_id, | 89 void Service::OnOpenResult(const ExtensionId& extension_id, |
| 88 const std::string& item_id) { | 90 const std::string& item_id) { |
| 89 CacheListenerExtensionIds(); | 91 CacheListenerExtensionIds(); |
| 90 CHECK(ContainsValue(*cached_listener_extension_ids_.get(), extension_id)); | 92 CHECK(ContainsValue(*cached_listener_extension_ids_.get(), extension_id)); |
| 91 | 93 |
| 92 extensions::EventRouter* event_router = | 94 extensions::EventRouter* event_router = |
| 93 extensions::EventRouter::Get(profile_); | 95 extensions::EventRouter::Get(profile_); |
| 94 event_router->DispatchEventToExtension( | 96 event_router->DispatchEventToExtension( |
| 95 extension_id, | 97 extension_id, |
| 96 make_scoped_ptr(new extensions::Event( | 98 make_scoped_ptr(new extensions::Event( |
| 99 extensions::events::UNKNOWN, |
| 97 api_launcher_search_provider::OnOpenResult::kEventName, | 100 api_launcher_search_provider::OnOpenResult::kEventName, |
| 98 api_launcher_search_provider::OnOpenResult::Create(item_id)))); | 101 api_launcher_search_provider::OnOpenResult::Create(item_id)))); |
| 99 } | 102 } |
| 100 | 103 |
| 101 void Service::SetSearchResults( | 104 void Service::SetSearchResults( |
| 102 const extensions::Extension* extension, | 105 const extensions::Extension* extension, |
| 103 scoped_ptr<ErrorReporter> error_reporter, | 106 scoped_ptr<ErrorReporter> error_reporter, |
| 104 const int query_id, | 107 const int query_id, |
| 105 const std::vector<linked_ptr< | 108 const std::vector<linked_ptr< |
| 106 extensions::api::launcher_search_provider::SearchResult>>& results) { | 109 extensions::api::launcher_search_provider::SearchResult>>& results) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 extension->permissions_data(); | 167 extension->permissions_data(); |
| 165 const bool has_permission = permission_data->HasAPIPermission( | 168 const bool has_permission = permission_data->HasAPIPermission( |
| 166 extensions::APIPermission::kLauncherSearchProvider); | 169 extensions::APIPermission::kLauncherSearchProvider); |
| 167 if (has_permission) | 170 if (has_permission) |
| 168 cached_listener_extension_ids_->insert(extension->id()); | 171 cached_listener_extension_ids_->insert(extension->id()); |
| 169 } | 172 } |
| 170 } | 173 } |
| 171 | 174 |
| 172 } // namespace launcher_search_provider | 175 } // namespace launcher_search_provider |
| 173 } // namespace chromeos | 176 } // namespace chromeos |
| OLD | NEW |