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