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

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

Issue 684983003: Add Observer in FaviconTabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/chrome_favicon_client.h" 8 #include "chrome/browser/favicon/chrome_favicon_client.h"
9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
10 #include "chrome/browser/favicon/favicon_handler.h" 10 #include "chrome/browser/favicon/favicon_handler.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return; 129 return;
130 const FaviconStatus& favicon(entry->GetFavicon()); 130 const FaviconStatus& favicon(entry->GetFavicon());
131 if (!favicon.valid || favicon.url.is_empty() || 131 if (!favicon.valid || favicon.url.is_empty() ||
132 favicon.image.IsEmpty()) { 132 favicon.image.IsEmpty()) {
133 return; 133 return;
134 } 134 }
135 service->SetFavicons( 135 service->SetFavicons(
136 entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image); 136 entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image);
137 } 137 }
138 138
139 void FaviconTabHelper::AddObserver(Observer* observer) {
140 observer_list_.AddObserver(observer);
141 }
142
143 void FaviconTabHelper::RemoveObserver(Observer* observer) {
144 observer_list_.RemoveObserver(observer);
145 }
146
139 int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) { 147 int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) {
140 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 148 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
141 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 149 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
142 if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) { 150 if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) {
143 DVLOG(1) << "Skip Failed FavIcon: " << url; 151 DVLOG(1) << "Skip Failed FavIcon: " << url;
144 return 0; 152 return 0;
145 } 153 }
146 154
147 return web_contents()->DownloadImage( 155 return web_contents()->DownloadImage(
148 url, 156 url,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 196 }
189 197
190 void FaviconTabHelper::SetActiveFaviconURL(GURL url) { 198 void FaviconTabHelper::SetActiveFaviconURL(GURL url) {
191 GetFaviconStatus().url = url; 199 GetFaviconStatus().url = url;
192 } 200 }
193 201
194 void FaviconTabHelper::SetActiveFaviconValidity(bool validity) { 202 void FaviconTabHelper::SetActiveFaviconValidity(bool validity) {
195 GetFaviconStatus().valid = validity; 203 GetFaviconStatus().valid = validity;
196 } 204 }
197 205
206 void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image) {
207 FOR_EACH_OBSERVER(Observer, observer_list_, OnFaviconAvailable(image));
208 }
209
198 content::FaviconStatus& FaviconTabHelper::GetFaviconStatus() { 210 content::FaviconStatus& FaviconTabHelper::GetFaviconStatus() {
199 DCHECK(web_contents()->GetController().GetActiveEntry()); 211 DCHECK(web_contents()->GetController().GetActiveEntry());
200 return web_contents()->GetController().GetActiveEntry()->GetFavicon(); 212 return web_contents()->GetController().GetActiveEntry()->GetFavicon();
201 } 213 }
202 214
203 void FaviconTabHelper::DidStartNavigationToPendingEntry( 215 void FaviconTabHelper::DidStartNavigationToPendingEntry(
204 const GURL& url, 216 const GURL& url,
205 NavigationController::ReloadType reload_type) { 217 NavigationController::ReloadType reload_type) {
206 if (reload_type != NavigationController::NO_RELOAD && 218 if (reload_type != NavigationController::NO_RELOAD &&
207 !profile_->IsOffTheRecord()) { 219 !profile_->IsOffTheRecord()) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 favicon_service->UnableToDownloadFavicon(image_url); 286 favicon_service->UnableToDownloadFavicon(image_url);
275 } 287 }
276 288
277 favicon_handler_->OnDidDownloadFavicon( 289 favicon_handler_->OnDidDownloadFavicon(
278 id, image_url, bitmaps, original_bitmap_sizes); 290 id, image_url, bitmaps, original_bitmap_sizes);
279 if (touch_icon_handler_.get()) { 291 if (touch_icon_handler_.get()) {
280 touch_icon_handler_->OnDidDownloadFavicon( 292 touch_icon_handler_->OnDidDownloadFavicon(
281 id, image_url, bitmaps, original_bitmap_sizes); 293 id, image_url, bitmaps, original_bitmap_sizes);
282 } 294 }
283 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698