Index: chrome/browser/history/history_types.h |
diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h |
index 6ae787e32c0c599a0088fe98730ecb62f5ffe57a..ecc4acf19cde34d6503890a32d4a6e613141054a 100644 |
--- a/chrome/browser/history/history_types.h |
+++ b/chrome/browser/history/history_types.h |
@@ -274,23 +274,6 @@ typedef std::vector<VisitRow> VisitVector; |
// used by HistoryBackend::AddVisits() to create new visits for a URL. |
typedef std::pair<base::Time, content::PageTransition> VisitInfo; |
-// Favicons ------------------------------------------------------------------- |
- |
-// Used by the importer to set favicons for imported bookmarks. |
-struct ImportedFaviconUsage { |
- ImportedFaviconUsage(); |
- ~ImportedFaviconUsage(); |
- |
- // The URL of the favicon. |
- GURL favicon_url; |
- |
- // The raw png-encoded data. |
- std::vector<unsigned char> png_data; |
- |
- // The list of URLs using this favicon. |
- std::set<GURL> urls; |
-}; |
- |
// PageVisit ------------------------------------------------------------------ |
// Represents a simplified version of a visit for external users. Normally, |
@@ -768,40 +751,122 @@ struct IconMapping { |
// The unique id of the icon. |
FaviconID icon_id; |
+ // The url of the icon. |
+ GURL icon_url; |
+ |
// The type of icon. |
IconType icon_type; |
}; |
+// Sizes represents the sizes that the thumbnail database knows a favicon is |
+// available at from the web. This can be different from the pixel sizes of |
+// the favicon bitmaps stored for the favicon. For instance, if a web page has |
+// a .ico favicon with bitmaps of pixel sizes (16x16, 24x24, 32x32), |
+// FaviconSizes::has_size will be true for all three pixel sizes regardless of |
+// whether bitmaps for all three pixel sizes are stored in the favicon_bitmaps |
+// database table. However, the pixel sizes of favicon bitmaps stored for a |
+// FaviconID must be a subset of the FaviconSizes for the favicon. |
+// FaviconSizes intentionally supports copy and assign. |
+class FaviconSizes { |
+ public: |
+ FaviconSizes(); |
+ FaviconSizes(const std::string& string_representation); |
+ FaviconSizes(const std::vector<gfx::Size>& vector_representation); |
+ ~FaviconSizes(); |
+ |
+ // Inserts size to the list of sizes supported by the favicon. |
+ void InsertSize(const gfx::Size& size); |
+ |
+ // Returns true if |size| is supported by the favicon. |
+ bool has_size(const gfx::Size& size) const { |
+ return sizes_.find(size) != sizes_.end(); |
+ } |
+ |
+ size_t num_sizes() const { return sizes_.size(); } |
+ |
+ // Returns string representation of sizes. |
+ // Format: |
+ // Each widthxheight pair is separated by a space. |
+ // Width and height are separated by a space. |
+ // For instance, if sizes contains pixel sizes (16x16, 32x32), the |
+ // string representation is "16 16 32 32". |
+ std::string ToString() const; |
+ |
+ // Returns vector representation of sizes. |
+ std::vector<gfx::Size> ToVector() const; |
+ |
+ private: |
+ std::set<gfx::Size> sizes_; |
+}; |
+ |
+// Defines a favicon bitmap stored in the history backend. |
+struct FaviconDataElement { |
+ FaviconDataElement(); |
+ ~FaviconDataElement(); |
+ |
+ // The bits of the bitmap. |
+ scoped_refptr<base::RefCountedMemory> bitmap_data; |
+ |
+ // The pixel dimensions of |bitmap_data|. |
+ gfx::Size pixel_size; |
+ |
+ // The icon's URL. |
+ GURL icon_url; |
+}; |
+ |
+// Mapping of icon URL to the sizes the favicon is available at from the web. |
+typedef std::map<GURL, FaviconSizes> IconURLSizesMap; |
+ |
// Defines the favicon stored in history backend. |
struct FaviconData { |
FaviconData(); |
~FaviconData(); |
- // Returns true if the icon is known and image has data. |
+ // Returns true if the icon is known, there is at least one element in |
+ // |elements| and all |elements| have valid data. |
bool is_valid(); |
// Indicates whether the icon is known by the history backend. |
bool known_icon; |
- // The bits of image. |
- scoped_refptr<base::RefCountedMemory> image_data; |
- |
- // Indicates whether image is expired. |
+ // Indicates whether at least one of the bitmaps in |elements| is expired. |
bool expired; |
- // The icon's URL. |
- GURL icon_url; |
- |
// The type of favicon. |
history::IconType icon_type; |
+ |
+ // Each entry in |elements| represents a favicon bitmap at a different pixel |
+ // size. |
+ // If a |pixel_size| parameter was passed in order to get the favicon data, |
+ // |elements| will have a single entry with the best match for |pixel_size|. |
+ std::vector<FaviconDataElement> elements; |
+ |
+ // Mapping of icon URL to the sizes that the favicon at the icon URL is |
+ // available at from the web. |
+ IconURLSizesMap icon_url_sizes; |
+}; |
+ |
+// Defines a favicon bitmap and its associated pixel size. |
+struct FaviconBitmapIDSize { |
+ FaviconBitmapIDSize(); |
+ ~FaviconBitmapIDSize(); |
+ |
+ // The unique id of the favicon bitmap. |
+ FaviconBitmapID bitmap_id; |
+ |
+ // The pixel dimensions of the associated bitmap. |
+ gfx::Size pixel_size; |
}; |
// Defines a favicon bitmap stored in the history backend. |
struct FaviconBitmap { |
+ FaviconBitmap(); |
+ ~FaviconBitmap(); |
+ |
// The unique id of the bitmap. |
FaviconBitmapID bitmap_id; |
- // The id of the favicon to which the bitmap belongs to. |
+ // The id of the favicon to which the bitmap belongs. |
FaviconID icon_id; |
// Time at which |bitmap_data| was last updated. |
@@ -814,6 +879,21 @@ struct FaviconBitmap { |
gfx::Size pixel_size; |
}; |
+// Used by the importer to set favicons for imported bookmarks. |
+struct ImportedFaviconUsage { |
+ ImportedFaviconUsage(); |
+ ~ImportedFaviconUsage(); |
+ |
+ // The URL of the favicon. |
+ GURL favicon_url; |
+ |
+ // The raw png-encoded data. |
+ std::vector<unsigned char> png_data; |
+ |
+ // The list of URLs using this favicon. |
+ std::set<GURL> urls; |
+}; |
+ |
// Abbreviated information about a visit. |
struct BriefVisitInfo { |
URLID url_id; |