Chromium Code Reviews| 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/autocomplete/autocomplete_controller_delegate.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 13 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 15 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h" | 15 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h" |
| 16 #include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h" | 16 #include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/remote_ptr.h" | |
| 18 | 17 |
| 19 class AutocompleteController; | 18 class AutocompleteController; |
| 20 class Profile; | 19 class Profile; |
| 21 | 20 |
| 22 // Implementation of OmniboxUIHandlerMojo. StartOmniboxQuery() calls to a | 21 // Implementation of OmniboxUIHandlerMojo. StartOmniboxQuery() calls to a |
| 23 // private AutocompleteController. It also listens for updates from the | 22 // private AutocompleteController. It also listens for updates from the |
| 24 // AutocompleteController to OnResultChanged() and passes those results to | 23 // AutocompleteController to OnResultChanged() and passes those results to |
| 25 // the OmniboxPage. | 24 // the OmniboxPage. |
| 26 class OmniboxUIHandler : public AutocompleteControllerDelegate, | 25 class OmniboxUIHandler : public AutocompleteControllerDelegate, |
| 27 public OmniboxUIHandlerMojo, | 26 public mojo::InterfaceImpl<OmniboxUIHandlerMojo>, |
|
DaveMoore
2014/05/08 18:27:30
This is kind of a mouthful. Should we generate a s
| |
| 28 public MojoWebUIHandler { | 27 public MojoWebUIHandler { |
| 29 public: | 28 public: |
| 30 OmniboxUIHandler(ScopedOmniboxPageHandle handle, Profile* profile); | 29 explicit OmniboxUIHandler(Profile* profile); |
| 31 virtual ~OmniboxUIHandler(); | 30 virtual ~OmniboxUIHandler(); |
| 32 | 31 |
| 33 // AutocompleteControllerDelegate overrides: | 32 // AutocompleteControllerDelegate overrides: |
| 34 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | 33 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; |
| 35 | 34 |
| 35 // ErrorHandler overrides: | |
| 36 virtual void OnConnectionError() OVERRIDE { | |
| 37 // TODO(darin): How should we handle connection error? | |
| 38 } | |
| 39 | |
| 36 // OmniboxUIHandlerMojo overrides: | 40 // OmniboxUIHandlerMojo overrides: |
| 41 virtual void SetClient(OmniboxPage* page) OVERRIDE; | |
| 37 virtual void StartOmniboxQuery(const mojo::String& input_string, | 42 virtual void StartOmniboxQuery(const mojo::String& input_string, |
| 38 int32_t cursor_position, | 43 int32_t cursor_position, |
| 39 bool prevent_inline_autocomplete, | 44 bool prevent_inline_autocomplete, |
| 40 bool prefer_keyword, | 45 bool prefer_keyword, |
| 41 int32_t page_classification) OVERRIDE; | 46 int32_t page_classification) OVERRIDE; |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 // Looks up whether the hostname is a typed host (i.e., has received | 49 // Looks up whether the hostname is a typed host (i.e., has received |
| 45 // typed visits). Return true if the lookup succeeded; if so, the | 50 // typed visits). Return true if the lookup succeeded; if so, the |
| 46 // value of |is_typed_host| is set appropriately. | 51 // value of |is_typed_host| is set appropriately. |
| 47 bool LookupIsTypedHost(const base::string16& host, bool* is_typed_host) const; | 52 bool LookupIsTypedHost(const base::string16& host, bool* is_typed_host) const; |
| 48 | 53 |
| 49 // Re-initializes the AutocompleteController in preparation for the | 54 // Re-initializes the AutocompleteController in preparation for the |
| 50 // next query. | 55 // next query. |
| 51 void ResetController(); | 56 void ResetController(); |
| 52 | 57 |
| 53 mojo::RemotePtr<OmniboxPage> page_; | 58 OmniboxPage* page_; |
| 54 | 59 |
| 55 // The omnibox AutocompleteController that collects/sorts/dup- | 60 // The omnibox AutocompleteController that collects/sorts/dup- |
| 56 // eliminates the results as they come in. | 61 // eliminates the results as they come in. |
| 57 scoped_ptr<AutocompleteController> controller_; | 62 scoped_ptr<AutocompleteController> controller_; |
| 58 | 63 |
| 59 // Time the user's input was sent to the omnibox to start searching. | 64 // Time the user's input was sent to the omnibox to start searching. |
| 60 // Needed because we also pass timing information in the object we | 65 // Needed because we also pass timing information in the object we |
| 61 // hand back to the javascript. | 66 // hand back to the javascript. |
| 62 base::Time time_omnibox_started_; | 67 base::Time time_omnibox_started_; |
| 63 | 68 |
| 64 // The input used when starting the AutocompleteController. | 69 // The input used when starting the AutocompleteController. |
| 65 AutocompleteInput input_; | 70 AutocompleteInput input_; |
| 66 | 71 |
| 67 // The Profile* handed to us in our constructor. | 72 // The Profile* handed to us in our constructor. |
| 68 Profile* profile_; | 73 Profile* profile_; |
| 69 | 74 |
| 70 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); | 75 DISALLOW_COPY_AND_ASSIGN(OmniboxUIHandler); |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ | 78 #endif // CHROME_BROWSER_UI_WEBUI_OMNIBOX_OMNIBOX_UI_HANDLER_H_ |
| OLD | NEW |