summaryrefslogtreecommitdiffstats
path: root/chrome/common/render_messages.h
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 19:36:32 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 19:36:32 +0000
commit0bedb8a46053e44f667da0e800568c38e2150e4a (patch)
treecd14724a4078a65970c56e97cbd7c5a904c2f14c /chrome/common/render_messages.h
parent6fa508a1cef4a920f570174c77eafc5f21d808eb (diff)
downloadchromium_src-0bedb8a46053e44f667da0e800568c38e2150e4a.zip
chromium_src-0bedb8a46053e44f667da0e800568c38e2150e4a.tar.gz
chromium_src-0bedb8a46053e44f667da0e800568c38e2150e4a.tar.bz2
This CL contains the back-end implementation of the translate feature. It adds a Translate method to the renderer.
On invocation this method triggers a traversal of the DOM page to retrieve the text nodes. The text node contents are then sent to the browser for actual translation (at this point, we just up-case the text for testing purpose). The browser sends back the translated text to the renderer that replace the DOM text node values with the translated text. BUG=None TEST=Run the unit-tests. Review URL: http://codereview.chromium.org/547013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/render_messages.h')
-rw-r--r--chrome/common/render_messages.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 3bd76e5..3934b53 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -534,6 +534,31 @@ struct ViewMsg_ExecuteCode_Params {
bool all_frames;
};
+// Message to ask the browser to translate some text from one language to
+// another.
+struct ViewHostMsg_TranslateTextParam {
+ // The routing id. Even though ViewHostMsg_TranslateText is a control message
+ // (sent to the browser, not to a specific RenderViewHost), the browser needs
+ // the routing id in order to send the response back to the right RenderView.
+ int routing_id;
+
+ // An id used to identify that specific translation.
+ int work_id;
+
+ // The text chunks that need to be translated.
+ std::vector<string16> text_chunks;
+
+ // The ISO code of the language the text to translate is in.
+ std::string from_language;
+
+ // The ISO code of the language the text should be translated to.
+ std::string to_language;
+
+ // Whether a secure connection should be used when transmitting the text for
+ // translation to an external server.
+ bool secure;
+};
+
namespace IPC {
template <>
@@ -2307,6 +2332,45 @@ struct ParamTraits<ViewMsg_ExecuteCode_Params> {
}
};
+template<>
+struct ParamTraits<ViewHostMsg_TranslateTextParam> {
+ typedef ViewHostMsg_TranslateTextParam param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.routing_id);
+ WriteParam(m, p.work_id);
+ WriteParam(m, p.text_chunks);
+ WriteParam(m, p.from_language);
+ WriteParam(m, p.to_language);
+ WriteParam(m, p.secure);
+ }
+
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return
+ ReadParam(m, iter, &p->routing_id) &&
+ ReadParam(m, iter, &p->work_id) &&
+ ReadParam(m, iter, &p->text_chunks) &&
+ ReadParam(m, iter, &p->from_language) &&
+ ReadParam(m, iter, &p->to_language) &&
+ ReadParam(m, iter, &p->secure);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.routing_id, l);
+ l->append(L", ");
+ LogParam(p.work_id, l);
+ l->append(L", ");
+ LogParam(p.text_chunks, l);
+ l->append(L", ");
+ LogParam(p.from_language, l);
+ l->append(L", ");
+ LogParam(p.to_language, l);
+ l->append(L", ");
+ LogParam(p.secure, l);
+ l->append(L")");
+ }
+};
+
+
} // namespace IPC