Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/chromeos/launcher_search_provider/service.h

Issue 1071093002: Implement setSearchResults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Relevance score should be provided in a range from 0 to 4. 0 is the lowest
23 // relevance, 4 is the highest.
24 const int kMaxSearchResultScore = 4;
25
17 // Manages listener extensions and routes events. Listener extensions are 26 // Manages listener extensions and routes events. Listener extensions are
18 // extensions which are allowed to use this API. When this API becomes public, 27 // 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. 28 // this API is white listed for file manager, and opt-in for other extensions.
20 // This service provides access control for it. 29 // This service provides access control for it.
21 // 30 //
22 // TODO(yawano): Implement opt-in control (crbug.com/440649). 31 // TODO(yawano): Implement opt-in control (crbug.com/440649).
23 class Service : public KeyedService { 32 class Service : public KeyedService {
24 public: 33 public:
25 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry); 34 Service(Profile* profile, extensions::ExtensionRegistry* extension_registry);
26 ~Service() override; 35 ~Service() override;
27 static Service* Get(content::BrowserContext* context); 36 static Service* Get(content::BrowserContext* context);
28 37
29 // Dispatches onQueryStarted events to listener extensions. 38 // Dispatches onQueryStarted events to listener extensions.
30 void OnQueryStarted(const std::string& query, const int max_result); 39 void OnQueryStarted(app_list::LauncherSearchProvider* provider,
40 const std::string& query,
41 const int max_result);
31 42
32 // Dispatches onQueryEnded events to listener extensions. 43 // Dispatches onQueryEnded events to listener extensions.
33 void OnQueryEnded(); 44 void OnQueryEnded();
34 45
46 // Sets search results of a listener extension.
47 void SetSearchResults(
48 const extensions::Extension* extension,
49 const std::string& query_id,
50 const std::vector<linked_ptr<
51 extensions::api::launcher_search_provider::SearchResult>>& results);
52
35 // Returns true if there is a running query. 53 // Returns true if there is a running query.
36 bool IsQueryRunning() const; 54 bool IsQueryRunning() const;
37 55
38 private: 56 private:
39 // Returns extension ids of listener extensions. 57 // Returns extension ids of listener extensions.
40 std::set<extensions::ExtensionId> GetListenerExtensionIds(); 58 std::set<extensions::ExtensionId> GetListenerExtensionIds();
41 59
42 Profile* const profile_; 60 Profile* const profile_;
43 extensions::ExtensionRegistry* extension_registry_; 61 extensions::ExtensionRegistry* extension_registry_;
62 app_list::LauncherSearchProvider* provider_;
44 uint32 query_id_; 63 uint32 query_id_;
45 bool is_query_running_; 64 bool is_query_running_;
46 65
47 DISALLOW_COPY_AND_ASSIGN(Service); 66 DISALLOW_COPY_AND_ASSIGN(Service);
48 }; 67 };
49 68
50 } // namespace launcher_search_provider 69 } // namespace launcher_search_provider
51 } // namespace chromeos 70 } // namespace chromeos
52 71
53 #endif // CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_ 72 #endif // CHROME_BROWSER_CHROMEOS_LAUNCHER_SEARCH_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698