diff options
Diffstat (limited to 'chromium/chrome/browser/ui/webui/omnibox')
5 files changed, 39 insertions, 37 deletions
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom index 7ffa3971673..e113fded051 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom @@ -52,9 +52,10 @@ struct AutocompleteResultsForProvider { }; struct OmniboxResponse { - bool done; + int32 cursor_position; // Time delta since the request was started, in milliseconds. int32 time_since_omnibox_started_ms; + bool done; // The inferred metrics::OmniboxInputType of the request represented as a // string. string type; @@ -67,7 +68,7 @@ struct OmniboxResponse { interface OmniboxPageHandler { // Registers the webui page. - SetClientPage(OmniboxPage page); + SetClientPage(pending_remote<OmniboxPage> page); // Prompts a autocopmlete controller to process an omnibox query. StartOmniboxQuery(string input_string, bool reset_autocomplete_controller, diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc index 3c90ef1508e..c8dc602ed4d 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc @@ -222,8 +222,8 @@ struct TypeConverter<mojom::AutocompleteResultsForProviderPtr, OmniboxPageHandler::OmniboxPageHandler( Profile* profile, - mojo::InterfaceRequest<mojom::OmniboxPageHandler> request) - : profile_(profile), binding_(this, std::move(request)), observer_(this) { + mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver) + : profile_(profile), receiver_(this, std::move(receiver)), observer_(this) { observer_.Add(OmniboxControllerEmitter::GetForBrowserContext(profile_)); ResetController(); } @@ -235,22 +235,25 @@ void OmniboxPageHandler::OnResultChanged(bool default_match_changed) { } void OmniboxPageHandler::OnOmniboxQuery(AutocompleteController* controller, - const base::string16& input_text) { + const AutocompleteInput& input) { + time_omnibox_started_ = base::Time::Now(); + input_ = input; page_->HandleNewAutocompleteQuery(controller == controller_.get(), - base::UTF16ToUTF8(input_text)); + base::UTF16ToUTF8(input.text())); } void OmniboxPageHandler::OnOmniboxResultChanged( bool default_match_changed, AutocompleteController* controller) { mojom::OmniboxResponsePtr response(mojom::OmniboxResponse::New()); - response->done = controller->done(); + response->cursor_position = input_.cursor_position(); response->time_since_omnibox_started_ms = (base::Time::Now() - time_omnibox_started_).InMilliseconds(); + response->done = controller->done(); + response->type = AutocompleteInput::TypeToString(input_.type()); const base::string16 host = input_.text().substr(input_.parts().host.begin, input_.parts().host.len); response->host = base::UTF16ToUTF8(host); - response->type = AutocompleteInput::TypeToString(input_.type()); bool is_typed_host; if (!LookupIsTypedHost(host, &is_typed_host)) is_typed_host = false; @@ -372,8 +375,9 @@ bool OmniboxPageHandler::LookupIsTypedHost(const base::string16& host, return true; } -void OmniboxPageHandler::SetClientPage(mojom::OmniboxPagePtr page) { - page_ = std::move(page); +void OmniboxPageHandler::SetClientPage( + mojo::PendingRemote<mojom::OmniboxPage> page) { + page_.Bind(std::move(page)); } void OmniboxPageHandler::StartOmniboxQuery(const std::string& input_string, @@ -391,30 +395,22 @@ void OmniboxPageHandler::StartOmniboxQuery(const std::string& input_string, // actual results to not depend on the state of the previous request. if (reset_autocomplete_controller) ResetController(); - // TODO (manukh): OmniboxPageHandler::StartOmniboxQuery is invoked only for - // queries from the debug page and not for queries from the browser omnibox. - // time_omnibox_started_ and input_ are therefore not set for browser omnibox - // queries, resulting in inaccurate time_since_omnibox_started_ms, host, type, - // and is_typed_host values in the result object being sent to the debug page. - // For the user, this means the 'details' section is mostly inaccurate for - // browser omnibox queries. - time_omnibox_started_ = base::Time::Now(); - input_ = AutocompleteInput( + AutocompleteInput input( base::UTF8ToUTF16(input_string), cursor_position, static_cast<metrics::OmniboxEventProto::PageClassification>( page_classification), ChromeAutocompleteSchemeClassifier(profile_)); GURL current_url_gurl{current_url}; if (current_url_gurl.is_valid()) - input_.set_current_url(current_url_gurl); - input_.set_current_title(base::UTF8ToUTF16(current_url)); - input_.set_prevent_inline_autocomplete(prevent_inline_autocomplete); - input_.set_prefer_keyword(prefer_keyword); + input.set_current_url(current_url_gurl); + input.set_current_title(base::UTF8ToUTF16(current_url)); + input.set_prevent_inline_autocomplete(prevent_inline_autocomplete); + input.set_prefer_keyword(prefer_keyword); if (prefer_keyword) - input_.set_keyword_mode_entry_method(metrics::OmniboxEventProto::TAB); - input_.set_from_omnibox_focus(zero_suggest); + input.set_keyword_mode_entry_method(metrics::OmniboxEventProto::TAB); + input.set_from_omnibox_focus(zero_suggest); - OnOmniboxQuery(controller_.get(), input_.text()); + OnOmniboxQuery(controller_.get(), input); controller_->Start(input_); } diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h index ec2f26b4a18..c960ff022e6 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h @@ -17,7 +17,10 @@ #include "components/omnibox/browser/autocomplete_input.h" #include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/omnibox_controller_emitter.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "mojo/public/cpp/bindings/remote.h" class AutocompleteController; class Profile; @@ -32,7 +35,7 @@ class OmniboxPageHandler : public AutocompleteControllerDelegate, public: // OmniboxPageHandler is deleted when the supplied pipe is destroyed. OmniboxPageHandler(Profile* profile, - mojo::InterfaceRequest<mojom::OmniboxPageHandler> request); + mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver); ~OmniboxPageHandler() override; // AutocompleteControllerDelegate overrides: @@ -40,12 +43,12 @@ class OmniboxPageHandler : public AutocompleteControllerDelegate, // OmniboxControllerEmitter::Observer overrides: void OnOmniboxQuery(AutocompleteController* controller, - const base::string16& input_text) override; + const AutocompleteInput& input) override; void OnOmniboxResultChanged(bool default_match_changed, AutocompleteController* controller) override; // mojom::OmniboxPageHandler overrides: - void SetClientPage(mojom::OmniboxPagePtr page) override; + void SetClientPage(mojo::PendingRemote<mojom::OmniboxPage> page) override; // current_url may be invalid, in which case, autocomplete input's url won't // be set. void StartOmniboxQuery(const std::string& input_string, @@ -80,12 +83,12 @@ class OmniboxPageHandler : public AutocompleteControllerDelegate, AutocompleteInput input_; // Handle back to the page by which we can pass results. - mojom::OmniboxPagePtr page_; + mojo::Remote<mojom::OmniboxPage> page_; // The Profile* handed to us in our constructor. Profile* profile_; - mojo::Binding<mojom::OmniboxPageHandler> binding_; + mojo::Receiver<mojom::OmniboxPageHandler> receiver_; ScopedObserver<OmniboxControllerEmitter, OmniboxControllerEmitter::Observer> observer_; diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc index 4e95206d915..0b5b49cde52 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc @@ -12,7 +12,7 @@ #include "chrome/browser/ui/webui/version_handler.h" #include "chrome/browser/ui/webui/version_ui.h" #include "chrome/common/url_constants.h" -#include "chrome/grit/browser_resources.h" +#include "chrome/grit/omnibox_resources.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_data_source.h" @@ -51,7 +51,7 @@ OmniboxUI::OmniboxUI(content::WebUI* web_ui) OmniboxUI::~OmniboxUI() {} void OmniboxUI::BindOmniboxPageHandler( - mojom::OmniboxPageHandlerRequest request) { - omnibox_handler_.reset( - new OmniboxPageHandler(Profile::FromWebUI(web_ui()), std::move(request))); + mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver) { + omnibox_handler_ = std::make_unique<OmniboxPageHandler>( + Profile::FromWebUI(web_ui()), std::move(receiver)); } diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h index d65e868e21b..81f3ad0e054 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h @@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" #include "ui/webui/mojo_web_ui_controller.h" class OmniboxPageHandler; @@ -18,7 +19,8 @@ class OmniboxUI : public ui::MojoWebUIController { ~OmniboxUI() override; private: - void BindOmniboxPageHandler(mojom::OmniboxPageHandlerRequest request); + void BindOmniboxPageHandler( + mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver); std::unique_ptr<OmniboxPageHandler> omnibox_handler_; |