| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "components/physical_web/data_source/physical_web_data_source.h" |
| 13 |
| 14 namespace base { |
| 15 class DictionaryValue; |
| 16 class ListValue; |
| 17 } |
| 18 |
| 19 namespace physical_web { |
| 20 |
| 21 std::unique_ptr<base::DictionaryValue> CreatePhysicalWebPage( |
| 22 const std::string& resolved_url, |
| 23 double distance_estimate, |
| 24 int scan_timestamp, |
| 25 const std::string& title, |
| 26 const std::string& description, |
| 27 const std::string& scanned_url); |
| 28 |
| 29 std::unique_ptr<base::DictionaryValue> |
| 30 CreateDummyPhysicalWebPage(int id, double distance, int timestamp); |
| 31 |
| 32 std::unique_ptr<base::ListValue> CreateDummyPhysicalWebPages( |
| 33 const std::vector<int>& ids); |
| 34 |
| 35 class FakePhysicalWebDataSource : public PhysicalWebDataSource { |
| 36 public: |
| 37 FakePhysicalWebDataSource(); |
| 38 ~FakePhysicalWebDataSource() override; |
| 39 |
| 40 void StartDiscovery(bool network_request_enabled) override; |
| 41 void StopDiscovery() override; |
| 42 |
| 43 std::unique_ptr<base::ListValue> GetMetadata() override; |
| 44 |
| 45 bool HasUnresolvedDiscoveries() override; |
| 46 |
| 47 void RegisterListener(PhysicalWebListener* physical_web_listener) override; |
| 48 void UnregisterListener(PhysicalWebListener* physical_web_listener) override; |
| 49 |
| 50 // for testing |
| 51 void SetMetadata(std::unique_ptr<base::ListValue> metadata); |
| 52 void NotifyOnFound(const std::string& url); |
| 53 void NotifyOnLost(const std::string& url); |
| 54 void NotifyOnDistanceChanged(const std::string& url, |
| 55 double distance_estimate); |
| 56 |
| 57 private: |
| 58 std::unique_ptr<base::ListValue> metadata_; |
| 59 base::ObserverList<PhysicalWebListener> observer_list_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(FakePhysicalWebDataSource); |
| 62 }; |
| 63 |
| 64 } // namespace physical_web |
| 65 |
| 66 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| OLD | NEW |