| Index: chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
|
| diff --git a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
|
| index ff030652d01de97fdf6e139040d878096cb5ec26..af1dc8b275cdb7bd3179a98791fb8d97e32f162c 100644
|
| --- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
|
| +++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
|
| @@ -11,62 +11,35 @@
|
| #include "base/time/time.h"
|
| #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
|
| #include "chrome/browser/autocomplete/autocomplete_match.h"
|
| -#include "content/public/browser/web_ui_message_handler.h"
|
| +#include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
|
| +#include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h"
|
| +#include "mojo/public/cpp/bindings/remote_ptr.h"
|
|
|
| class AutocompleteController;
|
| class Profile;
|
|
|
| -namespace base {
|
| -class ListValue;
|
| -}
|
| -
|
| -// UI Handler for chrome://omnibox/
|
| -// It listens for calls from javascript to StartOmniboxQuery() and
|
| -// passes those calls to its private AutocompleteController. It also
|
| -// listens for updates from the AutocompleteController to OnResultChanged()
|
| -// and passes those results on calling back into the Javascript to
|
| -// update the page.
|
| +// Implementation of OmniboxUIHandlerMojo. StartOmniboxQuery() calls to a
|
| +// private AutocompleteController. It also listens for updates from the
|
| +// AutocompleteController to OnResultChanged() and passes those results to
|
| +// the OmniboxPage.
|
| class OmniboxUIHandler : public AutocompleteControllerDelegate,
|
| - public content::WebUIMessageHandler {
|
| + public chrome::OmniboxUIHandlerMojo,
|
| + public MojoWebUIHandler {
|
| public:
|
| - explicit OmniboxUIHandler(Profile* profile);
|
| + OmniboxUIHandler(chrome::ScopedOmniboxPageHandle handle, Profile* profile);
|
| virtual ~OmniboxUIHandler();
|
|
|
| - // AutocompleteControllerDelegate implementation.
|
| - // Gets called when the result set of the AutocompleteController changes.
|
| - // We transform the AutocompleteResult into a Javascript object and
|
| - // call the Javascript function gotNewAutocompleteResult with it.
|
| - // |default_match_changed| is given to us by the AutocompleteController
|
| - // but we don't need it. It's ignored.
|
| + // AutocompleteControllerDelegate overrides:
|
| virtual void OnResultChanged(bool default_match_changed) OVERRIDE;
|
|
|
| - protected:
|
| - // WebUIMessageHandler implementation.
|
| - // Register our handler to get callbacks from javascript for
|
| - // startOmniboxQuery().
|
| - virtual void RegisterMessages() OVERRIDE;
|
| + // OmniboxUIHandlerMojo overrides:
|
| + virtual void StartOmniboxQuery(const mojo::String& input_string,
|
| + int32_t cursor_position,
|
| + bool prevent_inline_autocomplete,
|
| + bool prefer_keyword,
|
| + int32_t page_classification) OVERRIDE;
|
|
|
| private:
|
| - // Gets called from the javascript when a user enters text into the
|
| - // chrome://omnibox/ text box and clicks submit or hits enter.
|
| - // |input| is expected to be a four-element list:
|
| - // - first element: input string.
|
| - // - second element: the cursor position.
|
| - // - third element: boolean indicating whether we should set
|
| - // prevent_inline_autocomplete or not.
|
| - // - fourth element: boolean indicating whether we should set prefer_keyword
|
| - // - fifth element: current page classification value (enum
|
| - // PageClassification from omnibox_event.proto)
|
| - void StartOmniboxQuery(const base::ListValue* input);
|
| -
|
| - // Helper function for OnResultChanged().
|
| - // Takes an iterator over AutocompleteMatches and packages them into
|
| - // the DictionaryValue output, all stored under the given prefix.
|
| - void AddResultToDictionary(const std::string& prefix,
|
| - ACMatches::const_iterator result_it,
|
| - ACMatches::const_iterator end,
|
| - base::DictionaryValue* output);
|
| -
|
| // Looks up whether the hostname is a typed host (i.e., has received
|
| // typed visits). Return true if the lookup succeeded; if so, the
|
| // value of |is_typed_host| is set appropriately.
|
| @@ -76,6 +49,8 @@ class OmniboxUIHandler : public AutocompleteControllerDelegate,
|
| // next query.
|
| void ResetController();
|
|
|
| + mojo::RemotePtr<chrome::OmniboxPage> page_;
|
| +
|
| // The omnibox AutocompleteController that collects/sorts/dup-
|
| // eliminates the results as they come in.
|
| scoped_ptr<AutocompleteController> controller_;
|
|
|