Don't preload rarely seen large images
[chromium-blink-merge.git] / components / search_provider_logos / logo_common.h
blob86b5700fa865dc9c5638cc4278b4a5901a1b9977
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.
5 #ifndef COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
6 #define COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/ref_counted_memory.h"
12 #include "base/time/time.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
15 namespace search_provider_logos {
17 // The maximum number of milliseconds that a logo can be cached.
18 extern const int64 kMaxTimeToLiveMS;
20 struct LogoMetadata {
21 LogoMetadata();
22 ~LogoMetadata();
24 // For use by the client ----------------------------------------------------
26 // The URL to load when the logo is clicked.
27 std::string on_click_url;
28 // The accessibility text for the logo.
29 std::string alt_text;
30 // The mime type of the logo image.
31 std::string mime_type;
32 // The URL for an animated image to display when the call to action logo is
33 // clicked. If |animated_url| is not empty, |encoded_image| refers to a call
34 // to action image.
35 std::string animated_url;
37 // For use by LogoTracker ---------------------------------------------------
39 // The URL from which the logo was downloaded (without the fingerprint param).
40 std::string source_url;
41 // A fingerprint (i.e. hash) identifying the logo. Used when revalidating the
42 // logo with the server.
43 std::string fingerprint;
44 // Whether the logo can be shown optimistically after it's expired while a
45 // fresh logo is being downloaded.
46 bool can_show_after_expiration;
47 // When the logo expires. After this time, the logo will not be used and will
48 // be deleted.
49 base::Time expiration_time;
52 struct EncodedLogo {
53 EncodedLogo();
54 ~EncodedLogo();
56 // The jpeg- or png-encoded image.
57 scoped_refptr<base::RefCountedString> encoded_image;
58 // Metadata about the logo.
59 LogoMetadata metadata;
62 struct Logo {
63 Logo();
64 ~Logo();
66 // The logo image.
67 SkBitmap image;
68 // Metadata about the logo.
69 LogoMetadata metadata;
72 } // namespace search_provider_logos
74 #endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_