Chromium Code Reviews| Index: content/browser/web_contents/web_contents_impl.cc |
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
| index 9bf52afc22bfe5f8f14028a3661644c8d8c015fb..6775ee3f247fbaacf846f9a748d0ba4eb3141d5c 100644 |
| --- a/content/browser/web_contents/web_contents_impl.cc |
| +++ b/content/browser/web_contents/web_contents_impl.cc |
| @@ -39,6 +39,7 @@ |
| #include "content/browser/web_contents/web_contents_view_guest.h" |
| #include "content/browser/webui/web_ui_impl.h" |
| #include "content/common/browser_plugin_messages.h" |
| +#include "content/common/icon_messages.h" |
| #include "content/common/intents_messages.h" |
| #include "content/common/ssl_status_serialization.h" |
| #include "content/common/view_messages.h" |
| @@ -68,6 +69,7 @@ |
| #include "content/public/common/content_constants.h" |
| #include "content/public/common/content_restriction.h" |
| #include "content/public/common/content_switches.h" |
| +#include "content/public/common/favicon_url.h" |
|
jam
2012/12/03 21:59:39
nit: redundant since by definition icon_messages.h
Cait (Slow)
2012/12/04 20:57:35
Done.
|
| #include "content/public/common/url_constants.h" |
| #include "net/base/mime_util.h" |
| #include "net/base/net_util.h" |
| @@ -148,6 +150,17 @@ const int kSyncWaitDelay = 40; |
| const char kDotGoogleDotCom[] = ".google.com"; |
| +static int StartDownload(content::RenderViewHost* rvh, |
| + const GURL& url, |
| + int image_size) { |
| + static int g_next_favicon_download_id = 0; |
| + rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), |
| + ++g_next_favicon_download_id, |
| + url, |
| + image_size)); |
| + return g_next_favicon_download_id; |
| +} |
| + |
| #if defined(OS_WIN) |
| BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
| @@ -746,6 +759,8 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
| OnRequestPpapiBrokerPermission) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
| OnBrowserPluginCreateGuest) |
| + IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) |
| + IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP_EX() |
| message_source_ = NULL; |
| @@ -1950,6 +1965,14 @@ void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
| color_chooser_ = NULL; |
| } |
| +int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size, |
| + const FaviconDownloadCallback& callback) { |
| + RenderViewHost* host = GetRenderViewHost(); |
| + int id = StartDownload(host, url, image_size); |
| + favicon_download_map_[id] = callback; |
| + return id; |
| +} |
| + |
| bool WebContentsImpl::FocusLocationBarByDefault() { |
| WebUI* web_ui = GetWebUIForCurrentState(); |
| if (web_ui) |
| @@ -2365,6 +2388,31 @@ void WebContentsImpl::OnBrowserPluginCreateGuest( |
| params); |
| } |
| +void WebContentsImpl::OnDidDownloadFavicon( |
| + int id, |
| + const GURL& image_url, |
| + bool errored, |
| + int requested_size, |
| + const std::vector<SkBitmap>& bitmaps) { |
| + FaviconDownloadMap::iterator iter = favicon_download_map_.find(id); |
| + if (iter == favicon_download_map_.end()) { |
| + // Currently WebContents notifies us of ANY downloads so that it is |
| + // possible to get here. |
| + return; |
| + } |
| + if (!iter->second.is_null()) { |
| + iter->second.Run(id, image_url, errored, requested_size, bitmaps); |
| + } |
| + favicon_download_map_.erase(id); |
| +} |
| + |
| +void WebContentsImpl::OnUpdateFaviconURL( |
| + int32 page_id, |
| + const std::vector<FaviconURL>& candidates) { |
| + FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| + DidUpdateFaviconURL(page_id, candidates)); |
| +} |
| + |
| void WebContentsImpl::DidBlock3DAPIs(const GURL& url, |
| ThreeDAPIType requester) { |
| FOR_EACH_OBSERVER(WebContentsObserver, observers_, |