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

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

Issue 11411180: move favicon download code from chrome/ into content/ (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
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
13 using content::FaviconURL;
14 using content::WebContents; 14 using content::WebContents;
15 15
16 namespace {
17 static int current_download_id = 0;
18 } // namespace.
19
16 FaviconDownloadHelper::FaviconDownloadHelper( 20 FaviconDownloadHelper::FaviconDownloadHelper(
17 WebContents* web_contents, 21 WebContents* web_contents,
18 FaviconDownloadHelperDelegate* delegate) 22 FaviconDownloadHelperDelegate* delegate)
19 : content::WebContentsObserver(web_contents), 23 : content::WebContentsObserver(web_contents),
20 delegate_(delegate) { 24 delegate_(delegate) {
21 DCHECK(delegate_); 25 DCHECK(delegate_);
22 } 26 }
23 27
24 FaviconDownloadHelper::~FaviconDownloadHelper() { 28 FaviconDownloadHelper::~FaviconDownloadHelper() {
25 } 29 }
26 30
27 int FaviconDownloadHelper::DownloadFavicon(const GURL& url, int image_size) { 31 int FaviconDownloadHelper::DownloadFavicon(const GURL& url, int image_size) {
28 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 32 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
29 int id = FaviconUtil::DownloadFavicon(host, url, image_size); 33 int id = ++current_download_id;
34 host->Send(new IconMsg_DownloadFavicon(host->GetRoutingID(), id, url,
jam 2012/11/27 01:16:31 is this file wrong? i.e. icon_messages.h is now in
Cait (Slow) 2012/11/28 00:11:45 Done.
35 image_size));
30 DownloadIdList::iterator i = 36 DownloadIdList::iterator i =
31 std::find(download_ids_.begin(), download_ids_.end(), id); 37 std::find(download_ids_.begin(), download_ids_.end(), id);
32 DCHECK(i == download_ids_.end()); 38 DCHECK(i == download_ids_.end());
33 download_ids_.insert(id); 39 download_ids_.insert(id);
34 return id; 40 return id;
35 } 41 }
36 42
37 bool FaviconDownloadHelper::OnMessageReceived(const IPC::Message& message) { 43 bool FaviconDownloadHelper::OnMessageReceived(const IPC::Message& message) {
38 bool message_handled = false; // Allow other handlers to receive these. 44 bool message_handled = false; // Allow other handlers to receive these.
39 IPC_BEGIN_MESSAGE_MAP(FaviconDownloadHelper, message) 45 IPC_BEGIN_MESSAGE_MAP(FaviconDownloadHelper, message)
(...skipping 20 matching lines...) Expand all
60 delegate_->OnDidDownloadFavicon( 66 delegate_->OnDidDownloadFavicon(
61 id, image_url, errored, requested_size, bitmaps); 67 id, image_url, errored, requested_size, bitmaps);
62 download_ids_.erase(i); 68 download_ids_.erase(i);
63 } 69 }
64 70
65 void FaviconDownloadHelper::OnUpdateFaviconURL( 71 void FaviconDownloadHelper::OnUpdateFaviconURL(
66 int32 page_id, 72 int32 page_id,
67 const std::vector<FaviconURL>& candidates) { 73 const std::vector<FaviconURL>& candidates) {
68 delegate_->OnUpdateFaviconURL(page_id, candidates); 74 delegate_->OnUpdateFaviconURL(page_id, candidates);
69 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698