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

Side by Side Diff: chrome/browser/favicon/favicon_downloader.h

Issue 64853004: Use high resolution icons where possible for streamlined hosted app icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_experiment_create_app_from_page
Patch Set: mass refactor: pull code into FaviconDownloader class Created 7 years 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
(Empty)
1 // Copyright 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.
4
5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_DOWNLOADER_H_
6 #define CHROME_BROWSER_FAVICON_FAVICON_DOWNLOADER_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
pkotwicz 2013/12/02 01:00:57 You do not need to include scoped_ptr.h
calamity 2013/12/03 05:52:15 Done.
13 #include "base/memory/weak_ptr.h"
14 #include "content/public/browser/web_contents_observer.h"
15
16 class SkBitmap;
17
18 namespace content {
19 struct FaviconURL;
20 }
21
22 namespace gfx {
23 class Size;
24 }
25
26 // Class to help download the full-size favicons for a tab.
pkotwicz 2013/12/02 01:00:57 Can you update the class description? The goal of
calamity 2013/12/03 05:52:15 Done.
27 class FaviconDownloader : public content::WebContentsObserver {
28 public:
29 typedef std::map<GURL, std::vector<SkBitmap> > FaviconMap;
30 typedef base::Callback<void(
31 bool, /* success */
32 /* A map of icon urls to the bitmaps provided by that url. */
33 const FaviconMap&)>
34 FaviconDownloaderCallback;
35
36 FaviconDownloader(content::WebContents* web_contents,
37 FaviconDownloaderCallback callback);
pkotwicz 2013/12/02 01:00:57 Can the extra favicon URLs be passed into the cons
calamity 2013/12/03 05:52:15 Done.
38 virtual ~FaviconDownloader();
39
40 void AddExtraFaviconUrl(const GURL& url);
41
42 void Start();
43
44 private:
45 friend class TestFaviconDownloader;
46
47 // Initiates a download of the image at |url| and returns the download id.
48 // This is overridden in testing.
49 virtual int DownloadImage(const GURL& url);
50
51 // Populates |favicon_url_candidates_| if possible.
52 // This is overridden in testing.
pkotwicz 2013/12/02 01:00:57 How about: "Queries FaviconTabHelper for the page'
calamity 2013/12/03 05:52:15 Done.
53 virtual void PopulateFaviconURLsFromWebContents();
54
55 // Fetches icons for |favicon_url_candidates_| and |extra_favicon_urls_|.
56 // |callback| is run when all downloads complete.
57 void FetchIcons();
58
59 // Icon download callback.
60 void DidDownloadFavicon(int id,
61 int http_status_code,
62 const GURL& image_url,
63 const std::vector<SkBitmap>& bitmaps,
64 const std::vector<gfx::Size>& original_bitmap_sizes);
65
66 // content::WebContentsObserver overrides:
67 virtual void DidNavigateMainFrame(
68 const content::LoadCommittedDetails& details,
69 const content::FrameNavigateParams& params) OVERRIDE;
70 virtual void DidUpdateFaviconURL(
71 int32 page_id,
72 const std::vector<content::FaviconURL>& candidates) OVERRIDE;
73
74 // FaviconURLs for the current web contents.
75 // This is populated when PopulateFaviconURLsFromWebContents() is called if
76 // available. Otherwise it is populated when
77 // WebContentsObserver::DidUpdateFaviconURL() is called.
78 const std::vector<content::FaviconURL>* favicon_url_candidates_;
79
80 // URLs that aren't given by WebContentsObserver::DidUpdateFaviconURL() that
81 // should be used for this favicon.
82 std::vector<GURL> extra_favicon_urls_;
83
84 // The current page's icons. Populated by FetchIcons().
85 FaviconMap favicon_map_;
86
87 // Request ids of in-progress requests.
88 std::set<int> in_progress_requests_;
89
90 // Callback to run on favicon download completion.
91 FaviconDownloaderCallback callback_;
92
93 base::WeakPtrFactory<FaviconDownloader> weak_ptr_factory_;
94
95 DISALLOW_COPY_AND_ASSIGN(FaviconDownloader);
96 };
97
98 #endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698