| 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_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/favicon/favicon_handler.h" | 7 #include "chrome/browser/favicon/favicon_handler.h" |
| 8 #include "chrome/browser/favicon/favicon_service_factory.h" | 8 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 9 #include "chrome/browser/favicon/favicon_util.h" | 9 #include "chrome/browser/favicon/favicon_util.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "content/public/browser/favicon_status.h" | 16 #include "content/public/browser/favicon_status.h" |
| 17 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/browser/web_contents_delegate.h" | 24 #include "content/public/browser/web_contents_delegate.h" |
| 25 #include "content/public/browser/web_ui.h" | |
| 26 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
| 27 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 28 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
| 29 #include "ui/gfx/image/image_skia_rep.h" | 28 #include "ui/gfx/image/image_skia_rep.h" |
| 30 | 29 |
| 31 using content::FaviconStatus; | 30 using content::FaviconStatus; |
| 32 using content::NavigationController; | 31 using content::NavigationController; |
| 33 using content::NavigationEntry; | 32 using content::NavigationEntry; |
| 34 using content::WebContents; | 33 using content::WebContents; |
| 35 | 34 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 bool FaviconTabHelper::ShouldDisplayFavicon() { | 87 bool FaviconTabHelper::ShouldDisplayFavicon() { |
| 89 // Always display a throbber during pending loads. | 88 // Always display a throbber during pending loads. |
| 90 const NavigationController& controller = web_contents()->GetController(); | 89 const NavigationController& controller = web_contents()->GetController(); |
| 91 if (controller.GetLastCommittedEntry() && controller.GetPendingEntry()) | 90 if (controller.GetLastCommittedEntry() && controller.GetPendingEntry()) |
| 92 return true; | 91 return true; |
| 93 | 92 |
| 94 // No favicon on Instant New Tab Pages. | 93 // No favicon on Instant New Tab Pages. |
| 95 if (chrome::IsInstantNTP(web_contents())) | 94 if (chrome::IsInstantNTP(web_contents())) |
| 96 return false; | 95 return false; |
| 97 | 96 |
| 98 content::WebUI* web_ui = web_contents()->GetWebUIForCurrentState(); | |
| 99 if (web_ui) | |
| 100 return !web_ui->ShouldHideFavicon(); | |
| 101 return true; | 97 return true; |
| 102 } | 98 } |
| 103 | 99 |
| 104 void FaviconTabHelper::SaveFavicon() { | 100 void FaviconTabHelper::SaveFavicon() { |
| 105 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); | 101 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); |
| 106 if (!entry || entry->GetURL().is_empty()) | 102 if (!entry || entry->GetURL().is_empty()) |
| 107 return; | 103 return; |
| 108 | 104 |
| 109 // Make sure the page is in history, otherwise adding the favicon does | 105 // Make sure the page is in history, otherwise adding the favicon does |
| 110 // nothing. | 106 // nothing. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const GURL& image_url, | 175 const GURL& image_url, |
| 180 int requested_size, | 176 int requested_size, |
| 181 const std::vector<SkBitmap>& bitmaps) { | 177 const std::vector<SkBitmap>& bitmaps) { |
| 182 favicon_handler_->OnDidDownloadFavicon( | 178 favicon_handler_->OnDidDownloadFavicon( |
| 183 id, image_url, requested_size, bitmaps); | 179 id, image_url, requested_size, bitmaps); |
| 184 if (touch_icon_handler_.get()) { | 180 if (touch_icon_handler_.get()) { |
| 185 touch_icon_handler_->OnDidDownloadFavicon( | 181 touch_icon_handler_->OnDidDownloadFavicon( |
| 186 id, image_url, requested_size, bitmaps); | 182 id, image_url, requested_size, bitmaps); |
| 187 } | 183 } |
| 188 } | 184 } |
| OLD | NEW |