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

Side by Side Diff: chrome/browser/favicon/favicon_download_helper.cc

Issue 11421051: Remove FaviconUtil::DownloadFavicon (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/favicon/favicon_download_helper.h ('k') | chrome/browser/favicon/favicon_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/favicon/favicon_download_helper.h" 5 #include "chrome/browser/favicon/favicon_download_helper.h"
6 6
7 #include "chrome/browser/favicon/favicon_download_helper_delegate.h" 7 #include "chrome/browser/favicon/favicon_download_helper_delegate.h"
8 #include "chrome/browser/favicon/favicon_util.h"
9 #include "chrome/common/icon_messages.h" 8 #include "chrome/common/icon_messages.h"
10 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_contents_delegate.h" 11 #include "content/public/browser/web_contents_delegate.h"
13 12
14 using content::WebContents; 13 using content::WebContents;
15 14
15 namespace {
16 static int StartDownload(content::RenderViewHost* rvh,
17 const GURL& url,
18 int image_size) {
19 static int id = 0;
20 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), ++id, url,
21 image_size));
22 return id;
23 }
24 } // namespace.
25
16 FaviconDownloadHelper::FaviconDownloadHelper( 26 FaviconDownloadHelper::FaviconDownloadHelper(
17 WebContents* web_contents, 27 WebContents* web_contents,
18 FaviconDownloadHelperDelegate* delegate) 28 FaviconDownloadHelperDelegate* delegate)
19 : content::WebContentsObserver(web_contents), 29 : content::WebContentsObserver(web_contents),
20 delegate_(delegate) { 30 delegate_(delegate) {
21 DCHECK(delegate_); 31 DCHECK(delegate_);
22 } 32 }
23 33
24 FaviconDownloadHelper::~FaviconDownloadHelper() { 34 FaviconDownloadHelper::~FaviconDownloadHelper() {
25 } 35 }
26 36
27 int FaviconDownloadHelper::DownloadFavicon(const GURL& url, int image_size) { 37 int FaviconDownloadHelper::DownloadFavicon(const GURL& url, int image_size) {
28 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 38 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
29 int id = FaviconUtil::DownloadFavicon(host, url, image_size); 39 int id = StartDownload(host, url, image_size);
30 DownloadIdList::iterator i = 40 DownloadIdList::iterator i =
31 std::find(download_ids_.begin(), download_ids_.end(), id); 41 std::find(download_ids_.begin(), download_ids_.end(), id);
32 DCHECK(i == download_ids_.end()); 42 DCHECK(i == download_ids_.end());
33 download_ids_.insert(id); 43 download_ids_.insert(id);
34 return id; 44 return id;
35 } 45 }
36 46
37 bool FaviconDownloadHelper::OnMessageReceived(const IPC::Message& message) { 47 bool FaviconDownloadHelper::OnMessageReceived(const IPC::Message& message) {
38 bool message_handled = false; // Allow other handlers to receive these. 48 bool message_handled = false; // Allow other handlers to receive these.
39 IPC_BEGIN_MESSAGE_MAP(FaviconDownloadHelper, message) 49 IPC_BEGIN_MESSAGE_MAP(FaviconDownloadHelper, message)
(...skipping 20 matching lines...) Expand all
60 delegate_->OnDidDownloadFavicon( 70 delegate_->OnDidDownloadFavicon(
61 id, image_url, errored, requested_size, bitmaps); 71 id, image_url, errored, requested_size, bitmaps);
62 download_ids_.erase(i); 72 download_ids_.erase(i);
63 } 73 }
64 74
65 void FaviconDownloadHelper::OnUpdateFaviconURL( 75 void FaviconDownloadHelper::OnUpdateFaviconURL(
66 int32 page_id, 76 int32 page_id,
67 const std::vector<FaviconURL>& candidates) { 77 const std::vector<FaviconURL>& candidates) {
68 delegate_->OnUpdateFaviconURL(page_id, candidates); 78 delegate_->OnUpdateFaviconURL(page_id, candidates);
69 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_download_helper.h ('k') | chrome/browser/favicon/favicon_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698