| OLD | NEW |
| 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/browser/physical_web/ios_chrome_physical_web_data_source.h" | 5 #import "ios/chrome/browser/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" | |
| 9 #import "ios/chrome/browser/physical_web/physical_web_initial_state_recorder.h" | 8 #import "ios/chrome/browser/physical_web/physical_web_initial_state_recorder.h" |
| 10 #import "ios/chrome/common/physical_web/physical_web_scanner.h" | 9 #import "ios/chrome/common/physical_web/physical_web_scanner.h" |
| 11 | 10 |
| 12 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource( | 11 IOSChromePhysicalWebDataSource::IOSChromePhysicalWebDataSource( |
| 13 PrefService* pref_service) { | 12 PrefService* pref_service) { |
| 14 initialStateRecorder_.reset([[PhysicalWebInitialStateRecorder alloc] | 13 initialStateRecorder_.reset([[PhysicalWebInitialStateRecorder alloc] |
| 15 initWithPrefService:pref_service]); | 14 initWithPrefService:pref_service]); |
| 16 [initialStateRecorder_ collectAndRecordState]; | 15 [initialStateRecorder_ collectAndRecordState]; |
| 17 } | 16 } |
| 18 | 17 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 [scanner_ setOnLostDetectionEnabled:YES]; | 37 [scanner_ setOnLostDetectionEnabled:YES]; |
| 39 [scanner_ setNetworkRequestEnabled:network_request_enabled]; | 38 [scanner_ setNetworkRequestEnabled:network_request_enabled]; |
| 40 [scanner_ start]; | 39 [scanner_ start]; |
| 41 } | 40 } |
| 42 | 41 |
| 43 void IOSChromePhysicalWebDataSource::StopDiscovery() { | 42 void IOSChromePhysicalWebDataSource::StopDiscovery() { |
| 44 [scanner_ stop]; | 43 [scanner_ stop]; |
| 45 scanner_.reset(); | 44 scanner_.reset(); |
| 46 } | 45 } |
| 47 | 46 |
| 48 std::unique_ptr<base::ListValue> IOSChromePhysicalWebDataSource::GetMetadata() { | |
| 49 if (!scanner_) { | |
| 50 return base::MakeUnique<base::ListValue>(); | |
| 51 } | |
| 52 return [scanner_ metadata]; | |
| 53 } | |
| 54 | |
| 55 std::unique_ptr<physical_web::MetadataList> | 47 std::unique_ptr<physical_web::MetadataList> |
| 56 IOSChromePhysicalWebDataSource::GetMetadataList() { | 48 IOSChromePhysicalWebDataSource::GetMetadataList() { |
| 57 if (!scanner_) { | 49 if (!scanner_) { |
| 58 return base::MakeUnique<physical_web::MetadataList>(); | 50 return base::MakeUnique<physical_web::MetadataList>(); |
| 59 } | 51 } |
| 60 return [scanner_ metadataList]; | 52 return [scanner_ metadataList]; |
| 61 } | 53 } |
| 62 | 54 |
| 63 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { | 55 bool IOSChromePhysicalWebDataSource::HasUnresolvedDiscoveries() { |
| 64 return [scanner_ unresolvedBeaconsCount] > 0; | 56 return [scanner_ unresolvedBeaconsCount] > 0; |
| 65 } | 57 } |
| OLD | NEW |