summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 18:09:55 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 18:09:55 +0000
commitb9ab10cd0c07c9c4bc5c9f09742c3ee8e03ab7a3 (patch)
treecfa98ae941be636ec692f3ac15ebf82aa0885d99 /chrome/common
parentf290f3e46ee27cf48b9b6dbc0f35c0d8af6d0c00 (diff)
downloadchromium_src-b9ab10cd0c07c9c4bc5c9f09742c3ee8e03ab7a3.zip
chromium_src-b9ab10cd0c07c9c4bc5c9f09742c3ee8e03ab7a3.tar.gz
chromium_src-b9ab10cd0c07c9c4bc5c9f09742c3ee8e03ab7a3.tar.bz2
Add CSS Keyword values and conversion routines to webkit glue.
Review URL: http://codereview.chromium.org/149044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/common_param_traits_unittest.cc17
-rw-r--r--chrome/common/css_colors.h25
-rw-r--r--chrome/common/render_messages.h17
-rw-r--r--chrome/common/render_messages_internal.h11
4 files changed, 70 insertions, 0 deletions
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index f3a7e92..f5db121 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string.h>
+#include <utility>
#include "base/scoped_ptr.h"
#include "base/values.h"
@@ -52,6 +53,22 @@ TEST(IPCMessageTest, Serialize) {
EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output));
}
+// Tests std::pair serialization
+TEST(IPCMessageTest, Pair) {
+ typedef std::pair<std::string, std::string> TestPair;
+
+ TestPair input("foo", "bar");
+ IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
+ IPC::ParamTraits<TestPair>::Write(&msg, input);
+
+ TestPair output;
+ void* iter = NULL;
+ EXPECT_TRUE(IPC::ParamTraits<TestPair>::Read(&msg, &iter, &output));
+ EXPECT_EQ(output.first, "foo");
+ EXPECT_EQ(output.second, "bar");
+
+}
+
// Tests bitmap serialization.
TEST(IPCMessageTest, Bitmap) {
SkBitmap bitmap;
diff --git a/chrome/common/css_colors.h b/chrome/common/css_colors.h
new file mode 100644
index 0000000..994a3907
--- /dev/null
+++ b/chrome/common/css_colors.h
@@ -0,0 +1,25 @@
+// Copyright (c) 2009 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_CSS_COLORS_H_
+#define CHROME_COMMON_CSS_COLORS_H_
+
+#include <utility>
+
+#include "base/basictypes.h"
+#include "webkit/api/public/WebColor.h"
+#include "webkit/api/public/WebColorName.h"
+
+// Functionality related to sending the values of CSS colors to the renderer.
+class CSSColors {
+ public:
+ typedef WebKit::WebColorName CSSColorName;
+ typedef std::pair<CSSColorName, WebKit::WebColor> CSSColorMapping;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CSSColors);
+};
+
+#endif // CHROME_COMMON_CSS_COLORS_H_
+
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 026ff36f..af9ded8 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -15,6 +15,7 @@
#include "base/shared_memory.h"
#include "chrome/browser/renderer_host/resource_handler.h"
#include "chrome/common/common_param_traits.h"
+#include "chrome/common/css_colors.h"
#include "chrome/common/filter_policy.h"
#include "chrome/common/modal_dialog_event.h"
#include "chrome/common/page_transition_types.h"
@@ -1519,6 +1520,22 @@ struct ParamTraits<ViewHostMsg_DidPrintPage_Params> {
}
};
+// Traits for reading/writing CSS Colors
+template <>
+struct ParamTraits<CSSColors::CSSColorName> {
+ typedef CSSColors::CSSColorName param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p));
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, reinterpret_cast<int*>(p));
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<CSSColorName>");
+ }
+};
+
+
// Traits for RendererPreferences structure to pack/unpack.
template <>
struct ParamTraits<RendererPreferences> {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 1d22e66..5894bdc 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -18,6 +18,7 @@
#include "base/gfx/native_widget_types.h"
#include "base/shared_memory.h"
#include "base/values.h"
+#include "chrome/common/css_colors.h"
#include "chrome/common/transport_dib.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
@@ -40,6 +41,16 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_CONTROL1(ViewMsg_SetNextPageID,
int32 /* next_page_id */)
+ // Sends System Colors corresponding to a set of CSS color keywords
+ // down the pipe.
+ // This message must be sent to the renderer immediately on launch
+ // before creating any new views.
+ // The message can also be sent during a renderer's lifetime if system colors
+ // are updated.
+ // TODO(jeremy): Possibly change IPC format once we have this all hooked up.
+ IPC_MESSAGE_ROUTED1(ViewMsg_SetCSSColors,
+ std::vector<CSSColors::CSSColorMapping>)
+
// Tells the renderer to create a new view.
// This message is slightly different, the view it takes is the view to
// create, the message itself is sent as a non-view control message.