| 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 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ | 5 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ | 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace base { | |
| 16 class ListValue; | |
| 17 } | |
| 18 | |
| 19 namespace physical_web { | 15 namespace physical_web { |
| 20 | 16 |
| 21 class PhysicalWebListener; | 17 class PhysicalWebListener; |
| 22 | 18 |
| 23 // Dictionary keys for reading Physical Web URL metadata. | |
| 24 // TODO(cco3): Remove these when we are no longer dependent. | |
| 25 extern const char kDescriptionKey[]; | |
| 26 extern const char kDistanceEstimateKey[]; | |
| 27 extern const char kGroupIdKey[]; | |
| 28 extern const char kIconUrlKey[]; | |
| 29 extern const char kResolvedUrlKey[]; | |
| 30 extern const char kScanTimestampKey[]; | |
| 31 extern const char kScannedUrlKey[]; | |
| 32 extern const char kTitleKey[]; | |
| 33 | |
| 34 // Metadata struct for associating data with Physical Web URLs. | 19 // Metadata struct for associating data with Physical Web URLs. |
| 35 struct Metadata { | 20 struct Metadata { |
| 36 Metadata(); | 21 Metadata(); |
| 37 Metadata(const Metadata& other); | 22 Metadata(const Metadata& other); |
| 38 ~Metadata(); | 23 ~Metadata(); |
| 39 // The URL broadcasted by the beacon and scanned by the client device. | 24 // The URL broadcasted by the beacon and scanned by the client device. |
| 40 // REQUIRED | 25 // REQUIRED |
| 41 GURL scanned_url; | 26 GURL scanned_url; |
| 42 // The URL that the scanned_url redirects to. | 27 // The URL that the scanned_url redirects to. |
| 43 // This is the URL that users should be directed to. | 28 // This is the URL that users should be directed to. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 74 |
| 90 // Stops scanning for Physical Web URLs and clears cached URL content. | 75 // Stops scanning for Physical Web URLs and clears cached URL content. |
| 91 virtual void StopDiscovery() = 0; | 76 virtual void StopDiscovery() = 0; |
| 92 | 77 |
| 93 // Returns a list of resolved URLs and associated page metadata. If network | 78 // Returns a list of resolved URLs and associated page metadata. If network |
| 94 // requests are disabled or if discovery is not active, the list will be | 79 // requests are disabled or if discovery is not active, the list will be |
| 95 // empty. The method can be called at any time to receive the current metadata | 80 // empty. The method can be called at any time to receive the current metadata |
| 96 // list. | 81 // list. |
| 97 virtual std::unique_ptr<MetadataList> GetMetadataList() = 0; | 82 virtual std::unique_ptr<MetadataList> GetMetadataList() = 0; |
| 98 | 83 |
| 99 // Returns a list of resolved URLs and associated page metadata. If network | |
| 100 // requests are disabled or if discovery is not active, the list will be | |
| 101 // empty. The method can be called at any time to receive the current metadata | |
| 102 // list. | |
| 103 // DEPRECATED | |
| 104 // TODO(cco3): Remove this when we are no longer dependent on it. | |
| 105 virtual std::unique_ptr<base::ListValue> GetMetadata() = 0; | |
| 106 | |
| 107 // Returns boolean |true| if network requests are disabled and there are one | 84 // Returns boolean |true| if network requests are disabled and there are one |
| 108 // or more discovered URLs that have not been sent to the resolution service. | 85 // or more discovered URLs that have not been sent to the resolution service. |
| 109 // The method can be called at any time to check for unresolved discoveries. | 86 // The method can be called at any time to check for unresolved discoveries. |
| 110 // If discovery is inactive or network requests are enabled, it will always | 87 // If discovery is inactive or network requests are enabled, it will always |
| 111 // return false. | 88 // return false. |
| 112 virtual bool HasUnresolvedDiscoveries() = 0; | 89 virtual bool HasUnresolvedDiscoveries() = 0; |
| 113 | 90 |
| 114 // Register for changes to Physical Web URLs and associated page metadata. | 91 // Register for changes to Physical Web URLs and associated page metadata. |
| 115 virtual void RegisterListener(PhysicalWebListener* physical_web_listener) = 0; | 92 virtual void RegisterListener(PhysicalWebListener* physical_web_listener) = 0; |
| 116 | 93 |
| 117 // Unregister for changes to Physical Web URLs and associated page metadata. | 94 // Unregister for changes to Physical Web URLs and associated page metadata. |
| 118 virtual void UnregisterListener( | 95 virtual void UnregisterListener( |
| 119 PhysicalWebListener* physical_web_listener) = 0; | 96 PhysicalWebListener* physical_web_listener) = 0; |
| 120 }; | 97 }; |
| 121 | 98 |
| 122 } // namespace physical_web | 99 } // namespace physical_web |
| 123 | 100 |
| 124 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ | 101 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| OLD | NEW |