Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Side by Side Diff: components/favicon/content/content_favicon_driver.h

Issue 2799273002: Add support to process favicons from Web Manifests (Closed)
Patch Set: Addressed comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
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_;
pkotwicz 2017/05/11 06:12:57 Can this be a normal std::vector? I think that we
mastiz 2017/05/11 08:45:18 The condition in content_favicon_driver.cc:199 nee
pkotwicz 2017/05/12 06:13:28 I see. Thank you for pointing this out
88 // Whether DidUpdateManifestURL() was called at least once after
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_;
92 base::Optional<GURL> manifest_url_;
pkotwicz 2017/05/11 06:12:57 Can this just be a GURL? I think that we treat an
mastiz 2017/05/11 08:45:18 This is feasible, but note that WebContents' API e
pkotwicz 2017/05/12 06:13:28 In my opinion being consistent with the WebContent
mastiz 2017/05/12 13:31:32 Done.
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_
OLDNEW
« no previous file with comments | « chrome/test/data/favicon/page_with_manifest.html ('k') | components/favicon/content/content_favicon_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698