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

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

Issue 228783002: Moves knowledge of Profile out of FaviconHandler, into FaviconTabHelper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FAVICON_3
Patch Set: Created 6 years, 8 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 (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/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/favicon/favicon_handler.h" 8 #include "chrome/browser/favicon/favicon_handler.h"
9 #include "chrome/browser/favicon/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
10 #include "chrome/browser/favicon/favicon_util.h" 10 #include "chrome/browser/favicon/favicon_util.h"
(...skipping 21 matching lines...) Expand all
32 using content::NavigationController; 32 using content::NavigationController;
33 using content::NavigationEntry; 33 using content::NavigationEntry;
34 using content::WebContents; 34 using content::WebContents;
35 35
36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper); 36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(FaviconTabHelper);
37 37
38 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) 38 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents)
39 : content::WebContentsObserver(web_contents), 39 : content::WebContentsObserver(web_contents),
40 driver_(web_contents), 40 driver_(web_contents),
41 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { 41 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) {
42 favicon_handler_.reset( 42 favicon_handler_.reset(new FaviconHandler(
43 new FaviconHandler(profile_, &driver_, this, FaviconHandler::FAVICON)); 43 profile_, this, &driver_, this, FaviconHandler::FAVICON));
44 if (chrome::kEnableTouchIcon) 44 if (chrome::kEnableTouchIcon)
45 touch_icon_handler_.reset( 45 touch_icon_handler_.reset(new FaviconHandler(
46 new FaviconHandler(profile_, &driver_, this, FaviconHandler::TOUCH)); 46 profile_, this, &driver_, this, FaviconHandler::TOUCH));
47 } 47 }
48 48
49 FaviconTabHelper::~FaviconTabHelper() { 49 FaviconTabHelper::~FaviconTabHelper() {
50 } 50 }
51 51
52 void FaviconTabHelper::FetchFavicon(const GURL& url) { 52 void FaviconTabHelper::FetchFavicon(const GURL& url) {
53 favicon_handler_->FetchFavicon(url); 53 favicon_handler_->FetchFavicon(url);
54 if (touch_icon_handler_.get()) 54 if (touch_icon_handler_.get())
55 touch_icon_handler_->FetchFavicon(url); 55 touch_icon_handler_->FetchFavicon(url);
56 } 56 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int32 page_id, 181 int32 page_id,
182 const std::vector<content::FaviconURL>& candidates) { 182 const std::vector<content::FaviconURL>& candidates) {
183 DCHECK(!candidates.empty()); 183 DCHECK(!candidates.empty());
184 favicon_urls_ = candidates; 184 favicon_urls_ = candidates;
185 185
186 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); 186 favicon_handler_->OnUpdateFaviconURL(page_id, candidates);
187 if (touch_icon_handler_.get()) 187 if (touch_icon_handler_.get())
188 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); 188 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates);
189 } 189 }
190 190
191 FaviconService* FaviconTabHelper::GetFaviconService() {
192 return FaviconServiceFactory::GetForProfile(profile_,
193 Profile::EXPLICIT_ACCESS);
194 }
195
191 void FaviconTabHelper::DidDownloadFavicon( 196 void FaviconTabHelper::DidDownloadFavicon(
192 int id, 197 int id,
193 int http_status_code, 198 int http_status_code,
194 const GURL& image_url, 199 const GURL& image_url,
195 const std::vector<SkBitmap>& bitmaps, 200 const std::vector<SkBitmap>& bitmaps,
196 const std::vector<gfx::Size>& original_bitmap_sizes) { 201 const std::vector<gfx::Size>& original_bitmap_sizes) {
197 202
198 if (bitmaps.empty() && http_status_code == 404) { 203 if (bitmaps.empty() && http_status_code == 404) {
199 DVLOG(1) << "Failed to Download Favicon:" << image_url; 204 DVLOG(1) << "Failed to Download Favicon:" << image_url;
200 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 205 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
201 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 206 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
202 if (favicon_service) 207 if (favicon_service)
203 favicon_service->UnableToDownloadFavicon(image_url); 208 favicon_service->UnableToDownloadFavicon(image_url);
204 } 209 }
205 210
206 favicon_handler_->OnDidDownloadFavicon( 211 favicon_handler_->OnDidDownloadFavicon(
207 id, image_url, bitmaps, original_bitmap_sizes); 212 id, image_url, bitmaps, original_bitmap_sizes);
208 if (touch_icon_handler_.get()) { 213 if (touch_icon_handler_.get()) {
209 touch_icon_handler_->OnDidDownloadFavicon( 214 touch_icon_handler_->OnDidDownloadFavicon(
210 id, image_url, bitmaps, original_bitmap_sizes); 215 id, image_url, bitmaps, original_bitmap_sizes);
211 } 216 }
212 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698