OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h" | |
13 #include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h" | 12 #include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h" |
14 #include "components/omnibox/browser/autocomplete_controller_delegate.h" | 13 #include "components/omnibox/browser/autocomplete_controller_delegate.h" |
15 #include "components/omnibox/browser/autocomplete_input.h" | 14 #include "components/omnibox/browser/autocomplete_input.h" |
16 #include "components/omnibox/browser/autocomplete_match.h" | 15 #include "components/omnibox/browser/autocomplete_match.h" |
17 #include "mojo/public/cpp/bindings/strong_binding.h" | 16 |
| 17 namespace content { |
| 18 class WebUI; |
| 19 } |
18 | 20 |
19 class AutocompleteController; | 21 class AutocompleteController; |
20 class Profile; | 22 class Profile; |
21 | 23 |
22 // Implementation of OmniboxUIHandlerMojo. StartOmniboxQuery() calls to a | 24 // Implementation of OmniboxUIHandlerMojo. StartOmniboxQuery() calls to a |
23 // private AutocompleteController. It also listens for updates from the | 25 // private AutocompleteController. It also listens for updates from the |
24 // AutocompleteController to OnResultChanged() and passes those results to | 26 // AutocompleteController to OnResultChanged() and passes those results to |
25 // the OmniboxPage. | 27 // the OmniboxPage. |
26 class OmniboxUIHandler : public AutocompleteControllerDelegate, | 28 class OmniboxUIHandler : public AutocompleteControllerDelegate, |
27 public OmniboxUIHandlerMojo, | 29 public OmniboxUIHandlerMojo { |
28 public MojoWebUIHandler { | |
29 public: | 30 public: |
30 // OmniboxUIHandler is deleted when the supplied pipe is destroyed. | 31 explicit OmniboxUIHandler(content::WebUI* web_ui); |
31 OmniboxUIHandler(Profile* profile, | |
32 mojo::InterfaceRequest<OmniboxUIHandlerMojo> request); | |
33 ~OmniboxUIHandler() override; | 32 ~OmniboxUIHandler() override; |
34 | 33 |
35 // AutocompleteControllerDelegate overrides: | 34 // AutocompleteControllerDelegate overrides: |
36 void OnResultChanged(bool default_match_changed) override; | 35 void OnResultChanged(bool default_match_changed) override; |
37 | 36 |
38 // OmniboxUIHandlerMojo overrides: | 37 // OmniboxUIHandlerMojo overrides: |
39 void StartOmniboxQuery(const mojo::String& input_string, | 38 void StartOmniboxQuery(const mojo::String& input_string, |
40 int32_t cursor_position, | 39 int32_t cursor_position, |
41 bool prevent_inline_autocomplete, | 40 bool prevent_inline_autocomplete, |
42 bool prefer_keyword, | 41 bool prefer_keyword, |
(...skipping 18 matching lines...) Expand all Loading... |
61 // Needed because we also pass timing information in the object we | 60 // Needed because we also pass timing information in the object we |
62 // hand back to the javascript. | 61 // hand back to the javascript. |
63 base::Time time_omnibox_started_; | 62 base::Time time_omnibox_started_; |
64 | 63 |
65 // The input used when starting the AutocompleteController. | 64 // The input used when starting the AutocompleteController. |
66 AutocompleteInput input_; | 65 AutocompleteInput input_; |
67 | 66 |
68 // Handle back to the page by which we can pass results. | 67 // Handle back to the page by which we can pass results. |
69 OmniboxPagePtr page_; | 68 OmniboxPagePtr page_; |
70 | 69 |
71 // The Profile* handed to us in our constructor. | 70 // The Profile* for the content::WebUI handed to us in our constructor. |
72 Profile* profile_; | 71 Profile* profile_; |
73 | 72 |
74 mojo::StrongBinding<OmniboxUIHandlerMojo> binding_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); | 73 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); |
77 }; | 74 }; |
78 | 75 |
79 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 76 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
OLD | NEW |