Index: components/physical_web/data_source/physical_web_data_source.h |
diff --git a/components/physical_web/data_source/physical_web_data_source.h b/components/physical_web/data_source/physical_web_data_source.h |
index c6310396ce1a25c4ac2a767975182c3def46f550..43e007c4cff301500dd98782f09eaa4876d7a424 100644 |
--- a/components/physical_web/data_source/physical_web_data_source.h |
+++ b/components/physical_web/data_source/physical_web_data_source.h |
@@ -6,6 +6,10 @@ |
#define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
#include <memory> |
+#include <string> |
+#include <vector> |
+#include "base/time/time.h" |
+#include "url/gurl.h" |
namespace base { |
class ListValue; |
@@ -16,6 +20,7 @@ namespace physical_web { |
class PhysicalWebListener; |
// Dictionary keys for reading Physical Web URL metadata. |
+// TODO(cco3): Remove these when we are no longer dependent. |
extern const char kDescriptionKey[]; |
extern const char kDistanceEstimateKey[]; |
extern const char kGroupIdKey[]; |
@@ -25,6 +30,35 @@ extern const char kScanTimestampKey[]; |
extern const char kScannedUrlKey[]; |
extern const char kTitleKey[]; |
+// Metadata struct for associating data with Physical Web URLs. |
+struct Metadata { |
mattreynolds
2016/12/09 00:10:03
We should comment on which fields are optional. II
|
+ Metadata(); |
+ Metadata(const Metadata& other); |
+ ~Metadata(); |
+ // The URL broadcasted by the beacon and scanned by the client device. |
+ GURL scanned_url; |
+ // The URL that the scanned_url redirects to. |
+ // This is the URL that users should be directed to. |
+ GURL resolved_url; |
+ // The favicon URL. |
+ GURL icon_url; |
+ // The title of the web page. |
+ std::string title; |
+ // The description of the web page. |
+ std::string description; |
+ // An identifier that associates multiple resolved URLs. If two URLs have |
+ // the same group id, only one should be shown (typically, the one with the |
+ // smallest distance estimate). |
+ std::string group_id; |
+ // The estimated distance between the user and the Physical Web device (e.g., |
+ // beacon) in meters. |
+ double distance_estimate; |
+ // The timestamp corresponding to when this URL was last scanned. |
+ base::Time scan_timestamp; |
+}; |
+ |
+using MetadataList = std::vector<Metadata>; |
+ |
// Helper class for accessing Physical Web metadata and controlling the scanner. |
class PhysicalWebDataSource { |
public: |
@@ -41,6 +75,14 @@ class PhysicalWebDataSource { |
// requests are disabled or if discovery is not active, the list will be |
// empty. The method can be called at any time to receive the current metadata |
// list. |
+ virtual std::unique_ptr<MetadataList> GetMetadataList() = 0; |
+ |
+ // Returns a list of resolved URLs and associated page metadata. If network |
+ // requests are disabled or if discovery is not active, the list will be |
+ // empty. The method can be called at any time to receive the current metadata |
+ // list. |
+ // DEPRECATED |
+ // TODO(cco3): Remove this when we are no longer dependent on it. |
virtual std::unique_ptr<base::ListValue> GetMetadata() = 0; |
// Returns boolean |true| if network requests are disabled and there are one |