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

Unified Diff: ios/chrome/common/physical_web/physical_web_scanner.mm

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: Forward declare MetadataList 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 | « ios/chrome/common/physical_web/physical_web_scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/common/physical_web/physical_web_scanner.mm
diff --git a/ios/chrome/common/physical_web/physical_web_scanner.mm b/ios/chrome/common/physical_web/physical_web_scanner.mm
index ce0fe0a9e35e4e2a2214f664b9bbbcbdc00c8038..907904be5a691a64ea5fe1f45be52879678b6244 100644
--- a/ios/chrome/common/physical_web/physical_web_scanner.mm
+++ b/ios/chrome/common/physical_web/physical_web_scanner.mm
@@ -20,6 +20,7 @@
#import "ios/chrome/common/physical_web/physical_web_device.h"
#import "ios/chrome/common/physical_web/physical_web_request.h"
#import "ios/chrome/common/physical_web/physical_web_types.h"
+#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -185,7 +186,7 @@ enum BeaconType {
}
- (std::unique_ptr<base::ListValue>)metadata {
- auto metadataList = base::MakeUnique<base::ListValue>();
+ auto metadataRet = base::MakeUnique<base::ListValue>();
for (PhysicalWebDevice* device in [self devices]) {
std::string scannedUrl =
@@ -202,10 +203,34 @@ enum BeaconType {
metadataItem->SetString(physical_web::kIconUrlKey, icon);
metadataItem->SetString(physical_web::kTitleKey, title);
metadataItem->SetString(physical_web::kDescriptionKey, description);
- metadataList->Append(std::move(metadataItem));
+ metadataRet->Append(std::move(metadataItem));
}
- return metadataList;
+ return metadataRet;
+}
+
+- (std::unique_ptr<physical_web::MetadataList>)metadataList {
+ auto metadataRet = base::MakeUnique<physical_web::MetadataList>();
+
+ for (PhysicalWebDevice* device in [self devices]) {
+ std::string scannedUrl =
+ base::SysNSStringToUTF8([[device requestURL] absoluteString]);
+ std::string resolvedUrl =
+ base::SysNSStringToUTF8([[device url] absoluteString]);
+ std::string icon = base::SysNSStringToUTF8([[device icon] absoluteString]);
+ std::string title = base::SysNSStringToUTF8([device title]);
+ std::string description = base::SysNSStringToUTF8([device description]);
+
+ physical_web::Metadata metadataItem;
+ metadataItem.scanned_url = GURL(scannedUrl);
+ metadataItem.resolved_url = GURL(resolvedUrl);
+ metadataItem.icon_url = GURL(icon);
+ metadataItem.title = title;
+ metadataItem.description = description;
+ metadataRet->push_back(std::move(metadataItem));
+ }
+
+ return metadataRet;
}
- (void)setNetworkRequestEnabled:(BOOL)enabled {
« no previous file with comments | « ios/chrome/common/physical_web/physical_web_scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698