Chromium Code Reviews| 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..a3dfa2c69243ba16615575c45d43259ddb42ac88 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,41 @@ 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]; |
|
sdefresne
2016/08/02 22:23:36
Use base::SysNSStringToUTF8 (it returns std::strin
mattreynolds
2016/08/04 00:56:13
Done.
|
| + 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]; |
| + |
| + // Provide defaults for optional fields. |
|
sdefresne
2016/08/02 22:23:36
You can remove this if using base::SysNSStringToUT
mattreynolds
2016/08/04 00:56:12
Done.
|
| + if (!icon) { |
| + icon = ""; |
| + } |
| + if (!title) { |
| + title = ""; |
| + } |
| + if (!description) { |
| + description = ""; |
| + } |
| + |
| + 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; |