summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authormichaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-11 21:40:46 +0000
committermichaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-11 21:40:46 +0000
commit351ef3bc6f4ef78a1a8a5e9ccf2bdf0e3ec38e65 (patch)
tree15756795df3c94317f518cda23697ccacadea46a /chrome/common
parent639e57d0e1d79f996733d81285c6604314ca9cde (diff)
downloadchromium_src-351ef3bc6f4ef78a1a8a5e9ccf2bdf0e3ec38e65.zip
chromium_src-351ef3bc6f4ef78a1a8a5e9ccf2bdf0e3ec38e65.tar.gz
chromium_src-351ef3bc6f4ef78a1a8a5e9ccf2bdf0e3ec38e65.tar.bz2
a Downloaded or retrieved favicon and touch in FaviconHelper.
b.ViewHostMsg_UpdateFaviconURL can update multiple icon urls BUG=71571 TEST=Tested with existing unit test and add 2 new unit tests Review URL: http://codereview.chromium.org/6672065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/icon_messages.cc60
-rw-r--r--chrome/common/icon_messages.h57
-rw-r--r--chrome/common/render_messages.h5
3 files changed, 120 insertions, 2 deletions
diff --git a/chrome/common/icon_messages.cc b/chrome/common/icon_messages.cc
new file mode 100644
index 0000000..7648c14
--- /dev/null
+++ b/chrome/common/icon_messages.cc
@@ -0,0 +1,60 @@
+// 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
new file mode 100644
index 0000000..47d4e9f
--- /dev/null
+++ b/chrome/common/icon_messages.h
@@ -0,0 +1,57 @@
+// 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.
+
+// Multiply-included message file, no traditional include guard.
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+
+// 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__
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index ba64142..d417048 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -18,6 +18,7 @@
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/content_settings.h"
+#include "chrome/common/icon_messages.h"
#include "chrome/common/instant_types.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/prerender_constants.h"
@@ -334,10 +335,10 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail,
IPC_MESSAGE_ROUTED1(ViewHostMsg_Snapshot,
SkBitmap /* bitmap */)
-// Notification that the url for the favicon of a site has been determined.
+// Notification that the urls for the favicon of a site has been determined.
IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateFaviconURL,
int32 /* page_id */,
- GURL /* url of the favicon */)
+ std::vector<FaviconURL> /* urls of the favicon */)
// Following message is used to communicate the values received by the
// callback binding the JS to Cpp.