OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/history.h" | 8 #include "chrome/browser/history/history.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/icon_messages.h" | 12 #include "chrome/common/icon_messages.h" |
13 #include "content/browser/renderer_host/render_view_host.h" | 13 #include "content/browser/renderer_host/render_view_host.h" |
14 #include "content/browser/tab_contents/navigation_controller.h" | 14 #include "content/browser/tab_contents/navigation_controller.h" |
15 #include "content/browser/tab_contents/navigation_details.h" | 15 #include "content/browser/tab_contents/navigation_details.h" |
16 #include "content/browser/tab_contents/tab_contents_delegate.h" | 16 #include "content/browser/tab_contents/tab_contents_delegate.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/browser/webui/web_ui.h" | 18 #include "content/browser/webui/web_ui.h" |
19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "ui/gfx/codec/png_codec.h" | 20 #include "ui/gfx/codec/png_codec.h" |
21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
22 | 22 |
23 FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents) | 23 FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents) |
24 : TabContentsObserver(tab_contents), | 24 : TabContentsObserver(tab_contents), |
25 profile_(Profile::FromBrowserContext(tab_contents->browser_context())) { | 25 profile_(Profile::FromBrowserContext(tab_contents->browser_context())) { |
26 favicon_handler_.reset(new FaviconHandler(profile_, this, | 26 favicon_handler_.reset(new FaviconHandler(profile_, this, |
27 FaviconHandler::FAVICON)); | 27 FaviconHandler::FAVICON)); |
28 if (chrome::kEnableTouchIcon) | 28 if (chrome::kEnableTouchIcon) |
29 touch_icon_handler_.reset(new FaviconHandler(profile_, this, | 29 touch_icon_handler_.reset(new FaviconHandler(profile_, this, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return tab_contents()->controller().GetActiveEntry(); | 131 return tab_contents()->controller().GetActiveEntry(); |
132 } | 132 } |
133 | 133 |
134 void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { | 134 void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { |
135 RenderViewHost* host = tab_contents()->render_view_host(); | 135 RenderViewHost* host = tab_contents()->render_view_host(); |
136 host->Send(new IconMsg_DownloadFavicon( | 136 host->Send(new IconMsg_DownloadFavicon( |
137 host->routing_id(), id, url, image_size)); | 137 host->routing_id(), id, url, image_size)); |
138 } | 138 } |
139 | 139 |
140 void FaviconTabHelper::NotifyFaviconUpdated() { | 140 void FaviconTabHelper::NotifyFaviconUpdated() { |
141 NotificationService::current()->Notify( | 141 content::NotificationService::current()->Notify( |
142 chrome::NOTIFICATION_FAVICON_UPDATED, | 142 chrome::NOTIFICATION_FAVICON_UPDATED, |
143 content::Source<TabContents>(tab_contents()), | 143 content::Source<TabContents>(tab_contents()), |
144 NotificationService::NoDetails()); | 144 content::NotificationService::NoDetails()); |
145 tab_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); | 145 tab_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); |
146 } | 146 } |
147 | 147 |
148 void FaviconTabHelper::NavigateToPendingEntry( | 148 void FaviconTabHelper::NavigateToPendingEntry( |
149 const GURL& url, | 149 const GURL& url, |
150 NavigationController::ReloadType reload_type) { | 150 NavigationController::ReloadType reload_type) { |
151 if (reload_type != NavigationController::NO_RELOAD && | 151 if (reload_type != NavigationController::NO_RELOAD && |
152 !profile_->IsOffTheRecord()) { | 152 !profile_->IsOffTheRecord()) { |
153 FaviconService* favicon_service = | 153 FaviconService* favicon_service = |
154 profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); | 154 profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); |
(...skipping 21 matching lines...) Expand all Loading... |
176 | 176 |
177 void FaviconTabHelper::OnDidDownloadFavicon(int id, | 177 void FaviconTabHelper::OnDidDownloadFavicon(int id, |
178 const GURL& image_url, | 178 const GURL& image_url, |
179 bool errored, | 179 bool errored, |
180 const SkBitmap& image) { | 180 const SkBitmap& image) { |
181 gfx::Image favicon(new SkBitmap(image)); | 181 gfx::Image favicon(new SkBitmap(image)); |
182 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 182 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
183 if (touch_icon_handler_.get()) | 183 if (touch_icon_handler_.get()) |
184 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 184 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
185 } | 185 } |
OLD | NEW |