OLD | NEW |
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_handler.h" | 5 #include "chrome/browser/favicon/favicon_handler.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 465 } |
466 | 466 |
467 void FaviconHandler::SetHistoryFavicons(const GURL& page_url, | 467 void FaviconHandler::SetHistoryFavicons(const GURL& page_url, |
468 const GURL& icon_url, | 468 const GURL& icon_url, |
469 chrome::IconType icon_type, | 469 chrome::IconType icon_type, |
470 const gfx::Image& image) { | 470 const gfx::Image& image) { |
471 GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image); | 471 GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image); |
472 } | 472 } |
473 | 473 |
474 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { | 474 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { |
475 if (!profile_->IsOffTheRecord()) | 475 if (!delegate_->IsOffTheRecord()) |
476 return true; | 476 return true; |
477 | 477 |
478 // Otherwise store the favicon if the page is bookmarked. | 478 // Otherwise store the favicon if the page is bookmarked. |
479 BookmarkService* bookmark_service = | 479 BookmarkService* bookmark_service = |
480 BookmarkService::FromBrowserContext(profile_); | 480 BookmarkService::FromBrowserContext(profile_); |
481 return bookmark_service && bookmark_service->IsBookmarked(url); | 481 return bookmark_service && bookmark_service->IsBookmarked(url); |
482 } | 482 } |
483 | 483 |
484 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { | 484 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { |
485 delegate_->NotifyFaviconUpdated(icon_url_changed); | 485 delegate_->NotifyFaviconUpdated(icon_url_changed); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 const GURL& page_url, | 542 const GURL& page_url, |
543 const GURL& icon_url, | 543 const GURL& icon_url, |
544 chrome::IconType icon_type) { | 544 chrome::IconType icon_type) { |
545 if (favicon_expired_or_incomplete_) { | 545 if (favicon_expired_or_incomplete_) { |
546 // We have the mapping, but the favicon is out of date. Download it now. | 546 // We have the mapping, but the favicon is out of date. Download it now. |
547 ScheduleDownload(page_url, icon_url, icon_type); | 547 ScheduleDownload(page_url, icon_url, icon_type); |
548 } else if (GetFaviconService()) { | 548 } else if (GetFaviconService()) { |
549 // We don't know the favicon, but we may have previously downloaded the | 549 // We don't know the favicon, but we may have previously downloaded the |
550 // favicon for another page that shares the same favicon. Ask for the | 550 // favicon for another page that shares the same favicon. Ask for the |
551 // favicon given the favicon URL. | 551 // favicon given the favicon URL. |
552 if (profile_->IsOffTheRecord()) { | 552 if (delegate_->IsOffTheRecord()) { |
553 GetFaviconFromFaviconService( | 553 GetFaviconFromFaviconService( |
554 icon_url, icon_type, | 554 icon_url, icon_type, |
555 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), | 555 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), |
556 &cancelable_task_tracker_); | 556 &cancelable_task_tracker_); |
557 } else { | 557 } else { |
558 // Ask the history service for the icon. This does two things: | 558 // Ask the history service for the icon. This does two things: |
559 // 1. Attempts to fetch the favicon data from the database. | 559 // 1. Attempts to fetch the favicon data from the database. |
560 // 2. If the favicon exists in the database, this updates the database to | 560 // 2. If the favicon exists in the database, this updates the database to |
561 // include the mapping between the page url and the favicon url. | 561 // include the mapping between the page url and the favicon url. |
562 // This is asynchronous. The history service will call back when done. | 562 // This is asynchronous. The history service will call back when done. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 GetMaximalIconSize(icon_type)); | 612 GetMaximalIconSize(icon_type)); |
613 if (download_id) { | 613 if (download_id) { |
614 // Download ids should be unique. | 614 // Download ids should be unique. |
615 DCHECK(download_requests_.find(download_id) == download_requests_.end()); | 615 DCHECK(download_requests_.find(download_id) == download_requests_.end()); |
616 download_requests_[download_id] = | 616 download_requests_[download_id] = |
617 DownloadRequest(url, image_url, icon_type); | 617 DownloadRequest(url, image_url, icon_type); |
618 } | 618 } |
619 | 619 |
620 return download_id; | 620 return download_id; |
621 } | 621 } |
OLD | NEW |