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

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

Issue 11195010: Extract Favicon Download logic from FaviconTabHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | 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_tab_helper.h" 5 #include "chrome/browser/favicon/favicon_tab_helper.h"
6 6
7 #include "chrome/browser/favicon/favicon_download_helper.h"
7 #include "chrome/browser/favicon/favicon_handler.h" 8 #include "chrome/browser/favicon/favicon_handler.h"
8 #include "chrome/browser/favicon/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
9 #include "chrome/browser/favicon/favicon_util.h" 10 #include "chrome/browser/favicon/favicon_util.h"
10 #include "chrome/browser/history/history.h" 11 #include "chrome/browser/history/history.h"
11 #include "chrome/browser/history/history_service_factory.h" 12 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
14 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/icon_messages.h" 16 #include "chrome/common/icon_messages.h"
16 #include "content/public/browser/favicon_status.h" 17 #include "content/public/browser/favicon_status.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); 139 favicon_handler_->OnUpdateFaviconURL(page_id, candidates);
139 if (touch_icon_handler_.get()) 140 if (touch_icon_handler_.get())
140 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); 141 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates);
141 } 142 }
142 143
143 NavigationEntry* FaviconTabHelper::GetActiveEntry() { 144 NavigationEntry* FaviconTabHelper::GetActiveEntry() {
144 return web_contents()->GetController().GetActiveEntry(); 145 return web_contents()->GetController().GetActiveEntry();
145 } 146 }
146 147
147 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { 148 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) {
148 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 149 FaviconDownloadHelper::CreateForWebContents(web_contents());
149 int id = FaviconUtil::DownloadFavicon(host, url, image_size); 150 FaviconDownloadHelper* helper =
151 FaviconDownloadHelper::FromWebContents(web_contents());
152 int id = -1;
153
154 if (helper) {
155 helper->SetExternalDelegate(this);
156 id = helper->DownloadFavicon(url, image_size);
157 }
150 return id; 158 return id;
151 } 159 }
152 160
153 void FaviconTabHelper::NotifyFaviconUpdated() { 161 void FaviconTabHelper::NotifyFaviconUpdated() {
154 content::NotificationService::current()->Notify( 162 content::NotificationService::current()->Notify(
155 chrome::NOTIFICATION_FAVICON_UPDATED, 163 chrome::NOTIFICATION_FAVICON_UPDATED,
156 content::Source<WebContents>(web_contents()), 164 content::Source<WebContents>(web_contents()),
157 content::NotificationService::NoDetails()); 165 content::NotificationService::NoDetails());
158 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); 166 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
159 } 167 }
(...skipping 13 matching lines...) Expand all
173 void FaviconTabHelper::DidNavigateMainFrame( 181 void FaviconTabHelper::DidNavigateMainFrame(
174 const content::LoadCommittedDetails& details, 182 const content::LoadCommittedDetails& details,
175 const content::FrameNavigateParams& params) { 183 const content::FrameNavigateParams& params) {
176 // Get the favicon, either from history or request it from the net. 184 // Get the favicon, either from history or request it from the net.
177 FetchFavicon(details.entry->GetURL()); 185 FetchFavicon(details.entry->GetURL());
178 } 186 }
179 187
180 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { 188 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) {
181 bool message_handled = false; // Allow other handlers to receive these. 189 bool message_handled = false; // Allow other handlers to receive these.
182 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) 190 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message)
183 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
184 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 191 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
185 IPC_MESSAGE_UNHANDLED(message_handled = false) 192 IPC_MESSAGE_UNHANDLED(message_handled = false)
186 IPC_END_MESSAGE_MAP() 193 IPC_END_MESSAGE_MAP()
187 return message_handled; 194 return message_handled;
188 } 195 }
189 196
190 void FaviconTabHelper::OnDidDownloadFavicon( 197 void FaviconTabHelper::OnDidDownloadFavicon(
191 int id, 198 int id,
192 const GURL& image_url, 199 const GURL& image_url,
193 bool errored, 200 bool errored,
194 int requested_size, 201 int requested_size,
195 const std::vector<SkBitmap>& bitmaps) { 202 const std::vector<SkBitmap>& bitmaps) {
196 favicon_handler_->OnDidDownloadFavicon( 203 favicon_handler_->OnDidDownloadFavicon(
197 id, image_url, errored, requested_size, bitmaps); 204 id, image_url, errored, requested_size, bitmaps);
198 if (touch_icon_handler_.get()) { 205 if (touch_icon_handler_.get()) {
199 touch_icon_handler_->OnDidDownloadFavicon( 206 touch_icon_handler_->OnDidDownloadFavicon(
200 id, image_url, errored, requested_size, bitmaps); 207 id, image_url, errored, requested_size, bitmaps);
201 } 208 }
202 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698