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

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

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: Some ios compilation issues 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
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..6c7ec507d80d8917a995ca68f67ef1d27bc96a18 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<MetadataList>)metadataList {
mattreynolds 2017/01/11 20:54:50 physical_web:: (and in MakeUnique below)
cco3 2017/01/11 22:51:02 Done.
+ auto metadataRet = base::MakeUnique<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->Append(std::move(metadataItem));
mattreynolds 2017/01/11 20:54:51 push_back
cco3 2017/01/11 22:51:02 Done.
+ }
+
+ return metadataRet;
}
- (void)setNetworkRequestEnabled:(BOOL)enabled {

Powered by Google App Engine
This is Rietveld 408576698