NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / app_list / search / search_controller.h
blob96107000adcb91c5c4f2a71d36d744c4552f829a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_SEARCH_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_SEARCH_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/timer/timer.h"
12 #include "chrome/browser/ui/app_list/search/mixer.h"
13 #include "ui/app_list/app_list_model.h"
14 #include "ui/app_list/speech_ui_model_observer.h"
16 class AppListControllerDelegate;
17 class Profile;
19 namespace app_list {
21 class History;
22 class SearchBoxModel;
23 class SearchProvider;
24 class SearchResult;
25 class SpeechUIModel;
27 // Controller that collects query from given SearchBoxModel, dispatches it
28 // to all search providers, then invokes the mixer to mix and to publish the
29 // results to the given SearchResults UI model.
30 class SearchController : public SpeechUIModelObserver {
31 public:
32 SearchController(Profile* profile,
33 SearchBoxModel* search_box,
34 AppListModel::SearchResults* results,
35 SpeechUIModel* speech_ui,
36 AppListControllerDelegate* list_controller);
37 virtual ~SearchController();
39 void Init();
41 void Start();
42 void Stop();
44 void OpenResult(SearchResult* result, int event_flags);
45 void InvokeResultAction(SearchResult* result,
46 int action_index,
47 int event_flags);
49 private:
50 typedef ScopedVector<SearchProvider> Providers;
52 // Takes ownership of |provider| and associates it with given mixer group.
53 void AddProvider(Mixer::GroupId group,
54 scoped_ptr<SearchProvider> provider);
56 // Invoked when the search results are changed.
57 void OnResultsChanged();
59 // SpeechUIModelObserver overrides:
60 virtual void OnSpeechRecognitionStateChanged(
61 SpeechRecognitionState new_state) OVERRIDE;
63 Profile* profile_;
64 SearchBoxModel* search_box_;
65 SpeechUIModel* speech_ui_;
66 AppListControllerDelegate* list_controller_;
68 bool dispatching_query_;
69 Providers providers_;
70 scoped_ptr<Mixer> mixer_;
71 History* history_; // BrowserContextKeyedService, not owned.
73 base::OneShotTimer<SearchController> stop_timer_;
75 DISALLOW_COPY_AND_ASSIGN(SearchController);
78 } // namespace app_list
80 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_SEARCH_CONTROLLER_H_