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

Unified Diff: components/physical_web/webui/physical_web_base_message_handler.cc

Issue 2626413003: Replace deprecated call to GetMetadata in Physical Web WebUI (Closed)
Patch Set: remove unrelated changes Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/physical_web/webui/physical_web_ui_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/physical_web/webui/physical_web_base_message_handler.cc
diff --git a/components/physical_web/webui/physical_web_base_message_handler.cc b/components/physical_web/webui/physical_web_base_message_handler.cc
index a619666111bf3d56cbd169d3ac93897963a99e02..fd7d4b61699b61603297fa8eb56292f549698776 100644
--- a/components/physical_web/webui/physical_web_base_message_handler.cc
+++ b/components/physical_web/webui/physical_web_base_message_handler.cc
@@ -5,6 +5,7 @@
#include "components/physical_web/webui/physical_web_base_message_handler.h"
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "components/physical_web/data_source/physical_web_data_source.h"
@@ -32,15 +33,26 @@ void PhysicalWebBaseMessageHandler::HandleRequestNearbyURLs(
const base::ListValue* args) {
base::DictionaryValue results;
- std::unique_ptr<base::ListValue> metadata =
- GetPhysicalWebDataSource()->GetMetadata();
+ std::unique_ptr<physical_web::MetadataList> metadata_list =
+ GetPhysicalWebDataSource()->GetMetadataList();
- // Add item indices. When an item is selected, the index of the selected item
- // is recorded in a UMA histogram.
- for (size_t i = 0; i < metadata->GetSize(); i++) {
- base::DictionaryValue* metadata_item = nullptr;
- metadata->GetDictionary(i, &metadata_item);
- metadata_item->SetInteger(physical_web_ui::kIndex, static_cast<int>(i));
+ auto metadata = base::MakeUnique<base::ListValue>();
+ int index = 0;
+ for (const auto& metadata_list_item : *metadata_list) {
+ auto metadata_item = base::MakeUnique<base::DictionaryValue>();
+ metadata_item->SetString(physical_web_ui::kResolvedUrl,
+ metadata_list_item.resolved_url.spec());
+ metadata_item->SetString(physical_web_ui::kPageInfoIcon,
+ metadata_list_item.icon_url.spec());
+ metadata_item->SetString(physical_web_ui::kPageInfoTitle,
+ metadata_list_item.title);
+ metadata_item->SetString(physical_web_ui::kPageInfoDescription,
+ metadata_list_item.description);
+ // Add the item index so when an item is selected, the index can be recorded
+ // in a UMA histogram.
+ metadata_item->SetInteger(physical_web_ui::kIndex, index);
+ metadata->Append(std::move(metadata_item));
+ ++index;
}
results.Set(physical_web_ui::kMetadata, metadata.release());
« no previous file with comments | « no previous file | components/physical_web/webui/physical_web_ui_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698