OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 5 #ifndef COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/optional.h" | |
9 #include "components/favicon/core/favicon_driver_impl.h" | 10 #include "components/favicon/core/favicon_driver_impl.h" |
10 #include "content/public/browser/reload_type.h" | 11 #include "content/public/browser/reload_type.h" |
11 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
12 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 struct FaviconURL; | 17 struct FaviconURL; |
17 class WebContents; | 18 class WebContents; |
18 } | 19 } |
(...skipping 10 matching lines...) Expand all Loading... | |
29 public: | 30 public: |
30 ~ContentFaviconDriver() override; | 31 ~ContentFaviconDriver() override; |
31 | 32 |
32 static void CreateForWebContents(content::WebContents* web_contents, | 33 static void CreateForWebContents(content::WebContents* web_contents, |
33 FaviconService* favicon_service, | 34 FaviconService* favicon_service, |
34 history::HistoryService* history_service, | 35 history::HistoryService* history_service, |
35 bookmarks::BookmarkModel* bookmark_model); | 36 bookmarks::BookmarkModel* bookmark_model); |
36 | 37 |
37 // Returns the current tab's favicon URLs. If this is empty, | 38 // Returns the current tab's favicon URLs. If this is empty, |
38 // DidUpdateFaviconURL has not yet been called for the current navigation. | 39 // DidUpdateFaviconURL has not yet been called for the current navigation. |
39 const std::vector<content::FaviconURL>& favicon_urls() const { | 40 const base::Optional<std::vector<content::FaviconURL>>& favicon_urls() const { |
40 return favicon_urls_; | 41 return favicon_urls_; |
41 } | 42 } |
pkotwicz
2017/05/12 06:13:29
Can this function return a std::vector<content::Fa
mastiz
2017/05/12 13:31:33
By reintroducing the ambiguity between not having
pkotwicz
2017/05/12 15:37:41
The comment is correct for http page URLs because
mastiz
2017/05/15 14:07:00
Reverted. It however returns by value, since retur
| |
42 | 43 |
43 // Saves the favicon for the last committed navigation entry to the thumbnail | 44 // Saves the favicon for the last committed navigation entry to the thumbnail |
44 // database. | 45 // database. |
45 void SaveFavicon(); | 46 void SaveFavicon(); |
46 | 47 |
47 // FaviconDriver implementation. | 48 // FaviconDriver implementation. |
48 gfx::Image GetFavicon() const override; | 49 gfx::Image GetFavicon() const override; |
49 bool FaviconIsValid() const override; | 50 bool FaviconIsValid() const override; |
50 GURL GetActiveURL() override; | 51 GURL GetActiveURL() override; |
51 | 52 |
52 protected: | 53 protected: |
53 ContentFaviconDriver(content::WebContents* web_contents, | 54 ContentFaviconDriver(content::WebContents* web_contents, |
54 FaviconService* favicon_service, | 55 FaviconService* favicon_service, |
55 history::HistoryService* history_service, | 56 history::HistoryService* history_service, |
56 bookmarks::BookmarkModel* bookmark_model); | 57 bookmarks::BookmarkModel* bookmark_model); |
57 | 58 |
58 private: | 59 private: |
59 friend class content::WebContentsUserData<ContentFaviconDriver>; | 60 friend class content::WebContentsUserData<ContentFaviconDriver>; |
60 | 61 |
61 // FaviconHandler::Delegate implementation. | 62 // FaviconHandler::Delegate implementation. |
62 int DownloadImage(const GURL& url, | 63 int DownloadImage(const GURL& url, |
63 int max_image_size, | 64 int max_image_size, |
64 ImageDownloadCallback callback) override; | 65 ImageDownloadCallback callback) override; |
66 void DownloadManifest(const GURL& url, | |
67 ManifestDownloadCallback callback) override; | |
65 bool IsOffTheRecord() override; | 68 bool IsOffTheRecord() override; |
66 void OnFaviconUpdated(const GURL& page_url, | 69 void OnFaviconUpdated(const GURL& page_url, |
67 FaviconDriverObserver::NotificationIconType icon_type, | 70 FaviconDriverObserver::NotificationIconType icon_type, |
68 const GURL& icon_url, | 71 const GURL& icon_url, |
69 bool icon_url_changed, | 72 bool icon_url_changed, |
70 const gfx::Image& image) override; | 73 const gfx::Image& image) override; |
71 | 74 |
72 // content::WebContentsObserver implementation. | 75 // content::WebContentsObserver implementation. |
73 void DidUpdateFaviconURL( | 76 void DidUpdateFaviconURL( |
74 const std::vector<content::FaviconURL>& candidates) override; | 77 const std::vector<content::FaviconURL>& candidates) override; |
78 void DidUpdateWebManifestURL( | |
79 const base::Optional<GURL>& manifest_url) override; | |
75 void DidStartNavigation( | 80 void DidStartNavigation( |
76 content::NavigationHandle* navigation_handle) override; | 81 content::NavigationHandle* navigation_handle) override; |
77 void DidFinishNavigation( | 82 void DidFinishNavigation( |
78 content::NavigationHandle* navigation_handle) override; | 83 content::NavigationHandle* navigation_handle) override; |
79 | 84 |
80 GURL bypass_cache_page_url_; | 85 GURL bypass_cache_page_url_; |
81 std::vector<content::FaviconURL> favicon_urls_; | 86 // nullopt until the actual list is reported via DidUpdateFaviconURL(). |
87 base::Optional<std::vector<content::FaviconURL>> favicon_urls_; | |
88 // Whether DidUpdateManifestURL() was called at least once after | |
pkotwicz
2017/05/12 06:13:28
I am probably missing something. Does DidUpdateWeb
mastiz
2017/05/12 13:31:32
I removed the comment. Wrt to your question, in ge
pkotwicz
2017/05/12 15:37:42
Thanks
| |
89 // DidStartNavigation(). Note that this doesn't imply an actual manifest URL, | |
90 // i.e. the page might not have a web manifest. | |
91 bool received_manifest_url_; | |
pkotwicz
2017/05/12 06:13:29
|received_manifest_url_| seems unused?
mastiz
2017/05/12 13:31:32
Removed, thanks.
| |
92 base::Optional<GURL> manifest_url_; | |
82 | 93 |
83 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); | 94 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); |
84 }; | 95 }; |
85 | 96 |
86 } // namespace favicon | 97 } // namespace favicon |
87 | 98 |
88 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 99 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
OLD | NEW |