summaryrefslogtreecommitdiffstats
path: root/components/search_provider_logos/logo_common.h
diff options
context:
space:
mode:
authornewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 20:04:23 +0000
committernewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 20:04:23 +0000
commitcf59dd169aa864e41d6fbd32384e831e4ab80fba (patch)
tree1aa4556475e9322d829a26519f7b2f4c376fae8d /components/search_provider_logos/logo_common.h
parentebb3ad52433c978a914d0b387690dc98c791736a (diff)
downloadchromium_src-cf59dd169aa864e41d6fbd32384e831e4ab80fba.zip
chromium_src-cf59dd169aa864e41d6fbd32384e831e4ab80fba.tar.gz
chromium_src-cf59dd169aa864e41d6fbd32384e831e4ab80fba.tar.bz2
Add LogoTracker to fetch search providers' logos.
The LogoTracker keeps track of the logo for a search provider. The logo is downloaded, cached on disk, and periodically revalidated. This code lives inside a component (search_provider_logos) so it can be used on both Android and iOS. BUG=178922 NOTRY=true Review URL: https://codereview.chromium.org/162373002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/search_provider_logos/logo_common.h')
-rw-r--r--components/search_provider_logos/logo_common.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/components/search_provider_logos/logo_common.h b/components/search_provider_logos/logo_common.h
new file mode 100644
index 0000000..207026b
--- /dev/null
+++ b/components/search_provider_logos/logo_common.h
@@ -0,0 +1,70 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
+#define COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/time/time.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace search_provider_logos {
+
+// The maximum number of milliseconds that a logo can be cached.
+extern const int64 kMaxTimeToLiveMS;
+
+struct LogoMetadata {
+ LogoMetadata();
+ ~LogoMetadata();
+
+ // For use by the client ----------------------------------------------------
+
+ // The URL to load when the logo is clicked.
+ std::string on_click_url;
+ // The accessibility text for the logo.
+ std::string alt_text;
+ // The mime type of the logo image.
+ std::string mime_type;
+
+ // For use by LogoTracker ---------------------------------------------------
+
+ // The URL from which the logo was downloaded (without the fingerprint param).
+ std::string source_url;
+ // A fingerprint (i.e. hash) identifying the logo. Used when revalidating the
+ // logo with the server.
+ std::string fingerprint;
+ // Whether the logo can be shown optimistically after it's expired while a
+ // fresh logo is being downloaded.
+ bool can_show_after_expiration;
+ // When the logo expires. After this time, the logo will not be used and will
+ // be deleted.
+ base::Time expiration_time;
+};
+
+struct EncodedLogo {
+ EncodedLogo();
+ ~EncodedLogo();
+
+ // The jpeg- or png-encoded image.
+ scoped_refptr<base::RefCountedString> encoded_image;
+ // Metadata about the logo.
+ LogoMetadata metadata;
+};
+
+struct Logo {
+ Logo();
+ ~Logo();
+
+ // The logo image.
+ SkBitmap image;
+ // Metadata about the logo.
+ LogoMetadata metadata;
+};
+
+} // namespace search_provider_logos
+
+#endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_COMMON_H_