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

Side by Side Diff: components/favicon/core/favicon_handler.cc

Issue 2694333002: Fix leaking page visits in incognito mode via bookmarked favicons (Closed)
Patch Set: Rebased Created 3 years, 3 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 "components/favicon/core/favicon_handler.h" 5 #include "components/favicon/core/favicon_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return best_favicon_.candidate.score == 1; 282 return best_favicon_.candidate.score == 1;
283 } 283 }
284 } 284 }
285 285
286 void FaviconHandler::SetFavicon(const GURL& icon_url, 286 void FaviconHandler::SetFavicon(const GURL& icon_url,
287 const gfx::Image& image, 287 const gfx::Image& image,
288 favicon_base::IconType icon_type) { 288 favicon_base::IconType icon_type) {
289 // Associate the icon to all URLs in |page_urls_|, which contains page URLs 289 // Associate the icon to all URLs in |page_urls_|, which contains page URLs
290 // within the same site/document that have been considered to reliably share 290 // within the same site/document that have been considered to reliably share
291 // the same icon candidates. 291 // the same icon candidates.
292 for (const GURL& page_url : page_urls_) { 292 if (!delegate_->IsOffTheRecord()) {
293 if (ShouldSaveFavicon(page_url)) 293 for (const GURL& page_url : page_urls_)
294 service_->SetFavicons(page_url, icon_url, icon_type, image); 294 service_->SetFavicons(page_url, icon_url, icon_type, image);
295 } 295 }
296 296
297 NotifyFaviconUpdated(icon_url, icon_type, image); 297 NotifyFaviconUpdated(icon_url, icon_type, image);
298 } 298 }
299 299
300 void FaviconHandler::NotifyFaviconUpdated( 300 void FaviconHandler::NotifyFaviconUpdated(
301 const std::vector<favicon_base::FaviconRawBitmapResult>& 301 const std::vector<favicon_base::FaviconRawBitmapResult>&
302 favicon_bitmap_results) { 302 favicon_bitmap_results) {
303 DCHECK(!favicon_bitmap_results.empty()); 303 DCHECK(!favicon_bitmap_results.empty());
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 return icon_urls; 574 return icon_urls;
575 } 575 }
576 576
577 bool FaviconHandler::HasPendingTasksForTest() { 577 bool FaviconHandler::HasPendingTasksForTest() {
578 return !image_download_request_.IsCancelled() || 578 return !image_download_request_.IsCancelled() ||
579 !manifest_download_request_.IsCancelled() || 579 !manifest_download_request_.IsCancelled() ||
580 cancelable_task_tracker_for_page_url_.HasTrackedTasks() || 580 cancelable_task_tracker_for_page_url_.HasTrackedTasks() ||
581 cancelable_task_tracker_for_candidates_.HasTrackedTasks(); 581 cancelable_task_tracker_for_candidates_.HasTrackedTasks();
582 } 582 }
583 583
584 bool FaviconHandler::ShouldSaveFavicon(const GURL& page_url) const {
585 if (!delegate_->IsOffTheRecord())
586 return true;
587
588 // Always save favicon if the page is bookmarked.
589 return delegate_->IsBookmarked(page_url);
590 }
591
592 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( 584 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
593 const std::vector<favicon_base::FaviconRawBitmapResult>& 585 const std::vector<favicon_base::FaviconRawBitmapResult>&
594 favicon_bitmap_results) { 586 favicon_bitmap_results) {
595 got_favicon_from_history_ = true; 587 got_favicon_from_history_ = true;
596 bool has_valid_result = HasValidResult(favicon_bitmap_results); 588 bool has_valid_result = HasValidResult(favicon_bitmap_results);
597 initial_history_result_expired_or_incomplete_ = 589 initial_history_result_expired_or_incomplete_ =
598 !has_valid_result || 590 !has_valid_result ||
599 HasExpiredOrIncompleteResult(preferred_icon_size(), 591 HasExpiredOrIncompleteResult(preferred_icon_size(),
600 favicon_bitmap_results); 592 favicon_bitmap_results);
601 redownload_icons_ = initial_history_result_expired_or_incomplete_ && 593 redownload_icons_ = initial_history_result_expired_or_incomplete_ &&
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 // A max bitmap size is specified to avoid receiving huge bitmaps in 693 // A max bitmap size is specified to avoid receiving huge bitmaps in
702 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() 694 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload()
703 // for more details about the max bitmap size. 695 // for more details about the max bitmap size.
704 const int download_id = delegate_->DownloadImage( 696 const int download_id = delegate_->DownloadImage(
705 image_url, GetMaximalIconSize(handler_type_, !manifest_url_.is_empty()), 697 image_url, GetMaximalIconSize(handler_type_, !manifest_url_.is_empty()),
706 image_download_request_.callback()); 698 image_download_request_.callback());
707 DCHECK_NE(download_id, 0); 699 DCHECK_NE(download_id, 0);
708 } 700 }
709 701
710 } // namespace favicon 702 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_handler.h ('k') | components/favicon/core/favicon_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698