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

Side by Side Diff: ios/chrome/common/physical_web/physical_web_scanner.mm

Issue 2403423005: Expose Physical Web metadata to native clients over JNI (Closed)
Patch Set: remove unit test Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « components/physical_web/data_source/physical_web_data_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/common/physical_web/physical_web_scanner.h" 5 #import "ios/chrome/common/physical_web/physical_web_scanner.h"
6 6
7 #import <CoreBluetooth/CoreBluetooth.h> 7 #import <CoreBluetooth/CoreBluetooth.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #import "base/ios/weak_nsobject.h" 12 #import "base/ios/weak_nsobject.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #import "base/mac/scoped_nsobject.h" 14 #import "base/mac/scoped_nsobject.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/sys_string_conversions.h" 16 #include "base/strings/sys_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "components/physical_web/data_source/physical_web_data_source.h"
18 #include "device/bluetooth/uribeacon/uri_encoder.h" 19 #include "device/bluetooth/uribeacon/uri_encoder.h"
19 #import "ios/chrome/common/physical_web/physical_web_device.h" 20 #import "ios/chrome/common/physical_web/physical_web_device.h"
20 #import "ios/chrome/common/physical_web/physical_web_request.h" 21 #import "ios/chrome/common/physical_web/physical_web_request.h"
21 #import "ios/chrome/common/physical_web/physical_web_types.h" 22 #import "ios/chrome/common/physical_web/physical_web_types.h"
22 23
23 namespace { 24 namespace {
24 25
25 NSString* const kUriBeaconServiceUUID = @"FED8"; 26 NSString* const kUriBeaconServiceUUID = @"FED8";
26 NSString* const kEddystoneBeaconServiceUUID = @"FEAA"; 27 NSString* const kEddystoneBeaconServiceUUID = @"FEAA";
27 28
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 for (PhysicalWebDevice* device in [self devices]) { 180 for (PhysicalWebDevice* device in [self devices]) {
180 std::string scannedUrl = 181 std::string scannedUrl =
181 base::SysNSStringToUTF8([[device requestURL] absoluteString]); 182 base::SysNSStringToUTF8([[device requestURL] absoluteString]);
182 std::string resolvedUrl = 183 std::string resolvedUrl =
183 base::SysNSStringToUTF8([[device url] absoluteString]); 184 base::SysNSStringToUTF8([[device url] absoluteString]);
184 std::string icon = base::SysNSStringToUTF8([[device icon] absoluteString]); 185 std::string icon = base::SysNSStringToUTF8([[device icon] absoluteString]);
185 std::string title = base::SysNSStringToUTF8([device title]); 186 std::string title = base::SysNSStringToUTF8([device title]);
186 std::string description = base::SysNSStringToUTF8([device description]); 187 std::string description = base::SysNSStringToUTF8([device description]);
187 188
188 auto metadataItem = base::MakeUnique<base::DictionaryValue>(); 189 auto metadataItem = base::MakeUnique<base::DictionaryValue>();
189 metadataItem->SetString("scannedUrl", scannedUrl); 190 metadataItem->SetString(kPhysicalWebScannedUrlKey, scannedUrl);
190 metadataItem->SetString("resolvedUrl", resolvedUrl); 191 metadataItem->SetString(kPhysicalWebResolvedUrlKey, resolvedUrl);
191 metadataItem->SetString("icon", icon); 192 metadataItem->SetString(kPhysicalWebIconUrlKey, icon);
192 metadataItem->SetString("title", title); 193 metadataItem->SetString(kPhysicalWebTitleKey, title);
193 metadataItem->SetString("description", description); 194 metadataItem->SetString(kPhysicalWebDescriptionKey, description);
194 metadataList->Append(std::move(metadataItem)); 195 metadataList->Append(std::move(metadataItem));
195 } 196 }
196 197
197 return metadataList; 198 return metadataList;
198 } 199 }
199 200
200 - (void)setNetworkRequestEnabled:(BOOL)enabled { 201 - (void)setNetworkRequestEnabled:(BOOL)enabled {
201 if (networkRequestEnabled_ == enabled) { 202 if (networkRequestEnabled_ == enabled) {
202 return; 203 return;
203 } 204 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 [strongSelf.get()->devices_ addObject:device]; 481 [strongSelf.get()->devices_ addObject:device];
481 [strongSelf.get()->delegate_ scannerUpdatedDevices:weakSelf]; 482 [strongSelf.get()->delegate_ scannerUpdatedDevices:weakSelf];
482 [strongSelf.get()->finalUrls_ addObject:[device url]]; 483 [strongSelf.get()->finalUrls_ addObject:[device url]];
483 } 484 }
484 } 485 }
485 [strongSelf.get()->pendingRequests_ removeObject:strongRequest]; 486 [strongSelf.get()->pendingRequests_ removeObject:strongRequest];
486 }]; 487 }];
487 } 488 }
488 489
489 @end 490 @end
OLDNEW
« no previous file with comments | « components/physical_web/data_source/physical_web_data_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698