blob: 287be27f01639e692ee60dea7ea39328099f4e3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (c) 2013 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 ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_
#define ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_
#include <string>
#include "base/containers/hash_tables.h"
#include "content/public/browser/web_contents_observer.h"
#include "url/gurl.h"
class SkBitmap;
namespace content {
struct FaviconURL;
}
namespace gfx {
class Size;
}
namespace android_webview {
// A helper that observes favicon changes for Webview.
class IconHelper : public content::WebContentsObserver {
public:
class Listener {
public:
virtual bool ShouldDownloadFavicon(const GURL& icon_url) = 0;
virtual void OnReceivedIcon(const GURL& icon_url,
const SkBitmap& bitmap) = 0;
virtual void OnReceivedTouchIconUrl(const std::string& url,
const bool precomposed) = 0;
protected:
virtual ~Listener() {}
};
explicit IconHelper(content::WebContents* web_contents);
virtual ~IconHelper();
void SetListener(Listener* listener);
// From WebContentsObserver
virtual void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) override;
virtual void DidStartNavigationToPendingEntry(
const GURL& url,
content::NavigationController::ReloadType reload_type) override;
void DownloadFaviconCallback(
int id,
int http_status_code,
const GURL& image_url,
const std::vector<SkBitmap>& bitmaps,
const std::vector<gfx::Size>& original_bitmap_sizes);
private:
void MarkUnableToDownloadFavicon(const GURL& icon_url);
bool WasUnableToDownloadFavicon(const GURL& icon_url) const;
void ClearUnableToDownloadFavicons();
Listener* listener_;
typedef uint32 MissingFaviconURLHash;
base::hash_set<MissingFaviconURLHash> missing_favicon_urls_;
DISALLOW_COPY_AND_ASSIGN(IconHelper);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_ICON_HELPER_H_
|