Home | History | Annotate | Download | only in favicon_base
      1 // Copyright 2014 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_FAVICON_BASE_FAVICON_TYPES_H_
      6 #define COMPONENTS_FAVICON_BASE_FAVICON_TYPES_H_
      7 
      8 #include "base/memory/ref_counted_memory.h"
      9 #include "ui/gfx/image/image.h"
     10 #include "ui/gfx/size.h"
     11 #include "url/gurl.h"
     12 
     13 namespace favicon_base {
     14 
     15 typedef int64 FaviconID;
     16 
     17 // Defines the icon types. They are also stored in icon_type field of favicons
     18 // table.
     19 // The values of the IconTypes are used to select the priority in which favicon
     20 // data is returned in HistoryBackend and ThumbnailDatabase. Data for the
     21 // largest IconType takes priority if data for multiple IconTypes is available.
     22 enum IconType {
     23   INVALID_ICON = 0x0,
     24   FAVICON = 1 << 0,
     25   TOUCH_ICON = 1 << 1,
     26   TOUCH_PRECOMPOSED_ICON = 1 << 2
     27 };
     28 
     29 // Defines a gfx::Image of size desired_size_in_dip composed of image
     30 // representations for each of the desired scale factors.
     31 struct FaviconImageResult {
     32   FaviconImageResult();
     33   ~FaviconImageResult();
     34 
     35   // The resulting image.
     36   gfx::Image image;
     37 
     38   // The URL of the favicon which contains all of the image representations of
     39   // |image|.
     40   // TODO(pkotwicz): Return multiple |icon_urls| to allow |image| to have
     41   // representations from several favicons once content::FaviconStatus supports
     42   // multiple URLs.
     43   GURL icon_url;
     44 };
     45 
     46 // Defines a favicon bitmap which best matches the desired DIP size and one of
     47 // the desired scale factors.
     48 struct FaviconRawBitmapResult {
     49   FaviconRawBitmapResult();
     50   ~FaviconRawBitmapResult();
     51 
     52   // Returns true if |bitmap_data| contains a valid bitmap.
     53   bool is_valid() const { return bitmap_data.get() && bitmap_data->size(); }
     54 
     55   // Indicates whether |bitmap_data| is expired.
     56   bool expired;
     57 
     58   // The bits of the bitmap.
     59   scoped_refptr<base::RefCountedMemory> bitmap_data;
     60 
     61   // The pixel dimensions of |bitmap_data|.
     62   gfx::Size pixel_size;
     63 
     64   // The URL of the containing favicon.
     65   GURL icon_url;
     66 
     67   // The icon type of the containing favicon.
     68   IconType icon_type;
     69 };
     70 
     71 // Define type with same structure as FaviconRawBitmapResult for passing data to
     72 // HistoryBackend::SetFavicons().
     73 typedef FaviconRawBitmapResult FaviconRawBitmapData;
     74 
     75 }  // namespace favicon_base
     76 
     77 #endif  // COMPONENTS_FAVICON_BASE_FAVICON_TYPES_H_
     78