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/file_manager/app_id.h" | 9 #include "chrome/browser/chromeos/file_manager/app_id.h" |
10 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h" | 10 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 extensions::EventRouter* event_router = | 54 extensions::EventRouter* event_router = |
55 extensions::EventRouter::Get(profile_); | 55 extensions::EventRouter::Get(profile_); |
56 | 56 |
57 CacheListenerExtensionIds(); | 57 CacheListenerExtensionIds(); |
58 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { | 58 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { |
59 // Convert query_id_ to string here since queryId is defined as string in | 59 // Convert query_id_ to string here since queryId is defined as string in |
60 // javascript side API while we use uint32 internally to generate it. | 60 // javascript side API while we use uint32 internally to generate it. |
61 event_router->DispatchEventToExtension( | 61 event_router->DispatchEventToExtension( |
62 extension_id, | 62 extension_id, |
63 make_scoped_ptr(new extensions::Event( | 63 make_scoped_ptr(new extensions::Event( |
| 64 extensions::events::UNKNOWN, |
64 api_launcher_search_provider::OnQueryStarted::kEventName, | 65 api_launcher_search_provider::OnQueryStarted::kEventName, |
65 api_launcher_search_provider::OnQueryStarted::Create( | 66 api_launcher_search_provider::OnQueryStarted::Create( |
66 query_id_, query, max_result)))); | 67 query_id_, query, max_result)))); |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 void Service::OnQueryEnded() { | 71 void Service::OnQueryEnded() { |
71 DCHECK(is_query_running_); | 72 DCHECK(is_query_running_); |
72 provider_ = nullptr; | 73 provider_ = nullptr; |
73 | 74 |
74 extensions::EventRouter* event_router = | 75 extensions::EventRouter* event_router = |
75 extensions::EventRouter::Get(profile_); | 76 extensions::EventRouter::Get(profile_); |
76 | 77 |
77 CacheListenerExtensionIds(); | 78 CacheListenerExtensionIds(); |
78 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { | 79 for (const ExtensionId extension_id : *cached_listener_extension_ids_.get()) { |
79 event_router->DispatchEventToExtension( | 80 event_router->DispatchEventToExtension( |
80 extension_id, | 81 extension_id, |
81 make_scoped_ptr(new extensions::Event( | 82 make_scoped_ptr(new extensions::Event( |
| 83 extensions::events::UNKNOWN, |
82 api_launcher_search_provider::OnQueryEnded::kEventName, | 84 api_launcher_search_provider::OnQueryEnded::kEventName, |
83 api_launcher_search_provider::OnQueryEnded::Create(query_id_)))); | 85 api_launcher_search_provider::OnQueryEnded::Create(query_id_)))); |
84 } | 86 } |
85 | 87 |
86 is_query_running_ = false; | 88 is_query_running_ = false; |
87 } | 89 } |
88 | 90 |
89 void Service::OnOpenResult(const ExtensionId& extension_id, | 91 void Service::OnOpenResult(const ExtensionId& extension_id, |
90 const std::string& item_id) { | 92 const std::string& item_id) { |
91 CacheListenerExtensionIds(); | 93 CacheListenerExtensionIds(); |
92 CHECK(ContainsValue(*cached_listener_extension_ids_.get(), extension_id)); | 94 CHECK(ContainsValue(*cached_listener_extension_ids_.get(), extension_id)); |
93 | 95 |
94 extensions::EventRouter* event_router = | 96 extensions::EventRouter* event_router = |
95 extensions::EventRouter::Get(profile_); | 97 extensions::EventRouter::Get(profile_); |
96 event_router->DispatchEventToExtension( | 98 event_router->DispatchEventToExtension( |
97 extension_id, | 99 extension_id, |
98 make_scoped_ptr(new extensions::Event( | 100 make_scoped_ptr(new extensions::Event( |
| 101 extensions::events::UNKNOWN, |
99 api_launcher_search_provider::OnOpenResult::kEventName, | 102 api_launcher_search_provider::OnOpenResult::kEventName, |
100 api_launcher_search_provider::OnOpenResult::Create(item_id)))); | 103 api_launcher_search_provider::OnOpenResult::Create(item_id)))); |
101 } | 104 } |
102 | 105 |
103 void Service::SetSearchResults( | 106 void Service::SetSearchResults( |
104 const extensions::Extension* extension, | 107 const extensions::Extension* extension, |
105 scoped_ptr<ErrorReporter> error_reporter, | 108 scoped_ptr<ErrorReporter> error_reporter, |
106 const int query_id, | 109 const int query_id, |
107 const std::vector<linked_ptr< | 110 const std::vector<linked_ptr< |
108 extensions::api::launcher_search_provider::SearchResult>>& results) { | 111 extensions::api::launcher_search_provider::SearchResult>>& results) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 app_list::switches::IsDriveSearchEnabled()) || | 177 app_list::switches::IsDriveSearchEnabled()) || |
175 (extension->id() != file_manager::kFileManagerAppId && | 178 (extension->id() != file_manager::kFileManagerAppId && |
176 app_list::switches::IsLauncherSearchProviderApiEnabled())) | 179 app_list::switches::IsLauncherSearchProviderApiEnabled())) |
177 cached_listener_extension_ids_->insert(extension->id()); | 180 cached_listener_extension_ids_->insert(extension->id()); |
178 } | 181 } |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
182 } // namespace launcher_search_provider | 185 } // namespace launcher_search_provider |
183 } // namespace chromeos | 186 } // namespace chromeos |
OLD | NEW |