summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 21:28:05 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 21:28:05 +0000
commitae4efe42b48b651afc569537aca438c876cf7564 (patch)
tree990901ce745227abf74334d11e9d176b2e39ff6d
parent1c3412c0cae171231da8a17d41d48694473b567a (diff)
downloadchromium_src-ae4efe42b48b651afc569537aca438c876cf7564.zip
chromium_src-ae4efe42b48b651afc569537aca438c876cf7564.tar.gz
chromium_src-ae4efe42b48b651afc569537aca438c876cf7564.tar.bz2
Make icon_messages use the IPC macros for defining the structs and the serialization code, and move the icon messages there. Also get rid of friend class in RenderView that's not needed anymore.
Review URL: http://codereview.chromium.org/6883020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81999 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/favicon_helper.cc75
-rw-r--r--chrome/browser/favicon_helper.h12
-rw-r--r--chrome/browser/favicon_helper_unittest.cc58
-rw-r--r--chrome/browser/prerender/prerender_contents.cc5
-rw-r--r--chrome/browser/prerender/prerender_contents.h2
-rw-r--r--chrome/browser/prerender/prerender_manager.cc2
-rw-r--r--chrome/chrome_common.gypi3
-rw-r--r--chrome/common/common_message_generator.h1
-rw-r--r--chrome/common/favicon_url.cc17
-rw-r--r--chrome/common/favicon_url.h32
-rw-r--r--chrome/common/icon_messages.cc60
-rw-r--r--chrome/common/icon_messages.h84
-rw-r--r--chrome/common/render_messages.h21
-rw-r--r--chrome/renderer/chrome_render_view_observer.cc17
-rw-r--r--content/browser/renderer_host/render_view_host.cc3
-rw-r--r--content/browser/tab_contents/tab_contents.cc3
-rw-r--r--content/renderer/render_view.h3
-rw-r--r--ipc/ipc_message_utils.h1
18 files changed, 183 insertions, 216 deletions
diff --git a/chrome/browser/favicon_helper.cc b/chrome/browser/favicon_helper.cc
index 6479c69..fae78a7 100644
--- a/chrome/browser/favicon_helper.cc
+++ b/chrome/browser/favicon_helper.cc
@@ -12,7 +12,7 @@
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/render_messages.h"
+#include "chrome/common/icon_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h"
@@ -21,6 +21,34 @@
#include "skia/ext/image_operations.h"
#include "ui/gfx/codec/png_codec.h"
+namespace {
+
+// Returns history::IconType the given icon_type corresponds to.
+history::IconType ToHistoryIconType(FaviconURL::IconType icon_type) {
+ switch (icon_type) {
+ case FaviconURL::FAVICON:
+ return history::FAVICON;
+ case FaviconURL::TOUCH_ICON:
+ return history::TOUCH_ICON;
+ case FaviconURL::TOUCH_PRECOMPOSED_ICON:
+ return history::TOUCH_PRECOMPOSED_ICON;
+ case FaviconURL::INVALID_ICON:
+ return history::INVALID_ICON;
+ }
+ NOTREACHED();
+ // Shouldn't reach here, just make compiler happy.
+ return history::INVALID_ICON;
+}
+
+bool DoUrlAndIconMatch(const FaviconURL& favicon_url,
+ const GURL& url,
+ history::IconType icon_type) {
+ return favicon_url.icon_url == url &&
+ favicon_url.icon_type == static_cast<FaviconURL::IconType>(icon_type);
+}
+
+} // namespace
+
FaviconHelper::DownloadRequest::DownloadRequest()
: callback(NULL),
icon_type(history::INVALID_ICON) {
@@ -159,16 +187,17 @@ void FaviconHelper::OnUpdateFaviconURL(
return;
// For FAVICON.
- if (current_candidate()->icon_type == ::FAVICON) {
+ if (current_candidate()->icon_type == FaviconURL::FAVICON) {
if (!favicon_expired_ && entry->favicon().is_valid() &&
- do_url_and_icon_match(*current_candidate(), entry->favicon().url(),
- history::FAVICON))
+ DoUrlAndIconMatch(*current_candidate(), entry->favicon().url(),
+ history::FAVICON))
return;
entry->favicon().set_url(current_candidate()->icon_url);
} else if (!favicon_expired_ && got_favicon_from_history_ &&
history_icon_.is_valid() &&
- do_url_and_icon_match(*current_candidate(),
+ DoUrlAndIconMatch(
+ *current_candidate(),
history_icon_.icon_url, history_icon_.icon_type)) {
return;
}
@@ -238,26 +267,10 @@ bool FaviconHelper::ShouldSaveFavicon(const GURL& url) {
return bookmark_model && bookmark_model->IsBookmarked(url);
}
-history::IconType FaviconHelper::ToHistoryIconType(IconType icon_type) {
- switch (icon_type) {
- case ::FAVICON:
- return history::FAVICON;
- case ::TOUCH_ICON:
- return history::TOUCH_ICON;
- case ::TOUCH_PRECOMPOSED_ICON:
- return history::TOUCH_PRECOMPOSED_ICON;
- case ::INVALID_ICON:
- return history::INVALID_ICON;
- }
- NOTREACHED();
- // Shouldn't reach here, just make compiler happy.
- return history::INVALID_ICON;
-}
-
bool FaviconHelper::OnMessageReceived(const IPC::Message& message) {
bool message_handled = true;
IPC_BEGIN_MESSAGE_MAP(FaviconHelper, message)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
+ IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
IPC_MESSAGE_UNHANDLED(message_handled = false)
IPC_END_MESSAGE_MAP()
return message_handled;
@@ -277,8 +290,8 @@ void FaviconHelper::OnDidDownloadFavicon(int id,
if (i->second.callback) {
i->second.callback->Run(id, errored, image);
} else if (current_candidate() &&
- do_url_and_icon_match(*current_candidate(), image_url,
- i->second.icon_type)) {
+ DoUrlAndIconMatch(*current_candidate(), image_url,
+ i->second.icon_type)) {
// The downloaded icon is still valid when there is no FaviconURL update
// during the downloading.
if (!errored) {
@@ -307,8 +320,9 @@ void FaviconHelper::OnFaviconDataForInitialURL(
if (favicon.known_icon && favicon.icon_type == history::FAVICON &&
!entry->favicon().is_valid() &&
- (!current_candidate() || do_url_and_icon_match(*current_candidate(),
- favicon.icon_url, favicon.icon_type))) {
+ (!current_candidate() ||
+ DoUrlAndIconMatch(
+ *current_candidate(), favicon.icon_url, favicon.icon_type))) {
// The db knows the favicon (although it may be out of date) and the entry
// doesn't have an icon. Set the favicon now, and if the favicon turns out
// to be expired (or the wrong url) we'll fetch later on. This way the
@@ -320,8 +334,9 @@ void FaviconHelper::OnFaviconDataForInitialURL(
}
if (favicon.known_icon && !favicon.expired) {
- if (current_candidate() && !do_url_and_icon_match(*current_candidate(),
- favicon.icon_url, favicon.icon_type)) {
+ if (current_candidate() &&
+ !DoUrlAndIconMatch(
+ *current_candidate(), favicon.icon_url, favicon.icon_type)) {
// Mapping in the database is wrong. DownloadFavIconOrAskHistory will
// update the mapping for this url and download the favicon if we don't
// already have it.
@@ -391,8 +406,8 @@ void FaviconHelper::OnFaviconData(FaviconService::Handle handle,
history::FAVICON, NULL);
}
} else if (current_candidate() && (!favicon.known_icon || favicon.expired ||
- !(do_url_and_icon_match(*current_candidate(), favicon.icon_url,
- favicon.icon_type)))) {
+ !(DoUrlAndIconMatch(
+ *current_candidate(), favicon.icon_url, favicon.icon_type)))) {
// We don't know the favicon, it is out of date or its type is not same as
// one got from page. Request the current one.
ScheduleDownload(entry->url(), current_candidate()->icon_url,
diff --git a/chrome/browser/favicon_helper.h b/chrome/browser/favicon_helper.h
index 17a383a..aa71ae9 100644
--- a/chrome/browser/favicon_helper.h
+++ b/chrome/browser/favicon_helper.h
@@ -12,7 +12,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/favicon_service.h"
-#include "chrome/common/icon_messages.h"
+#include "chrome/common/favicon_url.h"
#include "chrome/common/ref_counted_util.h"
#include "content/browser/cancelable_request.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
@@ -156,16 +156,6 @@ class FaviconHelper : public TabContentsObserver {
history::IconType icon_type;
};
- static bool do_url_and_icon_match(const FaviconURL& favicon_url,
- const GURL& url,
- history::IconType icon_type) {
- return favicon_url.icon_url == url &&
- favicon_url.icon_type == static_cast<IconType>(icon_type);
- }
-
- // Returns history::IconType the given icon_type corresponds to.
- static history::IconType ToHistoryIconType(IconType icon_type);
-
// TabContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
diff --git a/chrome/browser/favicon_helper_unittest.cc b/chrome/browser/favicon_helper_unittest.cc
index 7b4d7ba..43e0ff6 100644
--- a/chrome/browser/favicon_helper_unittest.cc
+++ b/chrome/browser/favicon_helper_unittest.cc
@@ -307,14 +307,14 @@ TEST_F(FaviconHelperTest, GetFaviconFromHistory) {
// Simulates update favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(icon_url, FAVICON));
+ urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
// Verify FaviconHelper status
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(FAVICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// Favicon shouldn't request to download icon.
DownloadHandler* download_handler = helper.download_handler();
@@ -348,14 +348,14 @@ TEST_F(FaviconHelperTest, DownloadFavicon) {
// Simulates update favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(icon_url, FAVICON));
+ urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
// Verify FaviconHelper status
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(FAVICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// Favicon should request to download icon now.
DownloadHandler* download_handler = helper.download_handler();
@@ -374,7 +374,7 @@ TEST_F(FaviconHelperTest, DownloadFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
- EXPECT_EQ(FAVICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->image_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
@@ -420,14 +420,14 @@ TEST_F(FaviconHelperTest, UpdateAndDownloadFavicon) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(new_icon_url, FAVICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
// Verify FaviconHelper status.
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(FAVICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// The favicon status's url should be updated.
ASSERT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
@@ -435,7 +435,7 @@ TEST_F(FaviconHelperTest, UpdateAndDownloadFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
- EXPECT_EQ(FAVICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
@@ -459,7 +459,7 @@ TEST_F(FaviconHelperTest, UpdateAndDownloadFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
- EXPECT_EQ(FAVICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->image_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
@@ -505,14 +505,14 @@ TEST_F(FaviconHelperTest, UpdateFavicon) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(new_icon_url, FAVICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
// Verify FaviconHelper status.
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(FAVICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// The favicon status's url should be updated.
ASSERT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
@@ -520,7 +520,7 @@ TEST_F(FaviconHelperTest, UpdateFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
- EXPECT_EQ(FAVICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate find icon.
@@ -570,9 +570,9 @@ TEST_F(FaviconHelperTest, Download2ndFaviconURLCandidate) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(icon_url, TOUCH_PRECOMPOSED_ICON));
- urls.push_back(FaviconURL(new_icon_url, TOUCH_ICON));
- urls.push_back(FaviconURL(new_icon_url, FAVICON));
+ urls.push_back(FaviconURL(icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::TOUCH_ICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
@@ -580,13 +580,14 @@ TEST_F(FaviconHelperTest, Download2ndFaviconURLCandidate) {
EXPECT_EQ(2U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(TOUCH_PRECOMPOSED_ICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON,
+ helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
- EXPECT_EQ(TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
@@ -611,13 +612,13 @@ TEST_F(FaviconHelperTest, Download2ndFaviconURLCandidate) {
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
EXPECT_EQ(new_icon_url, helper.current_candidate()->icon_url);
- EXPECT_EQ(TOUCH_ICON, helper.current_candidate()->icon_type);
+ EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
- EXPECT_EQ(TOUCH_ICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Reset download handler
@@ -648,7 +649,7 @@ TEST_F(FaviconHelperTest, Download2ndFaviconURLCandidate) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
- EXPECT_EQ(TOUCH_ICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->image_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
}
@@ -683,9 +684,9 @@ TEST_F(FaviconHelperTest, UpdateDuringDownloading) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(icon_url, TOUCH_PRECOMPOSED_ICON));
- urls.push_back(FaviconURL(new_icon_url, TOUCH_ICON));
- urls.push_back(FaviconURL(new_icon_url, FAVICON));
+ urls.push_back(FaviconURL(icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::TOUCH_ICON));
+ urls.push_back(FaviconURL(new_icon_url, FaviconURL::FAVICON));
DownloadHandler::UpdateFaviconURL(&helper, urls);
@@ -693,13 +694,14 @@ TEST_F(FaviconHelperTest, UpdateDuringDownloading) {
EXPECT_EQ(2U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
- ASSERT_EQ(TOUCH_PRECOMPOSED_ICON, helper.current_candidate()->icon_type);
+ ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON,
+ helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
- EXPECT_EQ(TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
@@ -718,17 +720,17 @@ TEST_F(FaviconHelperTest, UpdateDuringDownloading) {
helper.set_history_handler(NULL);
const GURL latest_icon_url("http://www.google.com/latest_favicon");
std::vector<FaviconURL> latest_urls;
- latest_urls.push_back(FaviconURL(latest_icon_url, TOUCH_ICON));
+ latest_urls.push_back(FaviconURL(latest_icon_url, FaviconURL::TOUCH_ICON));
DownloadHandler::UpdateFaviconURL(&helper, latest_urls);
EXPECT_EQ(1U, helper.urls().size());
EXPECT_EQ(latest_icon_url, helper.current_candidate()->icon_url);
- EXPECT_EQ(TOUCH_ICON, helper.current_candidate()->icon_type);
+ EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type);
// Whether new icon is requested from history
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(latest_icon_url, history_handler->icon_url_);
- EXPECT_EQ(TOUCH_ICON, history_handler->icon_type_);
+ EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Reset the history_handler to verify whether favicon is request from
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index 96a7386..cfe63432 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/login/login_prompt.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/url_constants.h"
@@ -437,7 +438,7 @@ bool PrerenderContents::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP_EX(PrerenderContents, message, message_is_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame,
OnDidStartProvisionalLoadForFrame)
- IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
+ IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
IPC_MESSAGE_HANDLER(ViewHostMsg_MaybeCancelPrerenderForHTML5Media,
OnMaybeCancelPrerenderForHTML5Media)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -470,7 +471,7 @@ void PrerenderContents::OnUpdateFaviconURL(
LOG(INFO) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_;
for (std::vector<FaviconURL>::const_iterator i = urls.begin();
i != urls.end(); ++i) {
- if (i->icon_type == FAVICON) {
+ if (i->icon_type == FaviconURL::FAVICON) {
icon_url_ = i->icon_url;
LOG(INFO) << icon_url_;
return;
diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h
index 6d9245d..81152e3 100644
--- a/chrome/browser/prerender/prerender_contents.h
+++ b/chrome/browser/prerender/prerender_contents.h
@@ -14,7 +14,6 @@
#include "chrome/browser/prerender/prerender_final_status.h"
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
-#include "chrome/common/icon_messages.h"
#include "chrome/common/view_types.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/common/notification_registrar.h"
@@ -22,6 +21,7 @@
#include "webkit/glue/window_open_disposition.h"
class TabContents;
+struct FaviconURL;
struct WebPreferences;
struct ViewHostMsg_FrameNavigate_Params;
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index f560fa6..30f22b7 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -346,7 +346,7 @@ bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tc, const GURL& url) {
if (!icon_url.is_empty()) {
LOG(INFO) << "MaybeUsePreloadedPage";
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(icon_url, FAVICON));
+ urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON));
tc->favicon_helper().OnUpdateFaviconURL(pc->page_id(), urls);
}
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index e072567..7720b0a 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -48,7 +48,6 @@
'common/guid.h',
'common/guid_posix.cc',
'common/guid_win.cc',
- 'common/icon_messages.cc',
'common/icon_messages.h',
'common/instant_types.h',
'common/logging_chrome.cc',
@@ -187,6 +186,8 @@
'common/extensions/url_pattern.h',
'common/extensions/user_script.cc',
'common/extensions/user_script.h',
+ 'common/favicon_url.cc',
+ 'common/favicon_url.h',
'common/important_file_writer.cc',
'common/important_file_writer.h',
'common/json_pref_store.cc',
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index ddeac89..5597abd 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -7,6 +7,7 @@
#include "chrome/common/autofill_messages.h"
#include "chrome/common/devtools_messages.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/safe_browsing/safebrowsing_messages.h"
diff --git a/chrome/common/favicon_url.cc b/chrome/common/favicon_url.cc
new file mode 100644
index 0000000..8b05d0e
--- /dev/null
+++ b/chrome/common/favicon_url.cc
@@ -0,0 +1,17 @@
+// 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.
+
+#include "chrome/common/favicon_url.h"
+
+FaviconURL::FaviconURL()
+ : icon_type(INVALID_ICON) {
+}
+
+FaviconURL::FaviconURL(const GURL& url, IconType type)
+ : icon_url(url),
+ icon_type(type) {
+}
+
+FaviconURL::~FaviconURL() {
+}
diff --git a/chrome/common/favicon_url.h b/chrome/common/favicon_url.h
new file mode 100644
index 0000000..0fd427a
--- /dev/null
+++ b/chrome/common/favicon_url.h
@@ -0,0 +1,32 @@
+// 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 CHROME_COMMON_FAVICON_URL_
+#define CHROME_COMMON_FAVICON_URL_
+#pragma once
+
+#include "googleurl/src/gurl.h"
+
+// The favicon url from the render.
+struct FaviconURL {
+ // The icon type in a page. The definition must be same as history::IconType.
+ enum IconType {
+ INVALID_ICON = 0x0,
+ FAVICON = 1 << 0,
+ TOUCH_ICON = 1 << 1,
+ TOUCH_PRECOMPOSED_ICON = 1 << 2
+ };
+
+ FaviconURL();
+ FaviconURL(const GURL& url, IconType type);
+ ~FaviconURL();
+
+ // The url of the icon.
+ GURL icon_url;
+
+ // The type of the icon
+ IconType icon_type;
+};
+
+#endif // CHROME_COMMON_FAVICON_URL_
diff --git a/chrome/common/icon_messages.cc b/chrome/common/icon_messages.cc
deleted file mode 100644
index 7648c14..0000000
--- a/chrome/common/icon_messages.cc
+++ /dev/null
@@ -1,60 +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.
-
-#include "chrome/common/icon_messages.h"
-
-#include "content/common/common_param_traits.h"
-
-FaviconURL::FaviconURL()
- : icon_type(INVALID_ICON) {
-}
-
-FaviconURL::FaviconURL(const GURL& url, IconType type)
- : icon_url(url),
- icon_type(type) {
-}
-
-FaviconURL::~FaviconURL() {
-}
-
-namespace IPC {
-
-// static
-void ParamTraits<IconType>::Write(Message* m, const param_type& p) {
- m->WriteInt(p);
-}
-
-// static
-bool ParamTraits<IconType>::Read(const Message* m, void** iter, param_type* p) {
- int type;
- if (!m->ReadInt(iter, &type))
- return false;
- *p = static_cast<IconType>(type);
- return true;
-}
-
-// static
-void ParamTraits<IconType>::Log(const param_type& p, std::string* l) {
- l->append("IconType");
-}
-
-// static
-void ParamTraits<FaviconURL>::Write(Message* m, const param_type& p) {
- WriteParam(m, p.icon_url);
- WriteParam(m, p.icon_type);
-}
-
-// static
-bool ParamTraits<FaviconURL>::Read(const Message* m,
- void** iter,
- param_type* p) {
- return ReadParam(m, iter, &p->icon_url) && ReadParam(m, iter, &p->icon_type);
-}
-
-// static
-void ParamTraits<FaviconURL>::Log(const param_type& p, std::string* l) {
- l->append("<FaviconURL>");
-}
-
-} // namespace IPC
diff --git a/chrome/common/icon_messages.h b/chrome/common/icon_messages.h
index 47d4e9f..5f04c94 100644
--- a/chrome/common/icon_messages.h
+++ b/chrome/common/icon_messages.h
@@ -3,55 +3,43 @@
// found in the LICENSE file.
// Multiply-included message file, no traditional include guard.
-#include "googleurl/src/gurl.h"
+#include <vector>
+
+#include "chrome/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(FaviconURL::IconType)
+
+IPC_STRUCT_TRAITS_BEGIN(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 encode it as
+// PNG and send the PNG data back ala IconHostMsg_DidDownloadFavicon.
+IPC_MESSAGE_ROUTED3(IconMsg_DownloadFavicon,
+ int /* identifier for the request */,
+ GURL /* URL of the image */,
+ int /* Size of the image. Normally 0, but set if you have
+ a preferred image size to request, such as when
+ downloading the favicon */)
+
+// 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<FaviconURL> /* urls of the favicon */)
-// TODO : Pull ViewHostMsg_UpdateFaviconURL into this file
-
-#ifndef CHROME_COMMON_ICON_MESSAGES_H__
-#define CHROME_COMMON_ICON_MESSAGES_H__
-
-// The icon type in a page. The definition must be same as history::IconType.
-enum IconType {
- INVALID_ICON = 0x0,
- FAVICON = 1 << 0,
- TOUCH_ICON = 1 << 1,
- TOUCH_PRECOMPOSED_ICON = 1 << 2
-};
-
-// The favicon url from the render.
-struct FaviconURL {
- FaviconURL();
- FaviconURL(const GURL& url, IconType type);
- ~FaviconURL();
-
- // The url of the icon.
- GURL icon_url;
-
- // The type of the icon
- IconType icon_type;
-};
-
-namespace IPC {
-
-template <>
-struct ParamTraits<IconType> {
- typedef IconType param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::string* l);
-};
-
-template <>
-struct ParamTraits<FaviconURL> {
- typedef FaviconURL param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::string* l);
-};
-
-} // namespace IPC
-
-#endif // CHROME_COMMON_ICON_MESSAGES_H__
+IPC_MESSAGE_ROUTED4(IconHostMsg_DidDownloadFavicon,
+ int /* Identifier of the request */,
+ GURL /* URL of the image */,
+ bool /* true if there was a network error */,
+ SkBitmap /* image_data */)
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 510a8f1..d59cafe 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -18,7 +18,6 @@
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/common_param_traits.h"
-#include "chrome/common/icon_messages.h"
#include "chrome/common/instant_types.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/search_provider.h"
@@ -194,15 +193,6 @@ IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
std::vector<FilePath> /* paths of local copy */,
FilePath /* local directory path */)
-// Requests the renderer to download the specified favicon image encode it as
-// PNG and send the PNG data back ala ViewHostMsg_DidDownloadFavicon.
-IPC_MESSAGE_ROUTED3(ViewMsg_DownloadFavicon,
- int /* identifier for the request */,
- GURL /* URL of the image */,
- int /* Size of the image. Normally 0, but set if you have
- a preferred image size to request, such as when
- downloading the favicon */)
-
// Asks the renderer to send back stats on the WebCore cache broken down by
// resource types.
IPC_MESSAGE_CONTROL0(ViewMsg_GetCacheResourceStats)
@@ -305,11 +295,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail,
IPC_MESSAGE_ROUTED1(ViewHostMsg_Snapshot,
SkBitmap /* bitmap */)
-// Notification that the urls for the favicon of a site has been determined.
-IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateFaviconURL,
- int32 /* page_id */,
- std::vector<FaviconURL> /* urls of the favicon */)
-
// Following message is used to communicate the values received by the
// callback binding the JS to Cpp.
// An instance of browser that has an automation host listening to it can
@@ -399,12 +384,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData,
std::string /* data buffer */,
int32 /* complete status */)
-IPC_MESSAGE_ROUTED4(ViewHostMsg_DidDownloadFavicon,
- int /* Identifier of the request */,
- GURL /* URL of the image */,
- bool /* true if there was a network error */,
- SkBitmap /* image_data */)
-
// Provide the browser process with information about the WebCore resource
// cache.
IPC_MESSAGE_CONTROL1(ViewHostMsg_ResourceTypeStats,
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index f7316fa..12b9a60 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/url_constants.h"
@@ -141,7 +142,7 @@ bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(
ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
- IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavicon, OnDownloadFavicon)
+ IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon)
IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -248,14 +249,14 @@ void ChromeRenderViewObserver::OnDownloadFavicon(int id,
SkBitmap data_image = ImageFromDataUrl(image_url);
data_image_failed = data_image.empty();
if (!data_image_failed) {
- Send(new ViewHostMsg_DidDownloadFavicon(
+ Send(new IconHostMsg_DidDownloadFavicon(
routing_id(), id, image_url, false, data_image));
}
}
if (data_image_failed ||
!DownloadFavicon(id, image_url, image_size)) {
- Send(new ViewHostMsg_DidDownloadFavicon(
+ Send(new IconHostMsg_DidDownloadFavicon(
routing_id(), id, image_url, true, SkBitmap()));
}
}
@@ -306,8 +307,8 @@ void ChromeRenderViewObserver::DidStopLoading() {
GURL favicon_url(render_view()->webview()->mainFrame()->favIconURL());
if (!favicon_url.is_empty()) {
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(favicon_url, FAVICON));
- Send(new ViewHostMsg_UpdateFaviconURL(
+ urls.push_back(FaviconURL(favicon_url, FaviconURL::FAVICON));
+ Send(new IconHostMsg_UpdateFaviconURL(
routing_id(), render_view()->page_id(), urls));
}
}
@@ -317,8 +318,8 @@ void ChromeRenderViewObserver::DidChangeIcons(WebFrame* frame) {
return;
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(frame->favIconURL(), FAVICON));
- Send(new ViewHostMsg_UpdateFaviconURL(
+ urls.push_back(FaviconURL(frame->favIconURL(), FaviconURL::FAVICON));
+ Send(new IconHostMsg_UpdateFaviconURL(
routing_id(), render_view()->page_id(), urls));
}
@@ -584,7 +585,7 @@ bool ChromeRenderViewObserver::DownloadFavicon(int id,
void ChromeRenderViewObserver::DidDownloadFavicon(
ImageResourceFetcher* fetcher, const SkBitmap& image) {
// Notify requester of image download status.
- Send(new ViewHostMsg_DidDownloadFavicon(routing_id(),
+ Send(new IconHostMsg_DidDownloadFavicon(routing_id(),
fetcher->id(),
fetcher->image_url(),
image.isNull(),
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 920d462..d5eb8c9 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -22,6 +22,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/safe_browsing/safebrowsing_messages.h"
#include "chrome/common/spellcheck_messages.h"
@@ -571,7 +572,7 @@ int RenderViewHost::DownloadFavicon(const GURL& url, int image_size) {
}
static int next_id = 1;
int id = next_id++;
- Send(new ViewMsg_DownloadFavicon(routing_id(), id, url, image_size));
+ Send(new IconMsg_DownloadFavicon(routing_id(), id, url, image_size));
return id;
}
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index e7071e3..ef69769 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -58,6 +58,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/url_pattern.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
@@ -415,7 +416,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature,
OnPDFHasUnsupportedFeature)
IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset)
- IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
+ IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 3292a37..2e56b83 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -615,9 +615,6 @@ class RenderView : public RenderWidget,
virtual void OnWasRestored(bool needs_repainting);
private:
- // TODO(jam): temporary friend class to ease with the file move. Remove soon.
- friend class chrome::ChromeContentRendererClient;
-
// For unit tests.
friend class ExternalPopupMenuTest;
friend class PepperDeviceTest;
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 3cced70..c353e95 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -88,6 +88,7 @@ enum IPCMessageStart {
ExtensionMsgStart,
VideoCaptureMsgStart,
QuotaMsgStart,
+ IconMsgStart,
LastIPCMsgStart // Must come last.
};