summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 05:32:02 +0000
committerdimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 05:32:02 +0000
commit41225fe51b815b70bdc6df2775fa3f36bd832171 (patch)
tree1dec8870af60ed80282d692a428969e6952dc853
parentf7fc18bdc754687e9063edaf6728167e63ca3e95 (diff)
downloadchromium_src-41225fe51b815b70bdc6df2775fa3f36bd832171.zip
chromium_src-41225fe51b815b70bdc6df2775fa3f36bd832171.tar.gz
chromium_src-41225fe51b815b70bdc6df2775fa3f36bd832171.tar.bz2
Split FaviconHelper in two: ImageLoadingHelper and FaviconHelper.
This is the first step of fixing http://crbug.com/196769. The problem is that there are two types of users of Content::DownloadFavicon() - the favicon consumers and regular icons and images consumers. Recently, the otherwise-generic image download+decoding implementation regressed because it was assumed to be only used for favicon loading. The proposed fix is to add a parameter to the method (enum, FAVICON/IMAGE) and rename it from DownloadFavicon to DownloadImage, to make sure the name corresponds to the impl/usage. This is rename-only part, no additional parameter yet. The FaviconHelper class was split in 2, with new ImageLoadingHelper dealing with images. BUG=196769 Review URL: https://chromiumcodereview.appspot.com/12780024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191304 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/icon_helper.cc2
-rw-r--r--chrome/browser/favicon/favicon_handler.h4
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc2
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.cc2
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc2
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc2
-rw-r--r--chrome/browser/ui/metro_pin_tab_helper_win.cc2
-rw-r--r--chrome/browser/ui/views/ash/balloon_view_ash.cc8
-rw-r--r--chrome/browser/ui/views/create_application_shortcut_view.cc2
-rw-r--r--chrome/browser/ui/web_applications/web_app_ui.cc2
-rw-r--r--content/browser/web_contents/web_contents_impl.cc38
-rw-r--r--content/browser/web_contents/web_contents_impl.h22
-rw-r--r--content/common/content_message_generator.h2
-rw-r--r--content/common/icon_messages.h46
-rw-r--r--content/common/image_messages.h33
-rw-r--r--content/common/view_messages.h12
-rw-r--r--content/content_common.gypi2
-rw-r--r--content/content_renderer.gypi4
-rw-r--r--content/public/browser/web_contents.h16
-rw-r--r--content/renderer/favicon_helper.cc220
-rw-r--r--content/renderer/favicon_helper.h106
-rw-r--r--content/renderer/image_loading_helper.cc127
-rw-r--r--content/renderer/image_loading_helper.h77
-rw-r--r--content/renderer/render_view_impl.cc73
-rw-r--r--content/renderer/render_view_impl.h11
-rw-r--r--ipc/ipc_message_start.h2
26 files changed, 382 insertions, 437 deletions
diff --git a/android_webview/browser/icon_helper.cc b/android_webview/browser/icon_helper.cc
index 39573309..13091f2 100644
--- a/android_webview/browser/icon_helper.cc
+++ b/android_webview/browser/icon_helper.cc
@@ -59,7 +59,7 @@ void IconHelper::DidUpdateFaviconURL(int32 page_id,
// TODO(acleung): only fetch the URL if favicon downloading is enabled.
// (currently that is, the app has called WebIconDatabase.open()
// but we should decouple that setting via a boolean setting)
- web_contents()->DownloadFavicon(i->icon_url,
+ web_contents()->DownloadImage(i->icon_url,
true,
0,
base::Bind(
diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h
index d734d92..23a92bb 100644
--- a/chrome/browser/favicon/favicon_handler.h
+++ b/chrome/browser/favicon/favicon_handler.h
@@ -100,9 +100,9 @@ class FaviconHandler {
// history / download service.
void ProcessCurrentUrl();
- // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon
+ // Message handler for ImageHostMsg_DidDownloadImage. Called when the image
// at |image_url| has been downloaded.
- // |bitmaps| is a list of all the frames of the icon at |image_url|.
+ // |bitmaps| is a list of all the frames of the image at |image_url|.
void OnDidDownloadFavicon(int id,
const GURL& image_url,
int requested_size,
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 5265cd2..4c53912 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -132,7 +132,7 @@ NavigationEntry* FaviconTabHelper::GetActiveEntry() {
}
int FaviconTabHelper::StartDownload(const GURL& url, int image_size) {
- return web_contents()->DownloadFavicon(
+ return web_contents()->DownloadImage(
url,
true,
image_size,
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index 5296aed..44ffbdb 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -306,7 +306,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloadWithImage(
return;
}
- contents->DownloadFavicon(
+ contents->DownloadImage(
url,
false,
size,
diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
index 19f3dff..505d061 100644
--- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
@@ -109,7 +109,7 @@ void FaviconBitmapHandler::DidUpdateFaviconURL(
if (pending_requests_.find(*iter) != pending_requests_.end())
continue; // Skip already pending downloads.
pending_requests_.insert(*iter);
- web_contents_->DownloadFavicon(*iter, true, 0,
+ web_contents_->DownloadImage(*iter, true, 0,
base::Bind(&FaviconBitmapHandler::DidDownloadFavicon,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 6f7ba9c..770e4f7 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -361,7 +361,7 @@ void ShellWindow::SetAppIconUrl(const GURL& url) {
image_loader_ptr_factory_.InvalidateWeakPtrs();
app_icon_url_ = url;
- web_contents()->DownloadFavicon(
+ web_contents()->DownloadImage(
url, true, kPreferredIconSize,
base::Bind(&ShellWindow::DidDownloadFavicon,
image_loader_ptr_factory_.GetWeakPtr()));
diff --git a/chrome/browser/ui/metro_pin_tab_helper_win.cc b/chrome/browser/ui/metro_pin_tab_helper_win.cc
index fc0e13c7..13507c3 100644
--- a/chrome/browser/ui/metro_pin_tab_helper_win.cc
+++ b/chrome/browser/ui/metro_pin_tab_helper_win.cc
@@ -400,7 +400,7 @@ void MetroPinTabHelper::TogglePinnedToStartScreen() {
iter != favicon_url_candidates_.end();
++iter) {
favicon_chooser_->AddPendingRequest(
- web_contents()->DownloadFavicon(iter->icon_url,
+ web_contents()->DownloadImage(iter->icon_url,
true,
image_size,
base::Bind(&MetroPinTabHelper::DidDownloadFavicon,
diff --git a/chrome/browser/ui/views/ash/balloon_view_ash.cc b/chrome/browser/ui/views/ash/balloon_view_ash.cc
index acebcc9..5e1f8c66 100644
--- a/chrome/browser/ui/views/ash/balloon_view_ash.cc
+++ b/chrome/browser/ui/views/ash/balloon_view_ash.cc
@@ -89,10 +89,10 @@ BalloonViewAsh::ImageDownload::ImageDownload(const Notification& notification,
return;
}
- contents->DownloadFavicon(url_,
- false,
- size_,
- base::Bind(&ImageDownload::Downloaded,AsWeakPtr()));
+ contents->DownloadImage(url_,
+ false,
+ size_,
+ base::Bind(&ImageDownload::Downloaded,AsWeakPtr()));
}
diff --git a/chrome/browser/ui/views/create_application_shortcut_view.cc b/chrome/browser/ui/views/create_application_shortcut_view.cc
index 20fed13..e95c6fd 100644
--- a/chrome/browser/ui/views/create_application_shortcut_view.cc
+++ b/chrome/browser/ui/views/create_application_shortcut_view.cc
@@ -489,7 +489,7 @@ void CreateUrlApplicationShortcutView::FetchIcon() {
if (unprocessed_icons_.empty()) // No icons to fetch.
return;
- pending_download_id_ = web_contents_->DownloadFavicon(
+ pending_download_id_ = web_contents_->DownloadImage(
unprocessed_icons_.back().url,
true,
std::max(unprocessed_icons_.back().width,
diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc
index e505065..754004c 100644
--- a/chrome/browser/ui/web_applications/web_app_ui.cc
+++ b/chrome/browser/ui/web_applications/web_app_ui.cc
@@ -170,7 +170,7 @@ void UpdateShortcutWorker::DownloadIcon() {
return;
}
- web_contents_->DownloadFavicon(
+ web_contents_->DownloadImage(
unprocessed_icons_.back().url,
true, // favicon
std::max(unprocessed_icons_.back().width,
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 01151b3..3a95638 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -42,7 +42,7 @@
#include "content/browser/webui/web_ui_impl.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
-#include "content/common/icon_messages.h"
+#include "content/common/image_messages.h"
#include "content/common/ssl_status_serialization.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_view_host_delegate_view.h"
@@ -157,13 +157,13 @@ static int StartDownload(content::RenderViewHost* rvh,
const GURL& url,
bool is_favicon,
int image_size) {
- static int g_next_favicon_download_id = 0;
- rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(),
- ++g_next_favicon_download_id,
- url,
- is_favicon,
- image_size));
- return g_next_favicon_download_id;
+ static int g_next_image_download_id = 0;
+ rvh->Send(new ImageMsg_DownloadImage(rvh->GetRoutingID(),
+ ++g_next_image_download_id,
+ url,
+ is_favicon,
+ image_size));
+ return g_next_image_download_id;
}
ViewMsg_Navigate_Type::Value GetNavigationType(
@@ -696,8 +696,8 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
OnBrowserPluginMessage(message))
IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
OnBrowserPluginMessage(message))
- IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
- IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
+ IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply,
OnFindMatchRectsReply)
@@ -1990,13 +1990,13 @@ void WebContentsImpl::DidEndColorChooser(int color_chooser_id) {
color_chooser_ = NULL;
}
-int WebContentsImpl::DownloadFavicon(const GURL& url,
- bool is_favicon,
- int image_size,
- const FaviconDownloadCallback& callback) {
+int WebContentsImpl::DownloadImage(const GURL& url,
+ bool is_favicon,
+ int image_size,
+ const ImageDownloadCallback& callback) {
RenderViewHost* host = GetRenderViewHost();
int id = StartDownload(host, url, is_favicon, image_size);
- favicon_download_map_[id] = callback;
+ image_download_map_[id] = callback;
return id;
}
@@ -2408,13 +2408,13 @@ void WebContentsImpl::OnBrowserPluginMessage(const IPC::Message& message) {
browser_plugin_embedder_->OnMessageReceived(message);
}
-void WebContentsImpl::OnDidDownloadFavicon(
+void WebContentsImpl::OnDidDownloadImage(
int id,
const GURL& image_url,
int requested_size,
const std::vector<SkBitmap>& bitmaps) {
- FaviconDownloadMap::iterator iter = favicon_download_map_.find(id);
- if (iter == favicon_download_map_.end()) {
+ ImageDownloadMap::iterator iter = image_download_map_.find(id);
+ if (iter == image_download_map_.end()) {
// Currently WebContents notifies us of ANY downloads so that it is
// possible to get here.
return;
@@ -2422,7 +2422,7 @@ void WebContentsImpl::OnDidDownloadFavicon(
if (!iter->second.is_null()) {
iter->second.Run(id, image_url, requested_size, bitmaps);
}
- favicon_download_map_.erase(id);
+ image_download_map_.erase(id);
}
void WebContentsImpl::OnUpdateFaviconURL(
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index c9d6443..9dbf0a2 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -265,10 +265,10 @@ class CONTENT_EXPORT WebContentsImpl
virtual void DidChooseColorInColorChooser(int color_chooser_id,
SkColor color) OVERRIDE;
virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE;
- virtual int DownloadFavicon(const GURL& url,
- bool is_favicon,
- int image_size,
- const FaviconDownloadCallback& callback) OVERRIDE;
+ virtual int DownloadImage(const GURL& url,
+ bool is_favicon,
+ int image_size,
+ const ImageDownloadCallback& callback) OVERRIDE;
// Implementation of PageNavigator.
virtual WebContents* OpenURL(const OpenURLParams& params) OVERRIDE;
@@ -565,10 +565,10 @@ class CONTENT_EXPORT WebContentsImpl
const GURL& url,
const base::FilePath& plugin_path);
void OnBrowserPluginMessage(const IPC::Message& message);
- void OnDidDownloadFavicon(int id,
- const GURL& image_url,
- int requested_size,
- const std::vector<SkBitmap>& bitmaps);
+ void OnDidDownloadImage(int id,
+ const GURL& image_url,
+ int requested_size,
+ const std::vector<SkBitmap>& bitmaps);
void OnUpdateFaviconURL(int32 page_id,
const std::vector<FaviconURL>& candidates);
void OnFrameDetached(int64 frame_id);
@@ -871,9 +871,9 @@ class CONTENT_EXPORT WebContentsImpl
// Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
int fullscreen_widget_routing_id_;
- // Maps the ids of pending favicon downloads to their callbacks
- typedef std::map<int, FaviconDownloadCallback> FaviconDownloadMap;
- FaviconDownloadMap favicon_download_map_;
+ // Maps the ids of pending image downloads to their callbacks
+ typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
+ ImageDownloadMap image_download_map_;
DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
};
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index 9b0d4d4..512a4a5 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -26,7 +26,7 @@
#include "content/common/geolocation_messages.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/hyphenator_messages.h"
-#include "content/common/icon_messages.h"
+#include "content/common/image_messages.h"
#include "content/common/indexed_db/indexed_db_messages.h"
#include "content/common/java_bridge_messages.h"
#include "content/common/media/audio_messages.h"
diff --git a/content/common/icon_messages.h b/content/common/icon_messages.h
deleted file mode 100644
index 63f9ab9..0000000
--- a/content/common/icon_messages.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Multiply-included message file, no traditional include guard.
-#include <vector>
-
-#include "content/public/common/favicon_url.h"
-#include "ipc/ipc_message.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_param_traits.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-#define IPC_MESSAGE_START IconMsgStart
-
-IPC_ENUM_TRAITS(content::FaviconURL::IconType)
-
-IPC_STRUCT_TRAITS_BEGIN(content::FaviconURL)
- IPC_STRUCT_TRAITS_MEMBER(icon_url)
- IPC_STRUCT_TRAITS_MEMBER(icon_type)
-IPC_STRUCT_TRAITS_END()
-
-// Messages sent from the browser to the renderer.
-
-// Requests the renderer to download the specified favicon image, decode it,
-// and send the image data back via IconHostMsg_DidDownloadFavicon.
-IPC_MESSAGE_ROUTED4(IconMsg_DownloadFavicon,
- int /* identifier for the request */,
- GURL /* URL of the image */,
- bool /* is favicon (turn off cookies) */,
- int /* Preferred favicon size. Passed on to
- IconHostMsg_DidDownloadFavicon, unused otherwise */)
-
-// Messages sent from the renderer to the browser.
-
-// Notification that the urls for the favicon of a site has been determined.
-IPC_MESSAGE_ROUTED2(IconHostMsg_UpdateFaviconURL,
- int32 /* page_id */,
- std::vector<content::FaviconURL> /* urls of the favicon */)
-
-IPC_MESSAGE_ROUTED4(IconHostMsg_DidDownloadFavicon,
- int /* Identifier of the request */,
- GURL /* URL of the image */,
- int /* Preferred icon size passed to
- IconMsg_DownloadFavicon */,
- std::vector<SkBitmap> /* image_data */)
diff --git a/content/common/image_messages.h b/content/common/image_messages.h
new file mode 100644
index 0000000..78d7cff
--- /dev/null
+++ b/content/common/image_messages.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included message file, no traditional include guard.
+#include <vector>
+
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+#define IPC_MESSAGE_START ImageMsgStart
+
+// Messages sent from the browser to the renderer.
+
+// Requests the renderer to download the specified image, decode it,
+// and send the image data back via ImageHostMsg_DidDownloadImage.
+IPC_MESSAGE_ROUTED4(ImageMsg_DownloadImage,
+ int /* identifier for the request */,
+ GURL /* URL of the image */,
+ bool /* is favicon (turn off cookies) */,
+ int /* Preferred image size. Passed on to
+ ImageHostMsg_DidDownloadFavicon, unused otherwise */)
+
+// Messages sent from the renderer to the browser.
+
+IPC_MESSAGE_ROUTED4(ImageHostMsg_DidDownloadImage,
+ int /* Identifier of the request */,
+ GURL /* URL of the image */,
+ int /* Preferred image size passed to
+ ImageMsg_DownloadImage */,
+ std::vector<SkBitmap> /* image_data */)
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 0e84bef..e88c1b3 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -19,6 +19,7 @@
#include "content/port/common/input_event_ack_state.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/context_menu_params.h"
+#include "content/public/common/favicon_url.h"
#include "content/public/common/file_chooser_params.h"
#include "content/public/common/frame_navigate_params.h"
#include "content/public/common/javascript_message_type.h"
@@ -74,6 +75,7 @@ IPC_ENUM_TRAITS(WebKit::WebPopupType)
IPC_ENUM_TRAITS(WebKit::WebTextDirection)
IPC_ENUM_TRAITS(WebMenuItem::Type)
IPC_ENUM_TRAITS(WindowContainerType)
+IPC_ENUM_TRAITS(content::FaviconURL::IconType)
IPC_ENUM_TRAITS(content::FileChooserParams::Mode)
IPC_ENUM_TRAITS(content::InputEventAckState)
IPC_ENUM_TRAITS(content::JavaScriptMessageType)
@@ -198,6 +200,11 @@ IPC_STRUCT_TRAITS_BEGIN(content::EditCommand)
IPC_STRUCT_TRAITS_MEMBER(value)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(content::FaviconURL)
+ IPC_STRUCT_TRAITS_MEMBER(icon_url)
+ IPC_STRUCT_TRAITS_MEMBER(icon_type)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(content::FileChooserParams)
IPC_STRUCT_TRAITS_MEMBER(mode)
IPC_STRUCT_TRAITS_MEMBER(title)
@@ -2295,6 +2302,11 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_FrameDetached,
// first paint.
IPC_MESSAGE_ROUTED0(ViewHostMsg_WillInsertBody)
+// Notification that the urls for the favicon of a site has been determined.
+IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateFaviconURL,
+ int32 /* page_id */,
+ std::vector<content::FaviconURL> /* candidates */)
+
#if defined(OS_ANDROID)
// Response to ViewMsg_FindMatchRects.
//
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 5f261bc..0770f93 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -264,7 +264,7 @@
'common/gpu/texture_image_transport_surface.cc',
'common/handle_enumerator_win.cc',
'common/handle_enumerator_win.h',
- 'common/icon_messages.h',
+ 'common/image_messages.h',
'common/indexed_db/indexed_db_key.cc',
'common/indexed_db/indexed_db_key.h',
'common/indexed_db/indexed_db_key_path.cc',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 10edaad..6a7c6d0 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -88,8 +88,6 @@
'renderer/dom_storage/webstoragenamespace_impl.h',
'renderer/external_popup_menu.cc',
'renderer/external_popup_menu.h',
- 'renderer/favicon_helper.cc',
- 'renderer/favicon_helper.h',
'renderer/gamepad_shared_memory_reader.cc',
'renderer/gamepad_shared_memory_reader.h',
'renderer/geolocation_dispatcher.cc',
@@ -114,6 +112,8 @@
'renderer/hyphenator/hyphenator.h',
'renderer/idle_user_detector.cc',
'renderer/idle_user_detector.h',
+ 'renderer/image_loading_helper.cc',
+ 'renderer/image_loading_helper.h',
'renderer/input_tag_speech_dispatcher.cc',
'renderer/input_tag_speech_dispatcher.h',
'renderer/java/java_bridge_channel.cc',
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 22f0fab..13cec7f 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -412,19 +412,19 @@ class WebContents : public PageNavigator,
const GURL&, /* image_url */
int, /* requested_size */
const std::vector<SkBitmap>& /* bitmaps*/)>
- FaviconDownloadCallback;
+ ImageDownloadCallback;
- // Sends a request to download the given favicon |url| and returns the unique
+ // Sends a request to download the given image |url| and returns the unique
// id of the download request. When the download is finished, |callback| will
- // be called with the bitmaps received from the renderer. If [is_favicon|,
- // the cookeis are not sent and not accepted during download. Note that
+ // be called with the bitmaps received from the renderer. If |is_favicon| is
+ // true, the cookies are not sent and not accepted during download. Note that
// |image_size| is a hint for images with multiple sizes. The downloaded image
// is not resized to the given image_size. If 0 is passed, the first frame of
// the image is returned.
- virtual int DownloadFavicon(const GURL& url,
- bool is_favicon,
- int image_size,
- const FaviconDownloadCallback& callback) = 0;
+ virtual int DownloadImage(const GURL& url,
+ bool is_favicon,
+ int image_size,
+ const ImageDownloadCallback& callback) = 0;
private:
// This interface should only be implemented inside content.
diff --git a/content/renderer/favicon_helper.cc b/content/renderer/favicon_helper.cc
deleted file mode 100644
index 541847e..0000000
--- a/content/renderer/favicon_helper.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/favicon_helper.h"
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/message_loop.h"
-#include "content/common/icon_messages.h"
-#include "content/public/renderer/render_view.h"
-#include "net/base/data_url.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
-#include "ui/base/ui_base_switches.h"
-#include "ui/gfx/favicon_size.h"
-#include "ui/gfx/size.h"
-#include "ui/gfx/skbitmap_operations.h"
-#include "webkit/glue/image_decoder.h"
-#include "webkit/glue/multi_resolution_image_resource_fetcher.h"
-#include "webkit/glue/webkit_glue.h"
-
-using WebKit::WebFrame;
-using WebKit::WebIconURL;
-using WebKit::WebVector;
-using WebKit::WebURL;
-using WebKit::WebURLRequest;
-using webkit_glue::MultiResolutionImageResourceFetcher;
-
-namespace content {
-
-namespace {
-
-bool TouchEnabled() {
-// Based on the definition of chrome::kEnableTouchIcon.
-#if defined(OS_ANDROID)
- return true;
-#else
- return false;
-#endif
-}
-
-} // namespace
-
-
-static FaviconURL::IconType ToFaviconType(WebIconURL::Type type) {
- switch (type) {
- case WebIconURL::TypeFavicon:
- return FaviconURL::FAVICON;
- case WebIconURL::TypeTouch:
- return FaviconURL::TOUCH_ICON;
- case WebIconURL::TypeTouchPrecomposed:
- return FaviconURL::TOUCH_PRECOMPOSED_ICON;
- case WebIconURL::TypeInvalid:
- return FaviconURL::INVALID_ICON;
- }
- return FaviconURL::INVALID_ICON;
-}
-
-FaviconHelper::FaviconHelper(RenderView* render_view)
- : RenderViewObserver(render_view),
- icon_types_changed_(WebIconURL::TypeInvalid),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
-}
-
-void FaviconHelper::DidChangeIcon(WebKit::WebFrame* frame,
- WebKit::WebIconURL::Type icon_type) {
- if (frame->parent())
- return;
-
- if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon)
- return;
-
- DCHECK(!render_view()->GetWebView() ||
- frame == render_view()->GetWebView()->mainFrame());
-
- weak_ptr_factory_.InvalidateWeakPtrs();
- icon_types_changed_ =
- static_cast<WebKit::WebIconURL::Type>(icon_types_changed_ | icon_type);
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&FaviconHelper::ProcessDidChangeIcon,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-FaviconHelper::~FaviconHelper() {
-}
-
-void FaviconHelper::ProcessDidChangeIcon() {
- WebKit::WebIconURL::Type icon_types = icon_types_changed_;
- icon_types_changed_ = WebIconURL::TypeInvalid;
- WebKit::WebView* web_view = render_view()->GetWebView();
- if (!web_view) {
- return;
- }
- WebFrame* frame = web_view->mainFrame();
- if (!frame) {
- return;
- }
- WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_types);
- std::vector<FaviconURL> urls;
- for (size_t i = 0; i < icon_urls.size(); i++) {
- urls.push_back(FaviconURL(icon_urls[i].iconURL(),
- ToFaviconType(icon_urls[i].iconType())));
- }
- SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls);
-}
-
-void FaviconHelper::OnDownloadFavicon(int id,
- const GURL& image_url,
- bool is_favicon,
- int image_size) {
- std::vector<SkBitmap> result_images;
- if (image_url.SchemeIs("data")) {
- SkBitmap data_image = ImageFromDataUrl(image_url);
- if (!data_image.empty())
- result_images.push_back(data_image);
- } else {
- if (DownloadFavicon(id, image_url, is_favicon, image_size)) {
- // Will complete asynchronously via FaviconHelper::DidDownloadFavicon
- return;
- }
- }
-
- Send(new IconHostMsg_DidDownloadFavicon(routing_id(),
- id,
- image_url,
- image_size,
- result_images));
-}
-
-bool FaviconHelper::DownloadFavicon(int id,
- const GURL& image_url,
- bool is_favicon,
- int image_size) {
- // Make sure webview was not shut down.
- if (!render_view()->GetWebView())
- return false;
- // Create an image resource fetcher and assign it with a call back object.
- image_fetchers_.push_back(new MultiResolutionImageResourceFetcher(
- image_url,
- render_view()->GetWebView()->mainFrame(),
- id,
- is_favicon ? WebURLRequest::TargetIsFavicon :
- WebURLRequest::TargetIsImage,
- base::Bind(&FaviconHelper::DidDownloadFavicon,
- base::Unretained(this), image_size)));
- return true;
-}
-
-void FaviconHelper::DidDownloadFavicon(
- int requested_size,
- MultiResolutionImageResourceFetcher* fetcher,
- const std::vector<SkBitmap>& images) {
- // Notify requester of image download status.
- Send(new IconHostMsg_DidDownloadFavicon(routing_id(),
- fetcher->id(),
- fetcher->image_url(),
- requested_size,
- images));
-
- // Remove the image fetcher from our pending list. We're in the callback from
- // MultiResolutionImageResourceFetcher, best to delay deletion.
- ImageResourceFetcherList::iterator iter =
- std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher);
- if (iter != image_fetchers_.end()) {
- image_fetchers_.weak_erase(iter);
- MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
- }
-}
-
-SkBitmap FaviconHelper::ImageFromDataUrl(const GURL& url) const {
- std::string mime_type, char_set, data;
- if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) {
- // Decode the favicon using WebKit's image decoder.
- webkit_glue::ImageDecoder decoder(
- gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize));
- const unsigned char* src_data =
- reinterpret_cast<const unsigned char*>(&data[0]);
-
- return decoder.Decode(src_data, data.size());
- }
- return SkBitmap();
-}
-
-void FaviconHelper::SendUpdateFaviconURL(int32 routing_id,
- int32 page_id,
- const std::vector<FaviconURL>& urls) {
- if (!urls.empty())
- Send(new IconHostMsg_UpdateFaviconURL(routing_id, page_id, urls));
-}
-
-bool FaviconHelper::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(FaviconHelper, message)
- IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void FaviconHelper::DidStopLoading() {
- int icon_types = WebIconURL::TypeFavicon;
- if (TouchEnabled())
- icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch;
-
- WebVector<WebIconURL> icon_urls =
- render_view()->GetWebView()->mainFrame()->iconURLs(icon_types);
- std::vector<FaviconURL> urls;
- for (size_t i = 0; i < icon_urls.size(); i++) {
- WebURL url = icon_urls[i].iconURL();
- if (!url.isEmpty())
- urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType())));
- }
- SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls);
-}
-
-} // namespace content
diff --git a/content/renderer/favicon_helper.h b/content/renderer/favicon_helper.h
deleted file mode 100644
index 65032ec1..0000000
--- a/content/renderer/favicon_helper.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_FAVICON_HELPER_H_
-#define CONTENT_RENDERER_FAVICON_HELPER_H_
-
-#include <string>
-#include <vector>
-
-#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/weak_ptr.h"
-#include "content/public/common/content_constants.h"
-#include "content/public/renderer/render_view_observer.h"
-#include "googleurl/src/gurl.h"
-
-class SkBitmap;
-
-namespace content {
-struct FaviconURL;
-}
-
-namespace webkit_glue {
-class MultiResolutionImageResourceFetcher;
-}
-
-namespace content {
-
-struct FaviconURL;
-
-// This class deals with favicon downloading.
-// There is one FaviconHelper per RenderView, which is owned by the RenderView.
-class FaviconHelper : public RenderViewObserver {
- public:
- explicit FaviconHelper(RenderView* render_view);
-
- // Send a message that the favicon has changed.
- void DidChangeIcon(WebKit::WebFrame* frame,
- WebKit::WebIconURL::Type icon_type);
-
- private:
- virtual ~FaviconHelper();
-
- // Start processing the icon change. This done async from DidChangeIcon in
- // case there are several calls to DidChangeIcon in a row.
- void ProcessDidChangeIcon();
-
- // Message handler.
- void OnDownloadFavicon(int id,
- const GURL& image_url,
- bool is_favicon,
- int image_size);
-
- // Requests to download a favicon image. When done, the RenderView
- // is notified by way of DidDownloadFavicon. Returns true if the
- // request was successfully started, false otherwise. id is used to
- // uniquely identify the request and passed back to the
- // DidDownloadFavicon method. If the image is a favicon, cookies are
- // not sent and not accepted during download.
- // If the image has multiple frames, the
- // frame whose size is image_size is returned. If the image doesn't
- // have a frame at the specified size, the first is returned.
- bool DownloadFavicon(int id,
- const GURL& image_url,
- bool is_favicon,
- int image_size);
-
- // This callback is triggered when DownloadFavicon completes, either
- // succesfully or with a failure. See DownloadFavicon for more
- // details.
- void DidDownloadFavicon(
- int requested_size,
- webkit_glue::MultiResolutionImageResourceFetcher* fetcher,
- const std::vector<SkBitmap>& images);
-
- // Decodes a data: URL image or returns an empty image in case of failure.
- SkBitmap ImageFromDataUrl(const GURL&) const;
-
- // Send a message to update the favicon URL for a page.
- void SendUpdateFaviconURL(int32 routing_id,
- int32 page_id,
- const std::vector<FaviconURL>& urls);
-
- // RenderViewObserver implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- virtual void DidStopLoading() OVERRIDE;
-
- typedef ScopedVector<webkit_glue::MultiResolutionImageResourceFetcher>
- ImageResourceFetcherList;
-
- // ImageResourceFetchers schedule via DownloadImage.
- ImageResourceFetcherList image_fetchers_;
-
- // The set of flags which have been sent to DidChangeIcon but not yet
- // processed.
- WebKit::WebIconURL::Type icon_types_changed_;
-
- base::WeakPtrFactory<FaviconHelper> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(FaviconHelper);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_FAVICON_HELPER_H_
diff --git a/content/renderer/image_loading_helper.cc b/content/renderer/image_loading_helper.cc
new file mode 100644
index 0000000..c996984
--- /dev/null
+++ b/content/renderer/image_loading_helper.cc
@@ -0,0 +1,127 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/image_loading_helper.h"
+
+#include "base/bind.h"
+#include "base/message_loop.h"
+#include "content/common/image_messages.h"
+#include "content/public/common/url_constants.h"
+#include "content/public/renderer/render_view.h"
+#include "net/base/data_url.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "ui/gfx/favicon_size.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/skbitmap_operations.h"
+#include "webkit/glue/image_decoder.h"
+#include "webkit/glue/multi_resolution_image_resource_fetcher.h"
+#include "webkit/glue/webkit_glue.h"
+
+using WebKit::WebFrame;
+using WebKit::WebVector;
+using WebKit::WebURL;
+using WebKit::WebURLRequest;
+using webkit_glue::MultiResolutionImageResourceFetcher;
+
+namespace content {
+
+ImageLoadingHelper::ImageLoadingHelper(RenderView* render_view)
+ : RenderViewObserver(render_view) {
+}
+
+ImageLoadingHelper::~ImageLoadingHelper() {
+}
+
+void ImageLoadingHelper::OnDownloadImage(int id,
+ const GURL& image_url,
+ bool is_favicon,
+ int image_size) {
+ std::vector<SkBitmap> result_images;
+ if (image_url.SchemeIs(chrome::kDataScheme)) {
+ SkBitmap data_image = ImageFromDataUrl(image_url);
+ if (!data_image.empty())
+ result_images.push_back(data_image);
+ } else {
+ if (DownloadImage(id, image_url, is_favicon, image_size)) {
+ // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage
+ return;
+ }
+ }
+
+ Send(new ImageHostMsg_DidDownloadImage(routing_id(),
+ id,
+ image_url,
+ image_size,
+ result_images));
+}
+
+bool ImageLoadingHelper::DownloadImage(int id,
+ const GURL& image_url,
+ bool is_favicon,
+ int image_size) {
+ // Make sure webview was not shut down.
+ if (!render_view()->GetWebView())
+ return false;
+ // Create an image resource fetcher and assign it with a call back object.
+ image_fetchers_.push_back(new MultiResolutionImageResourceFetcher(
+ image_url,
+ render_view()->GetWebView()->mainFrame(),
+ id,
+ is_favicon ? WebURLRequest::TargetIsFavicon :
+ WebURLRequest::TargetIsImage,
+ base::Bind(&ImageLoadingHelper::DidDownloadImage,
+ base::Unretained(this), image_size)));
+ return true;
+}
+
+void ImageLoadingHelper::DidDownloadImage(
+ int requested_size,
+ MultiResolutionImageResourceFetcher* fetcher,
+ const std::vector<SkBitmap>& images) {
+ // Notify requester of image download status.
+ Send(new ImageHostMsg_DidDownloadImage(routing_id(),
+ fetcher->id(),
+ fetcher->image_url(),
+ requested_size,
+ images));
+
+ // Remove the image fetcher from our pending list. We're in the callback from
+ // MultiResolutionImageResourceFetcher, best to delay deletion.
+ ImageResourceFetcherList::iterator iter =
+ std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher);
+ if (iter != image_fetchers_.end()) {
+ image_fetchers_.weak_erase(iter);
+ MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
+ }
+}
+
+SkBitmap ImageLoadingHelper::ImageFromDataUrl(const GURL& url) const {
+ std::string mime_type, char_set, data;
+ if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) {
+ // Decode the image using WebKit's image decoder.
+ webkit_glue::ImageDecoder decoder(
+ gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize));
+ const unsigned char* src_data =
+ reinterpret_cast<const unsigned char*>(&data[0]);
+
+ return decoder.Decode(src_data, data.size());
+ }
+ return SkBitmap();
+}
+
+bool ImageLoadingHelper::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message)
+ IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+} // namespace content
+
diff --git a/content/renderer/image_loading_helper.h b/content/renderer/image_loading_helper.h
new file mode 100644
index 0000000..6e2302d
--- /dev/null
+++ b/content/renderer/image_loading_helper.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
+#define CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/scoped_vector.h"
+#include "content/public/renderer/render_view_observer.h"
+#include "googleurl/src/gurl.h"
+
+class SkBitmap;
+
+namespace webkit_glue {
+class MultiResolutionImageResourceFetcher;
+}
+
+namespace content {
+
+// This class deals with image downloading.
+// One instance of ImageLoadingHelper is owned by RenderView.
+class ImageLoadingHelper : public RenderViewObserver {
+ public:
+ explicit ImageLoadingHelper(RenderView* render_view);
+
+ private:
+ virtual ~ImageLoadingHelper();
+
+ // Message handler.
+ void OnDownloadImage(int id,
+ const GURL& image_url,
+ bool is_favicon,
+ int image_size);
+
+ // Requests to download an image. When done, the ImageLoadingHelper
+ // is notified by way of DidDownloadImage. Returns true if the
+ // request was successfully started, false otherwise. id is used to
+ // uniquely identify the request and passed back to the
+ // DidDownloadImage method. If the image is a favicon, cookies will not be
+ // sent nor accepted during download. If the image has multiple frames, the
+ // frame whose size is image_size is returned. If the image doesn't
+ // have a frame at the specified size, the first is returned.
+ bool DownloadImage(int id,
+ const GURL& image_url,
+ bool is_favicon,
+ int image_size);
+
+ // This callback is triggered when DownloadImage completes, either
+ // succesfully or with a failure. See DownloadImage for more
+ // details.
+ void DidDownloadImage(
+ int requested_size,
+ webkit_glue::MultiResolutionImageResourceFetcher* fetcher,
+ const std::vector<SkBitmap>& images);
+
+ // Decodes a data: URL image or returns an empty image in case of failure.
+ SkBitmap ImageFromDataUrl(const GURL&) const;
+
+ // RenderViewObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ typedef ScopedVector<webkit_glue::MultiResolutionImageResourceFetcher>
+ ImageResourceFetcherList;
+
+ // ImageResourceFetchers schedule via DownloadImage.
+ ImageResourceFetcherList image_fetchers_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
+
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index dd55cf5..130f3ee 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -51,6 +51,7 @@
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/context_menu_params.h"
+#include "content/public/common/favicon_url.h"
#include "content/public/common/file_chooser_params.h"
#include "content/public/common/ssl_status.h"
#include "content/public/common/three_d_api_types.h"
@@ -75,11 +76,11 @@
#include "content/renderer/dom_automation_controller.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/external_popup_menu.h"
-#include "content/renderer/favicon_helper.h"
#include "content/renderer/geolocation_dispatcher.h"
#include "content/renderer/gpu/input_handler_manager.h"
#include "content/renderer/gpu/render_widget_compositor.h"
#include "content/renderer/idle_user_detector.h"
+#include "content/renderer/image_loading_helper.h"
#include "content/renderer/input_tag_speech_dispatcher.h"
#include "content/renderer/java/java_bridge_dispatcher.h"
#include "content/renderer/load_progress_tracker.h"
@@ -546,6 +547,20 @@ static bool ShouldUseFixedPositionCompositing(float device_scale_factor) {
return false;
}
+static FaviconURL::IconType ToFaviconType(WebKit::WebIconURL::Type type) {
+ switch (type) {
+ case WebKit::WebIconURL::TypeFavicon:
+ return FaviconURL::FAVICON;
+ case WebKit::WebIconURL::TypeTouch:
+ return FaviconURL::TOUCH_ICON;
+ case WebKit::WebIconURL::TypeTouchPrecomposed:
+ return FaviconURL::TOUCH_PRECOMPOSED_ICON;
+ case WebKit::WebIconURL::TypeInvalid:
+ return FaviconURL::INVALID_ICON;
+ }
+ return FaviconURL::INVALID_ICON;
+}
+
///////////////////////////////////////////////////////////////////////////////
struct RenderViewImpl::PendingFileChooser {
@@ -595,6 +610,15 @@ int64 ExtractPostId(const WebHistoryItem& item) {
return item.httpBody().identifier();
}
+bool TouchEnabled() {
+// Based on the definition of chrome::kEnableTouchIcon.
+#if defined(OS_ANDROID)
+ return true;
+#else
+ return false;
+#endif
+}
+
} // namespace
RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
@@ -635,7 +659,6 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
renderer_accessibility_(NULL),
java_bridge_dispatcher_(NULL),
mouse_lock_dispatcher_(NULL),
- favicon_helper_(NULL),
#if defined(OS_ANDROID)
body_background_color_(SK_ColorWHITE),
update_frame_info_scheduled_(false),
@@ -762,7 +785,8 @@ void RenderViewImpl::Initialize(RenderViewImplParams* params) {
// along with the RenderView automatically.
devtools_agent_ = new DevToolsAgent(this);
mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this);
- favicon_helper_ = new FaviconHelper(this);
+
+ new ImageLoadingHelper(this);
// Create renderer_accessibility_ if needed.
OnSetAccessibilityMode(params->accessibility_mode);
@@ -2109,6 +2133,8 @@ void RenderViewImpl::didStopLoading() {
if (load_progress_tracker_ != NULL)
load_progress_tracker_->DidStopLoading();
+ DidStopLoadingIcons();
+
FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading());
}
@@ -3634,8 +3660,21 @@ void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title,
UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
}
-void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) {
- favicon_helper_->DidChangeIcon(frame, type);
+void RenderViewImpl::didChangeIcon(WebFrame* frame,
+ WebIconURL::Type icon_type) {
+ if (frame->parent())
+ return;
+
+ if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon)
+ return;
+
+ WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type);
+ std::vector<FaviconURL> urls;
+ for (size_t i = 0; i < icon_urls.size(); i++) {
+ urls.push_back(FaviconURL(icon_urls[i].iconURL(),
+ ToFaviconType(icon_urls[i].iconType())));
+ }
+ SendUpdateFaviconURL(urls);
}
void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) {
@@ -6555,4 +6594,28 @@ void RenderViewImpl::DidCommitCompositorFrame() {
FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame());
}
+void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) {
+ if (!urls.empty())
+ Send(new ViewHostMsg_UpdateFaviconURL(routing_id_, page_id_, urls));
+}
+
+void RenderViewImpl::DidStopLoadingIcons() {
+ int icon_types = WebIconURL::TypeFavicon;
+ if (TouchEnabled())
+ icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch;
+
+ WebVector<WebIconURL> icon_urls =
+ webview()->mainFrame()->iconURLs(icon_types);
+
+ std::vector<FaviconURL> urls;
+ for (size_t i = 0; i < icon_urls.size(); i++) {
+ WebURL url = icon_urls[i].iconURL();
+ if (!url.isEmpty())
+ urls.push_back(FaviconURL(url,
+ ToFaviconType(icon_urls[i].iconType())));
+ }
+ SendUpdateFaviconURL(urls);
+}
+
+
} // namespace content
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 28a6f1a..4473025 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -169,6 +169,7 @@ class RenderWidgetFullscreenPepper;
class SpeechRecognitionDispatcher;
class WebPluginDelegateProxy;
struct CustomContextMenuContext;
+struct FaviconURL;
struct FileChooserParams;
struct RenderViewImplParams;
@@ -1186,6 +1187,13 @@ class CONTENT_EXPORT RenderViewImpl
// If |url| is empty, show |fallback_url|.
void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
+ // Tells the browser what the new list of favicons for the webpage is.
+ void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls);
+
+ // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
+ // the browser.
+ void DidStopLoadingIcons();
+
// Coordinate conversion -----------------------------------------------------
gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const;
@@ -1418,9 +1426,6 @@ class CONTENT_EXPORT RenderViewImpl
// Mouse Lock dispatcher attached to this view.
MouseLockDispatcher* mouse_lock_dispatcher_;
- // Helper class to handle favicon changes.
- FaviconHelper* favicon_helper_;
-
#if defined(OS_ANDROID)
// Android Specific ---------------------------------------------------------
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h
index b535e92..3a8713f 100644
--- a/ipc/ipc_message_start.h
+++ b/ipc/ipc_message_start.h
@@ -52,7 +52,7 @@ enum IPCMessageStart {
ExtensionMsgStart,
VideoCaptureMsgStart,
QuotaMsgStart,
- IconMsgStart,
+ ImageMsgStart,
TextInputClientMsgStart,
ChromeUtilityMsgStart,
MediaStreamMsgStart,