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

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

Issue 2413923002: Enable lost URL detection in the Physical Web scanner (Closed)
Patch Set: fixes 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 | « no previous file | ios/chrome/common/physical_web/physical_web_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ios_chrome_physical_web_data_source.h" 5 #import "ios/chrome/common/physical_web/ios_chrome_physical_web_data_source.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #import "ios/chrome/common/physical_web/physical_web_scanner.h" 9 #import "ios/chrome/common/physical_web/physical_web_scanner.h"
10 10
11 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {} 11 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource() {}
12 12
13 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() { 13 IOSChromePhysicalWebDataSource::~IOSChromePhysicalWebDataSource() {
14 StopDiscovery(); 14 StopDiscovery();
15 } 15 }
16 16
17 void IOSChromePhysicalWebDataSource::StartDiscovery( 17 void IOSChromePhysicalWebDataSource::StartDiscovery(
18 bool network_request_enabled) { 18 bool network_request_enabled) {
19 // If there are unresolved beacons it means the scanner is started but does 19 // If there are unresolved beacons it means the scanner is started but does
20 // not have network requests enabled. In this case we should avoid recreating 20 // not have network requests enabled. In this case we should avoid recreating
21 // the scanner as it would clear the cache of nearby beacons. 21 // the scanner as it would clear the cache of nearby beacons.
22 if (network_request_enabled && HasUnresolvedDiscoveries()) { 22 if (network_request_enabled && HasUnresolvedDiscoveries()) {
23 [scanner_ setNetworkRequestEnabled:YES]; 23 [scanner_ setNetworkRequestEnabled:YES];
24 return; 24 return;
25 } 25 }
26 26
27 [scanner_ stop]; 27 [scanner_ stop];
28 scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]); 28 scanner_.reset([[PhysicalWebScanner alloc] initWithDelegate:nil]);
29
30 // Configure the scanner to notify us when a URL is no longer nearby.
31 [scanner_ setOnLostDetectionEnabled:YES];
29 [scanner_ setNetworkRequestEnabled:network_request_enabled]; 32 [scanner_ setNetworkRequestEnabled:network_request_enabled];
30 [scanner_ start]; 33 [scanner_ start];
31 } 34 }
32 35
33 void IOSChromePhysicalWebDataSource::StopDiscovery() { 36 void IOSChromePhysicalWebDataSource::StopDiscovery() {
34 [scanner_ stop]; 37 [scanner_ stop];
35 scanner_.reset(); 38 scanner_.reset();
36 } 39 }
37 40
38 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { 41 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() {
39 if (!scanner_) { 42 if (!scanner_) {
40 return base::MakeUnique<base::ListValue>(); 43 return base::MakeUnique<base::ListValue>();
41 } 44 }
42 return [scanner_ metadata]; 45 return [scanner_ metadata];
43 } 46 }
44 47
45 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { 48 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() {
46 return [scanner_ unresolvedBeaconsCount] > 0; 49 return [scanner_ unresolvedBeaconsCount] > 0;
47 } 50 }
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/common/physical_web/physical_web_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698