Revert of ui: Clean up damaged rects and clear them after painting. (patchset #2...
[chromium-blink-merge.git] / components / favicon / content / content_favicon_driver.h
blob18ef1bff5bd954375efc87c0a7a555beb690b1a5
1 // Copyright 2015 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_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_
6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_
8 #include "components/favicon/core/favicon_driver_impl.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
11 #include "url/gurl.h"
13 namespace content {
14 struct FaviconStatus;
15 struct FaviconURL;
16 class WebContents;
19 namespace favicon {
21 // ContentFaviconDriver is an implementation of FaviconDriver that listens to
22 // WebContents events to start download of favicons and to get informed when the
23 // favicon download has completed.
24 class ContentFaviconDriver
25 : public content::WebContentsObserver,
26 public content::WebContentsUserData<ContentFaviconDriver>,
27 public FaviconDriverImpl {
28 public:
29 static void CreateForWebContents(content::WebContents* web_contents,
30 FaviconService* favicon_service,
31 history::HistoryService* history_service,
32 bookmarks::BookmarkModel* bookmark_model);
34 // Returns the current tab's favicon URLs. If this is empty,
35 // DidUpdateFaviconURL has not yet been called for the current navigation.
36 const std::vector<content::FaviconURL>& favicon_urls() const {
37 return favicon_urls_;
40 // FaviconDriver implementation.
41 gfx::Image GetFavicon() const override;
42 bool FaviconIsValid() const override;
43 int StartDownload(const GURL& url, int max_bitmap_size) override;
44 bool IsOffTheRecord() override;
45 GURL GetActiveURL() override;
46 base::string16 GetActiveTitle() override;
47 bool GetActiveFaviconValidity() override;
48 void SetActiveFaviconValidity(bool valid) override;
49 GURL GetActiveFaviconURL() override;
50 void SetActiveFaviconURL(const GURL& url) override;
51 gfx::Image GetActiveFaviconImage() override;
52 void SetActiveFaviconImage(const gfx::Image& image) override;
54 protected:
55 ContentFaviconDriver(content::WebContents* web_contents,
56 FaviconService* favicon_service,
57 history::HistoryService* history_service,
58 bookmarks::BookmarkModel* bookmark_model);
59 ~ContentFaviconDriver() override;
61 private:
62 friend class content::WebContentsUserData<ContentFaviconDriver>;
64 // FaviconDriver implementation.
65 void NotifyFaviconUpdated(bool icon_url_changed) override;
67 // content::WebContentsObserver implementation.
68 void DidUpdateFaviconURL(
69 const std::vector<content::FaviconURL>& candidates) override;
70 void DidStartNavigationToPendingEntry(
71 const GURL& url,
72 content::NavigationController::ReloadType reload_type) override;
73 void DidNavigateMainFrame(
74 const content::LoadCommittedDetails& details,
75 const content::FrameNavigateParams& params) override;
77 // Returns the active navigation entry's favicon.
78 content::FaviconStatus& GetFaviconStatus();
80 GURL bypass_cache_page_url_;
81 std::vector<content::FaviconURL> favicon_urls_;
83 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver);
86 } // namespace favicon
88 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_