Home | History | Annotate | Download | only in search_provider_logos
      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_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
      6 #define COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
      7 
      8 #include <string>
      9 
     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"
     14 
     15 namespace search_provider_logos {
     16 
     17 // The maximum number of milliseconds that a logo can be cached.
     18 extern const int64 kMaxTimeToLiveMS;
     19 
     20 struct LogoMetadata {
     21   LogoMetadata();
     22   ~LogoMetadata();
     23 
     24   // For use by the client ----------------------------------------------------
     25 
     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 
     33   // For use by LogoTracker ---------------------------------------------------
     34 
     35   // The URL from which the logo was downloaded (without the fingerprint param).
     36   std::string source_url;
     37   // A fingerprint (i.e. hash) identifying the logo. Used when revalidating the
     38   // logo with the server.
     39   std::string fingerprint;
     40   // Whether the logo can be shown optimistically after it's expired while a
     41   // fresh logo is being downloaded.
     42   bool can_show_after_expiration;
     43   // When the logo expires. After this time, the logo will not be used and will
     44   // be deleted.
     45   base::Time expiration_time;
     46 };
     47 
     48 struct EncodedLogo {
     49   EncodedLogo();
     50   ~EncodedLogo();
     51 
     52   // The jpeg- or png-encoded image.
     53   scoped_refptr<base::RefCountedString> encoded_image;
     54   // Metadata about the logo.
     55   LogoMetadata metadata;
     56 };
     57 
     58 struct Logo {
     59   Logo();
     60   ~Logo();
     61 
     62   // The logo image.
     63   SkBitmap image;
     64   // Metadata about the logo.
     65   LogoMetadata metadata;
     66 };
     67 
     68 }  // namespace search_provider_logos
     69 
     70 #endif  // COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
     71