Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Side by Side Diff: components/omnibox/browser/physical_web_provider.cc

Issue 2403423005: Expose Physical Web metadata to native clients over JNI (Closed)
Patch Set: remove unit test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/omnibox/browser/autocomplete_provider_client.h" 8 #include "components/omnibox/browser/autocomplete_provider_client.h"
9 #include "components/omnibox/browser/autocomplete_provider_listener.h" 9 #include "components/omnibox/browser/autocomplete_provider_listener.h"
10 #include "components/omnibox/browser/history_url_provider.h" 10 #include "components/omnibox/browser/history_url_provider.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 size_t used_slots = 0; 99 size_t used_slots = 0;
100 100
101 for (size_t i = 0; i < metadata_count; ++i) { 101 for (size_t i = 0; i < metadata_count; ++i) {
102 base::DictionaryValue* metadata_item = NULL; 102 base::DictionaryValue* metadata_item = NULL;
103 if (!metadata_list->GetDictionary(i, &metadata_item)) { 103 if (!metadata_list->GetDictionary(i, &metadata_item)) {
104 continue; 104 continue;
105 } 105 }
106 106
107 std::string url_string; 107 std::string url_string;
108 std::string title_string; 108 std::string title_string;
109 if (!metadata_item->GetString("resolvedUrl", &url_string) || 109 if (!metadata_item->GetString(kPhysicalWebResolvedUrlKey, &url_string) ||
110 !metadata_item->GetString("title", &title_string)) { 110 !metadata_item->GetString(kPhysicalWebTitleKey, &title_string)) {
111 continue; 111 continue;
112 } 112 }
113 base::string16 title = 113 base::string16 title =
114 AutocompleteMatch::SanitizeString(base::UTF8ToUTF16(title_string)); 114 AutocompleteMatch::SanitizeString(base::UTF8ToUTF16(title_string));
115 115
116 // Add match items with decreasing relevance to preserve the ordering in 116 // Add match items with decreasing relevance to preserve the ordering in
117 // the metadata list. 117 // the metadata list.
118 int relevance = kPhysicalWebUrlBaseRelevance - used_slots; 118 int relevance = kPhysicalWebUrlBaseRelevance - used_slots;
119 119
120 // Append an overflow item if creating a match for each metadata item would 120 // Append an overflow item if creating a match for each metadata item would
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 AutocompleteInput::FormattedStringWithEquivalentMeaning( 180 AutocompleteInput::FormattedStringWithEquivalentMeaning(
181 url, match.contents, client_->GetSchemeClassifier()); 181 url, match.contents, client_->GetSchemeClassifier());
182 182
183 match.description = 183 match.description =
184 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); 184 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION);
185 match.description_class.push_back( 185 match.description_class.push_back(
186 ACMatchClassification(0, ACMatchClassification::NONE)); 186 ACMatchClassification(0, ACMatchClassification::NONE));
187 187
188 matches_.push_back(match); 188 matches_.push_back(match);
189 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698