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 73260d3a39bd7262df2f44ca239cc20ca81008a2..540a33a73fca9002bdea32fd77fc8e6b52e9fe1f 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -38,6 +38,7 @@ |
#include "content/browser/web_contents/navigation_entry_impl.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" |
@@ -49,6 +50,7 @@ |
#include "content/public/browser/devtools_agent_host_registry.h" |
#include "content/public/browser/download_manager.h" |
#include "content/public/browser/download_url_parameters.h" |
+#include "content/public/browser/favicon_download_delegate.h" |
#include "content/public/browser/invalidate_type.h" |
#include "content/public/browser/javascript_dialogs.h" |
#include "content/public/browser/load_from_memory_cache_details.h" |
@@ -67,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" |
#include "content/public/common/url_constants.h" |
#include "net/base/mime_util.h" |
#include "net/base/net_util.h" |
@@ -147,6 +150,8 @@ const int kSyncWaitDelay = 40; |
const char kDotGoogleDotCom[] = ".google.com"; |
+static int current_favicon_download_id = 0; |
jam
2012/11/27 01:16:31
nit: prefix with "g_" to make it clear that this i
Cait (Slow)
2012/11/28 00:11:45
Done.
|
+ |
#if defined(OS_WIN) |
BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
@@ -317,7 +322,8 @@ WebContentsImpl::WebContentsImpl( |
maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
temporary_zoom_settings_(false), |
content_restrictions_(0), |
- color_chooser_(NULL) { |
+ color_chooser_(NULL), |
+ favicon_download_delegate_(NULL) { |
} |
WebContentsImpl::~WebContentsImpl() { |
@@ -743,6 +749,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; |
@@ -1938,6 +1946,23 @@ void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
color_chooser_ = NULL; |
} |
+int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size) { |
+ RenderViewHost* host = GetRenderViewHost(); |
+ int id = ++current_favicon_download_id; |
+ host->Send(new IconMsg_DownloadFavicon(host->GetRoutingID(), id, url, |
+ image_size)); |
+ DownloadIdList::iterator i = |
+ std::find(favicon_download_ids_.begin(), favicon_download_ids_.end(), id); |
+ DCHECK(i == favicon_download_ids_.end()); |
jam
2012/11/27 01:16:31
this check seems unnecessary given that you have a
Cait (Slow)
2012/11/28 00:11:45
Done.
|
+ favicon_download_ids_.insert(id); |
+ return id; |
+} |
+ |
+void WebContentsImpl::RegisterFaviconDelegate( |
+ FaviconDownloadDelegate* delegate) { |
+ favicon_download_delegate_ = delegate; |
+} |
+ |
bool WebContentsImpl::FocusLocationBarByDefault() { |
WebUI* web_ui = GetWebUIForCurrentState(); |
if (web_ui) |
@@ -2361,6 +2386,34 @@ void WebContentsImpl::OnBrowserPluginCreateGuest( |
params); |
} |
+void WebContentsImpl::OnDidDownloadFavicon( |
+ int id, |
+ const GURL& image_url, |
+ bool errored, |
+ int requested_size, |
+ const std::vector<SkBitmap>& bitmaps) { |
+ DownloadIdList::iterator i = |
+ std::find(favicon_download_ids_.begin(), favicon_download_ids_.end(), id); |
+ if (i == favicon_download_ids_.end()) { |
+ // Currently WebContents notifies us of ANY downloads so that it is |
jam
2012/11/27 01:16:31
I'm not sure I understand this comment. This is an
Cait (Slow)
2012/11/28 00:11:45
Done.
|
+ // possible to get here. |
+ return; |
+ } |
+ if (favicon_download_delegate_) { |
+ favicon_download_delegate_->DidDownloadFavicon( |
+ id, image_url, errored, requested_size, bitmaps); |
+ } |
+ favicon_download_ids_.erase(i); |
+ |
+} |
+ |
+void WebContentsImpl::OnUpdateFaviconURL( |
+ int32 page_id, |
+ const std::vector<FaviconURL>& candidates) { |
+ if (favicon_download_delegate_) |
+ favicon_download_delegate_->UpdateFaviconURL(page_id, candidates); |
+} |
+ |
void WebContentsImpl::DidBlock3DAPIs(const GURL& url, |
ThreeDAPIType requester) { |
FOR_EACH_OBSERVER(WebContentsObserver, observers_, |