OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "chrome/browser/android/vr_shell/vr_omnibox.h" | 5 #include "chrome/browser/android/vr_shell/vr_omnibox.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 AutocompleteClassifier::DefaultOmniboxProviders())) {} | 26 AutocompleteClassifier::DefaultOmniboxProviders())) {} |
27 | 27 |
28 VrOmnibox::~VrOmnibox() = default; | 28 VrOmnibox::~VrOmnibox() = default; |
29 | 29 |
30 void VrOmnibox::HandleInput(const base::DictionaryValue& dict) { | 30 void VrOmnibox::HandleInput(const base::DictionaryValue& dict) { |
31 base::string16 text; | 31 base::string16 text; |
32 CHECK(dict.GetString("text", &text)); | 32 CHECK(dict.GetString("text", &text)); |
33 | 33 |
34 // TODO(crbug.com/683344): Scrub and appropriately tune these parameters. | 34 // TODO(crbug.com/683344): Scrub and appropriately tune these parameters. |
35 GURL current_url; | 35 GURL current_url; |
| 36 base::string16 current_title; |
36 size_t cursor_pos = base::string16::npos; | 37 size_t cursor_pos = base::string16::npos; |
37 std::string desired_tld; | 38 std::string desired_tld; |
38 metrics::OmniboxEventProto::PageClassification page_classification = | 39 metrics::OmniboxEventProto::PageClassification page_classification = |
39 metrics::OmniboxEventProto::OTHER; | 40 metrics::OmniboxEventProto::OTHER; |
40 bool prevent_inline_autocomplete = false; | 41 bool prevent_inline_autocomplete = false; |
41 bool prefer_keyword = false; | 42 bool prefer_keyword = false; |
42 bool allow_exact_keyword_match = false; | 43 bool allow_exact_keyword_match = false; |
43 bool want_asynchronous_matches = true; | 44 bool want_asynchronous_matches = true; |
44 bool from_omnibox_focus = false; | 45 bool from_omnibox_focus = false; |
45 | 46 |
46 autocomplete_controller_->Start(AutocompleteInput( | 47 autocomplete_controller_->Start(AutocompleteInput( |
47 text, cursor_pos, desired_tld, current_url, page_classification, | 48 text, cursor_pos, desired_tld, current_url, current_title, |
48 prevent_inline_autocomplete, prefer_keyword, allow_exact_keyword_match, | 49 page_classification, prevent_inline_autocomplete, prefer_keyword, |
49 want_asynchronous_matches, from_omnibox_focus, | 50 allow_exact_keyword_match, want_asynchronous_matches, from_omnibox_focus, |
50 ChromeAutocompleteSchemeClassifier(profile_))); | 51 ChromeAutocompleteSchemeClassifier(profile_))); |
51 } | 52 } |
52 | 53 |
53 void VrOmnibox::OnResultChanged(bool default_match_changed) { | 54 void VrOmnibox::OnResultChanged(bool default_match_changed) { |
54 const AutocompleteResult& result = autocomplete_controller_->result(); | 55 const AutocompleteResult& result = autocomplete_controller_->result(); |
55 auto suggestions = base::MakeUnique<base::ListValue>(); | 56 auto suggestions = base::MakeUnique<base::ListValue>(); |
56 | 57 |
57 for (const AutocompleteMatch& match : result) { | 58 for (const AutocompleteMatch& match : result) { |
58 auto entry = base::MakeUnique<base::DictionaryValue>(); | 59 auto entry = base::MakeUnique<base::DictionaryValue>(); |
59 entry->SetString("description", match.contents); | 60 entry->SetString("description", match.contents); |
60 entry->SetString("url", match.destination_url.spec()); | 61 entry->SetString("url", match.destination_url.spec()); |
61 suggestions->Append(std::move(entry)); | 62 suggestions->Append(std::move(entry)); |
62 } | 63 } |
63 | 64 |
64 ui_->SetOmniboxSuggestions(std::move(suggestions)); | 65 ui_->SetOmniboxSuggestions(std::move(suggestions)); |
65 } | 66 } |
66 | 67 |
67 } // namespace vr_shell | 68 } // namespace vr_shell |
OLD | NEW |