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

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

Issue 2113473002: Add a Physical Web data source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove notification Created 4 years, 6 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 2457f225a5cacc46102e6ce517f596118ddb774e..81a6e0560e2ac7d30c3805599150c1f2de18b8ec 100644
--- a/ios/chrome/common/physical_web/physical_web_scanner.mm
+++ b/ios/chrome/common/physical_web/physical_web_scanner.mm
@@ -4,20 +4,19 @@
#import "ios/chrome/common/physical_web/physical_web_scanner.h"
+#import <CoreBluetooth/CoreBluetooth.h>
+
#include <string>
#include <vector>
-#import <CoreBluetooth/CoreBluetooth.h>
-
-#include "base/ios/weak_nsobject.h"
+#import "base/ios/weak_nsobject.h"
#include "base/logging.h"
-#include "base/mac/scoped_nsobject.h"
-#include "base/macros.h"
+#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "device/bluetooth/uribeacon/uri_encoder.h"
-#include "ios/chrome/common/physical_web/physical_web_device.h"
+#import "ios/chrome/common/physical_web/physical_web_device.h"
#import "ios/chrome/common/physical_web/physical_web_request.h"
-#include "ios/chrome/common/physical_web/physical_web_types.h"
+#import "ios/chrome/common/physical_web/physical_web_types.h"
namespace {
@@ -149,6 +148,30 @@ enum BeaconType {
}];
}
+- (std::unique_ptr<base::ListValue>)metadata {
+ std::unique_ptr<base::ListValue> metadataList(new base::ListValue());
+
+ NSInteger deviceCount = [[self devices] count];
+ for (int i = 0; i < deviceCount; ++i) {
+ PhysicalWebDevice* device = [[self devices] objectAtIndex:i];
+ const char* scannedUrl = [[[device requestURL] absoluteString] UTF8String];
+ const char* resolvedUrl = [[[device url] absoluteString] UTF8String];
+ const char* icon = [[[device icon] absoluteString] UTF8String];
+ const char* title = [[device title] UTF8String];
+ const char* description = [[device description] UTF8String];
+
+ base::DictionaryValue* metadataItem = new base::DictionaryValue();
+ metadataItem->SetString("scannedUrl", scannedUrl);
+ metadataItem->SetString("resolvedUrl", resolvedUrl);
+ metadataItem->SetString("icon", icon);
+ metadataItem->SetString("title", title);
+ metadataItem->SetString("description", description);
+ metadataList->Append(metadataItem);
+ }
+
+ return metadataList;
+}
+
- (void)setNetworkRequestEnabled:(BOOL)enabled {
if (networkRequestEnabled_ == enabled) {
return;

Powered by Google App Engine
This is Rietveld 408576698