Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "components/omnibox/browser/physical_web_provider.h" | 5 #include "components/omnibox/browser/physical_web_provider.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 } | 68 } |
| 69 | 69 |
| 70 physical_web::PhysicalWebDataSource* data_source = | 70 physical_web::PhysicalWebDataSource* data_source = |
| 71 client_->GetPhysicalWebDataSource(); | 71 client_->GetPhysicalWebDataSource(); |
| 72 if (!data_source) { | 72 if (!data_source) { |
| 73 done_ = true; | 73 done_ = true; |
| 74 nearby_url_count_ = 0; | 74 nearby_url_count_ = 0; |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (input.from_omnibox_focus()) { | 78 if (input.from_omnibox_focus() || input.text().empty()) { |
| 79 ConstructZeroSuggestMatches(data_source->GetMetadataList()); | 79 ConstructZeroSuggestMatches(data_source->GetMetadataList()); |
| 80 | 80 |
| 81 if (!matches_.empty()) { | 81 if (!matches_.empty()) { |
| 82 had_physical_web_suggestions_ = true; | 82 had_physical_web_suggestions_ = true; |
| 83 had_physical_web_suggestions_at_focus_or_later_ = true; | 83 had_physical_web_suggestions_at_focus_or_later_ = true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 if (!zero_suggest_enabled_) { | 86 if (!zero_suggest_enabled_) { |
| 87 matches_.clear(); | 87 matches_.clear(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // In zero-suggest, Physical Web matches should never be default. If the | 90 // In zero-suggest, Physical Web matches should never be default. If the |
| 91 // omnibox input is non-empty and we have at least one Physical Web match, | 91 // omnibox input is non-empty and we have at least one Physical Web match, |
| 92 // add the current URL as the default so that hitting enter after focusing | 92 // add the current URL as the default so that hitting enter after focusing |
| 93 // the omnibox causes the current page to reload. If the input field is | 93 // the omnibox causes the current page to reload. If the input field is |
| 94 // empty, no default match is required. | 94 // empty, no default match is required. |
| 95 if (!matches_.empty() && !input.text().empty()) { | 95 if (!matches_.empty() && !input.text().empty()) { |
|
Mark P
2017/01/24 19:06:12
I don't think this test is exactly right anymore.
mattreynolds
2017/01/24 22:41:54
I think that's an Android bug, we should never dis
Mark P
2017/01/25 20:19:47
Filed crbug.com/685332. It seems straightforward
mattreynolds
2017/01/25 22:01:52
Thanks, I'll look into it.
| |
| 96 matches_.push_back(VerbatimMatchForURL( | 96 matches_.push_back(VerbatimMatchForURL( |
| 97 client_, input, input.current_url(), history_url_provider_, -1)); | 97 client_, input, input.current_url(), history_url_provider_, -1)); |
| 98 } | 98 } |
| 99 } else { | 99 } else { |
| 100 ConstructQuerySuggestMatches(data_source->GetMetadataList(), input); | 100 ConstructQuerySuggestMatches(data_source->GetMetadataList(), input); |
| 101 | 101 |
| 102 if (!matches_.empty()) { | 102 if (!matches_.empty()) { |
| 103 had_physical_web_suggestions_ = true; | 103 had_physical_web_suggestions_ = true; |
| 104 had_physical_web_suggestions_at_focus_or_later_ = true; | 104 had_physical_web_suggestions_at_focus_or_later_ = true; |
| 105 } | 105 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 273 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 274 url, match.contents, client_->GetSchemeClassifier()); | 274 url, match.contents, client_->GetSchemeClassifier()); |
| 275 | 275 |
| 276 match.description = | 276 match.description = |
| 277 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); | 277 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); |
| 278 match.description_class.push_back( | 278 match.description_class.push_back( |
| 279 ACMatchClassification(0, ACMatchClassification::NONE)); | 279 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 280 | 280 |
| 281 matches_.push_back(match); | 281 matches_.push_back(match); |
| 282 } | 282 } |
| OLD | NEW |