[M73 Dev][EFL] Disable VizDisplayCompositor for EFL port
[platform/framework/web/chromium-efl.git] / components / favicon_base / favicon_types.h
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 <stdint.h>
9
10 #include <memory>
11
12 #include "base/containers/flat_set.h"
13 #include "base/memory/ref_counted_memory.h"
14 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/image/image.h"
16 #include "url/gurl.h"
17
18 namespace favicon_base {
19
20 struct FallbackIconStyle;
21
22 typedef int64_t FaviconID;
23
24 // Defines the icon types.
25 //
26 // IMPORTANT: these values must stay in sync with the FaviconType enum in
27 // tools/metrics/histograms/enum.xml.
28 //
29 // The values of the IconTypes are used to select the priority in which favicon
30 // data is returned in HistoryBackend and ThumbnailDatabase.
31 //
32 // A Java counterpart will be generated for this enum.
33 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.favicon
34 enum class IconType {
35   kInvalid = 0,
36   kFavicon,
37   kTouchIcon,
38   kTouchPrecomposedIcon,
39   kWebManifestIcon,
40   kMax = kWebManifestIcon,
41   kCount
42 };
43
44 using IconTypeSet = base::flat_set<IconType>;
45
46 // Defines a gfx::Image of size desired_size_in_dip composed of image
47 // representations for each of the desired scale factors.
48 struct FaviconImageResult {
49   FaviconImageResult();
50   ~FaviconImageResult();
51
52   // The resulting image.
53   gfx::Image image;
54
55   // The URL of the favicon which contains all of the image representations of
56   // |image|.
57   // TODO(pkotwicz): Return multiple |icon_urls| to allow |image| to have
58   // representations from several favicons once content::FaviconStatus supports
59   // multiple URLs.
60   GURL icon_url;
61 };
62
63 // Defines a favicon bitmap which best matches the desired DIP size and one of
64 // the desired scale factors.
65 struct FaviconRawBitmapResult {
66   FaviconRawBitmapResult();
67   FaviconRawBitmapResult(const FaviconRawBitmapResult& other);
68   ~FaviconRawBitmapResult();
69
70   // Returns true if |bitmap_data| contains a valid bitmap.
71   bool is_valid() const { return bitmap_data.get() && bitmap_data->size(); }
72
73   // Indicates whether |bitmap_data| is expired.
74   bool expired;
75
76   // The bits of the bitmap.
77   scoped_refptr<base::RefCountedMemory> bitmap_data;
78
79   // The pixel dimensions of |bitmap_data|.
80   gfx::Size pixel_size;
81
82   // The URL of the containing favicon.
83   GURL icon_url;
84
85   // The icon type of the containing favicon.
86   IconType icon_type;
87
88   // Indicates whether the bitmap was fetched upon visiting a page. Value
89   // false means that it was fetched on-demand by the UI of chrome, without
90   // visiting the page.
91   bool fetched_because_of_page_visit;
92 };
93
94 // Define type with same structure as FaviconRawBitmapResult for passing data to
95 // HistoryBackend::SetFavicons().
96 typedef FaviconRawBitmapResult FaviconRawBitmapData;
97
98 // Result returned by LargeIconService::GetLargeIconOrFallbackStyle(). Contains
99 // either the bitmap data if the favicon database has a sufficiently large
100 // favicon bitmap and the style of the fallback icon otherwise.
101 struct LargeIconResult {
102   explicit LargeIconResult(const FaviconRawBitmapResult& bitmap_in);
103
104   // Takes ownership of |fallback_icon_style_in|.
105   explicit LargeIconResult(FallbackIconStyle* fallback_icon_style_in);
106
107   ~LargeIconResult();
108
109   // The bitmap from the favicon database if the database has a sufficiently
110   // large one.
111   FaviconRawBitmapResult bitmap;
112
113   // The fallback icon style if a sufficiently large icon isn't available. This
114   // uses the dominant color of a smaller icon as the background if available.
115   std::unique_ptr<FallbackIconStyle> fallback_icon_style;
116 };
117
118 // Result returned by LargeIconService::GetLargeIconImageOrFallbackStyle().
119 // Contains either the gfx::Image if the favicon database has a sufficiently
120 // large favicon bitmap and the style of the fallback icon otherwise.
121 struct LargeIconImageResult {
122   explicit LargeIconImageResult(const gfx::Image& image_in,
123                                 const GURL& icon_url_in);
124
125   // Takes ownership of |fallback_icon_style_in|.
126   explicit LargeIconImageResult(FallbackIconStyle* fallback_icon_style_in);
127
128   ~LargeIconImageResult();
129
130   // The image from the favicon database if the database has a sufficiently
131   // large one.
132   gfx::Image image;
133
134   // The URL of the containing favicon. Specified only if |image| is not empty.
135   GURL icon_url;
136
137   // The fallback icon style if a sufficiently large icon isn't available. This
138   // uses the dominant color of a smaller icon as the background if available.
139   std::unique_ptr<FallbackIconStyle> fallback_icon_style;
140 };
141
142 // Enumeration listing all possible outcomes for fetch attempts from Google
143 // favicon server. Used for UMA enum GoogleFaviconServerRequestStatus, so do not
144 // change existing values. Insert new values at the end, and update the
145 // histogram definition.
146 enum class GoogleFaviconServerRequestStatus {
147   // Request sent out and the favicon successfully fetched.
148   SUCCESS = 0,
149   // Request sent out and a connection error occurred (no valid HTTP response
150   // recevied).
151   FAILURE_CONNECTION_ERROR = 1,
152   // Request sent out and a HTTP error received.
153   FAILURE_HTTP_ERROR = 2,
154   // Request not sent out (previous HTTP error in cache).
155   FAILURE_HTTP_ERROR_CACHED = 3,
156   // Request sent out and favicon fetched but writing to database failed.
157   FAILURE_ON_WRITE = 4,
158   // Request not sent out (the request or the fetcher was invalid).
159   DEPRECATED_FAILURE_INVALID = 5,
160   // Request not sent out (the target URL was an IP address or its scheme was
161   // not http(s)).
162   FAILURE_TARGET_URL_SKIPPED = 6,
163   // Request not sent out (the target URL was not valid).
164   FAILURE_TARGET_URL_INVALID = 7,
165   // Request not sent out (the server URL was not valid).
166   FAILURE_SERVER_URL_INVALID = 8,
167   // Request not sent out (as there already is an icon in the local favicon
168   // database that prevents a new one to be stored).
169   FAILURE_ICON_EXISTS_IN_DB = 9,
170   // Insert new values here.
171   COUNT
172 };
173
174 }  // namespace favicon_base
175
176 #endif  // COMPONENTS_FAVICON_BASE_FAVICON_TYPES_H_