tile.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2020 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. #ifndef COMPONENTS_QUERY_TILES_TILE_H_
  5. #define COMPONENTS_QUERY_TILES_TILE_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "base/time/time.h"
  10. #include "url/gurl.h"
  11. namespace query_tiles {
  12. // Metadata of a tile image.
  13. struct ImageMetadata {
  14. ImageMetadata();
  15. explicit ImageMetadata(const GURL& url);
  16. ~ImageMetadata();
  17. ImageMetadata(const ImageMetadata& other);
  18. bool operator==(const ImageMetadata& other) const;
  19. // URL of the image.
  20. GURL url;
  21. };
  22. // Stats of a tile, used for ranking.
  23. struct TileStats {
  24. TileStats();
  25. TileStats(base::Time last_clicked_time, double score);
  26. ~TileStats();
  27. TileStats(const TileStats& other);
  28. bool operator==(const TileStats& other) const;
  29. // Last clicked timestamp.
  30. base::Time last_clicked_time;
  31. // Score of the tile, used for ranking.
  32. double score;
  33. };
  34. // Represents the in memory structure of Tile.
  35. struct Tile {
  36. Tile();
  37. ~Tile();
  38. bool operator==(const Tile& other) const;
  39. bool operator!=(const Tile& other) const;
  40. Tile(const Tile& other);
  41. Tile(Tile&& other) noexcept;
  42. Tile& operator=(const Tile& other);
  43. Tile& operator=(Tile&& other) noexcept;
  44. // Unique Id for each entry.
  45. std::string id;
  46. // String of query that send to the search engine.
  47. std::string query_text;
  48. // String of the text that displays in UI.
  49. std::string display_text;
  50. // Text for accessibility purposes, in pair with |display_text|.
  51. std::string accessibility_text;
  52. // A list of images's matadatas.
  53. std::vector<ImageMetadata> image_metadatas;
  54. // A list of children of this tile.
  55. std::vector<std::unique_ptr<Tile>> sub_tiles;
  56. // Additional params for search query.
  57. std::vector<std::string> search_params;
  58. // Print pretty formatted content in Tile struct.
  59. std::string DebugString();
  60. };
  61. } // namespace query_tiles
  62. #endif // COMPONENTS_QUERY_TILES_TILE_H_