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 #ifndef CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ |
7 | 7 |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/extensions/api/launcher_search_provider.h" |
9 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
10 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
11 #include "extensions/browser/event_router.h" | 12 #include "extensions/browser/event_router.h" |
12 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
13 | 14 |
| 15 namespace app_list { |
| 16 class LauncherSearchProvider; |
| 17 } // namespace app_list |
| 18 |
14 namespace chromeos { | 19 namespace chromeos { |
15 namespace launcher_search_provider { | 20 namespace launcher_search_provider { |
16 | 21 |
17 // Manages listener extensions and routes events. Listener extensions are | 22 // Manages listener extensions and routes events. Listener extensions are |
18 // extensions which are allowed to use this API. When this API becomes public, | 23 // extensions which are allowed to use this API. When this API becomes public, |
19 // this API is white listed for file manager, and opt-in for other extensions. | 24 // this API is white listed for file manager, and opt-in for other extensions. |
20 // This service provides access control for it. | 25 // This service provides access control for it. |
21 // | 26 // |
22 // TODO(yawano): Implement opt-in control (crbug.com/440649). | 27 // TODO(yawano): Implement opt-in control (crbug.com/440649). |
23 class Service : public KeyedService { | 28 class Service : public KeyedService { |
24 public: | 29 public: |
25 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry); | 30 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry); |
26 ~Service() override; | 31 ~Service() override; |
27 static Service* Get(content::BrowserContext* context); | 32 static Service* Get(content::BrowserContext* context); |
28 | 33 |
29 // Dispatches onQueryStarted events to listener extensions. | 34 // Dispatches onQueryStarted events to listener extensions. |
30 void OnQueryStarted(const std::string& query, const int max_result); | 35 void OnQueryStarted(app_list::LauncherSearchProvider* provider, |
| 36 const std::string& query, |
| 37 const int max_result); |
31 | 38 |
32 // Dispatches onQueryEnded events to listener extensions. | 39 // Dispatches onQueryEnded events to listener extensions. |
33 void OnQueryEnded(); | 40 void OnQueryEnded(); |
34 | 41 |
| 42 // Sets search results of a listener extension. |
| 43 void SetSearchResults( |
| 44 const extensions::Extension* extension, |
| 45 const std::string& query_id, |
| 46 std::vector<linked_ptr< |
| 47 extensions::api::launcher_search_provider::SearchResult>> results); |
| 48 |
35 // Returns true if there is a running query. | 49 // Returns true if there is a running query. |
36 bool IsQueryRunning() const; | 50 bool IsQueryRunning() const; |
37 | 51 |
38 private: | 52 private: |
39 // Returns extension ids of listener extensions. | 53 // Returns extension ids of listener extensions. |
40 std::set<extensions::ExtensionId> GetListenerExtensionIds(); | 54 std::set<extensions::ExtensionId> GetListenerExtensionIds(); |
41 | 55 |
42 Profile* const profile_; | 56 Profile* const profile_; |
43 extensions::ExtensionRegistry* extension_registry_; | 57 extensions::ExtensionRegistry* extension_registry_; |
| 58 app_list::LauncherSearchProvider* provider_; |
44 uint32 query_id_; | 59 uint32 query_id_; |
45 bool is_query_running_; | 60 bool is_query_running_; |
46 | 61 |
47 DISALLOW_COPY_AND_ASSIGN(Service); | 62 DISALLOW_COPY_AND_ASSIGN(Service); |
48 }; | 63 }; |
49 | 64 |
50 } // namespace launcher_search_provider | 65 } // namespace launcher_search_provider |
51 } // namespace chromeos | 66 } // namespace chromeos |
52 | 67 |
53 #endif // CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ | 68 #endif // CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ |
OLD | NEW |