| 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "base/metrics/histogram_macros.h" | 6 #include "base/metrics/histogram_macros.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/omnibox/browser/autocomplete_provider_client.h" | 9 #include "components/omnibox/browser/autocomplete_provider_client.h" |
| 10 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 10 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Don't provide suggestions in incognito mode. | 61 // Don't provide suggestions in incognito mode. |
| 62 if (client_->IsOffTheRecord()) { | 62 if (client_->IsOffTheRecord()) { |
| 63 done_ = true; | 63 done_ = true; |
| 64 nearby_url_count_ = 0; | 64 nearby_url_count_ = 0; |
| 65 return; | 65 return; |
| 66 } | 66 } |
| 67 | 67 |
| 68 PhysicalWebDataSource* data_source = client_->GetPhysicalWebDataSource(); | 68 physical_web::PhysicalWebDataSource* data_source = |
| 69 client_->GetPhysicalWebDataSource(); |
| 69 if (!data_source) { | 70 if (!data_source) { |
| 70 done_ = true; | 71 done_ = true; |
| 71 nearby_url_count_ = 0; | 72 nearby_url_count_ = 0; |
| 72 return; | 73 return; |
| 73 } | 74 } |
| 74 | 75 |
| 75 ConstructMatches(data_source->GetMetadata().get()); | 76 ConstructMatches(data_source->GetMetadata().get()); |
| 76 | 77 |
| 77 // Physical Web matches should never be default. If the omnibox input is | 78 // Physical Web matches should never be default. If the omnibox input is |
| 78 // non-empty and we have at least one Physical Web match, add the current URL | 79 // non-empty and we have at least one Physical Web match, add the current URL |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 size_t used_slots = 0; | 121 size_t used_slots = 0; |
| 121 | 122 |
| 122 for (size_t i = 0; i < nearby_url_count_; ++i) { | 123 for (size_t i = 0; i < nearby_url_count_; ++i) { |
| 123 base::DictionaryValue* metadata_item = NULL; | 124 base::DictionaryValue* metadata_item = NULL; |
| 124 if (!metadata_list->GetDictionary(i, &metadata_item)) { | 125 if (!metadata_list->GetDictionary(i, &metadata_item)) { |
| 125 continue; | 126 continue; |
| 126 } | 127 } |
| 127 | 128 |
| 128 std::string url_string; | 129 std::string url_string; |
| 129 std::string title_string; | 130 std::string title_string; |
| 130 if (!metadata_item->GetString(kPhysicalWebResolvedUrlKey, &url_string) || | 131 if (!metadata_item->GetString(physical_web::kResolvedUrlKey, &url_string) || |
| 131 !metadata_item->GetString(kPhysicalWebTitleKey, &title_string)) { | 132 !metadata_item->GetString(physical_web::kTitleKey, &title_string)) { |
| 132 continue; | 133 continue; |
| 133 } | 134 } |
| 134 base::string16 title = | 135 base::string16 title = |
| 135 AutocompleteMatch::SanitizeString(base::UTF8ToUTF16(title_string)); | 136 AutocompleteMatch::SanitizeString(base::UTF8ToUTF16(title_string)); |
| 136 | 137 |
| 137 // Add match items with decreasing relevance to preserve the ordering in | 138 // Add match items with decreasing relevance to preserve the ordering in |
| 138 // the metadata list. | 139 // the metadata list. |
| 139 int relevance = kPhysicalWebUrlBaseRelevance - used_slots; | 140 int relevance = kPhysicalWebUrlBaseRelevance - used_slots; |
| 140 | 141 |
| 141 // Append an overflow item if creating a match for each metadata item would | 142 // Append an overflow item if creating a match for each metadata item would |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 205 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 205 url, match.contents, client_->GetSchemeClassifier()); | 206 url, match.contents, client_->GetSchemeClassifier()); |
| 206 | 207 |
| 207 match.description = | 208 match.description = |
| 208 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); | 209 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); |
| 209 match.description_class.push_back( | 210 match.description_class.push_back( |
| 210 ACMatchClassification(0, ACMatchClassification::NONE)); | 211 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 211 | 212 |
| 212 matches_.push_back(match); | 213 matches_.push_back(match); |
| 213 } | 214 } |
| OLD | NEW |