Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / android_webview / browser / icon_helper.h
blobdc9a1d63f858fee1594ae8a9d8cbbedbad987e4d
1 // Copyright (c) 2013 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 ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_
6 #define ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_
8 #include <string>
9 #include "base/containers/hash_tables.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "url/gurl.h"
13 class SkBitmap;
15 namespace content {
16 struct FaviconURL;
19 namespace gfx {
20 class Size;
23 namespace android_webview {
25 // A helper that observes favicon changes for Webview.
26 class IconHelper : public content::WebContentsObserver {
27 public:
28 class Listener {
29 public:
30 virtual bool ShouldDownloadFavicon(const GURL& icon_url) = 0;
31 virtual void OnReceivedIcon(const GURL& icon_url,
32 const SkBitmap& bitmap) = 0;
33 virtual void OnReceivedTouchIconUrl(const std::string& url,
34 const bool precomposed) = 0;
35 protected:
36 virtual ~Listener() {}
39 explicit IconHelper(content::WebContents* web_contents);
40 ~IconHelper() override;
42 void SetListener(Listener* listener);
44 // From WebContentsObserver
45 void DidUpdateFaviconURL(
46 const std::vector<content::FaviconURL>& candidates) override;
47 void DidStartNavigationToPendingEntry(
48 const GURL& url,
49 content::NavigationController::ReloadType reload_type) override;
51 void DownloadFaviconCallback(
52 int id,
53 int http_status_code,
54 const GURL& image_url,
55 const std::vector<SkBitmap>& bitmaps,
56 const std::vector<gfx::Size>& original_bitmap_sizes);
58 private:
59 void MarkUnableToDownloadFavicon(const GURL& icon_url);
60 bool WasUnableToDownloadFavicon(const GURL& icon_url) const;
61 void ClearUnableToDownloadFavicons();
63 Listener* listener_;
65 typedef uint32 MissingFaviconURLHash;
66 base::hash_set<MissingFaviconURLHash> missing_favicon_urls_;
68 DISALLOW_COPY_AND_ASSIGN(IconHelper);
71 } // namespace android_webview
73 #endif // ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_