summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authordroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 05:07:49 +0000
committerdroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 05:07:49 +0000
commit381500970819966e039bf3221dec75f0f1affb70 (patch)
treebc7393f5e7206a706745c724609d38011ef5771e /components
parent0203e05abaef4995e07107b25ce992dc0e3c95ee (diff)
downloadchromium_src-381500970819966e039bf3221dec75f0f1affb70.zip
chromium_src-381500970819966e039bf3221dec75f0f1affb70.tar.gz
chromium_src-381500970819966e039bf3221dec75f0f1affb70.tar.bz2
Move Translate renderer messages to the Translate component
BUG=335082 TBR=thakis Review URL: https://codereview.chromium.org/219963007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/translate.gypi18
-rw-r--r--components/translate/content/common/translate_messages.cc33
-rw-r--r--components/translate/content/common/translate_messages.h81
3 files changed, 132 insertions, 0 deletions
diff --git a/components/translate.gypi b/components/translate.gypi
index 0c73df3..9fa48de 100644
--- a/components/translate.gypi
+++ b/components/translate.gypi
@@ -122,6 +122,24 @@
'translate/content/browser/content_translate_driver.h',
],
},
+ {
+ 'target_name': 'translate_content_common',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'translate_core_common',
+ 'translate_language_detection',
+ '../base/base.gyp:base',
+ '../content/content.gyp:content_common',
+ '../ipc/ipc.gyp:ipc',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'translate/content/common/translate_messages.cc',
+ 'translate/content/common/translate_messages.h',
+ ],
+ },
],
}],
],
diff --git a/components/translate/content/common/translate_messages.cc b/components/translate/content/common/translate_messages.cc
new file mode 100644
index 0000000..459248a
--- /dev/null
+++ b/components/translate/content/common/translate_messages.cc
@@ -0,0 +1,33 @@
+// Copyright 2014 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.
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "components/translate/content/common/translate_messages.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "components/translate/content/common/translate_messages.h"
+
+// Generate destructors.
+#include "ipc/struct_destructor_macros.h"
+#include "components/translate/content/common/translate_messages.h"
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+namespace IPC {
+#include "components/translate/content/common/translate_messages.h"
+} // namespace IPC
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+namespace IPC {
+#include "components/translate/content/common/translate_messages.h"
+} // namespace IPC
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+namespace IPC {
+#include "components/translate/content/common/translate_messages.h"
+} // namespace IPC
diff --git a/components/translate/content/common/translate_messages.h b/components/translate/content/common/translate_messages.h
new file mode 100644
index 0000000..f14efff
--- /dev/null
+++ b/components/translate/content/common/translate_messages.h
@@ -0,0 +1,81 @@
+// Copyright 2014 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, hence no include guard.
+
+#include "components/translate/core/common/language_detection_details.h"
+#include "components/translate/core/common/translate_errors.h"
+#include "content/public/common/common_param_traits.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_message_utils.h"
+
+#define IPC_MESSAGE_START TranslateMsgStart
+
+IPC_ENUM_TRAITS(TranslateErrors::Type)
+
+IPC_STRUCT_TRAITS_BEGIN(LanguageDetectionDetails)
+ IPC_STRUCT_TRAITS_MEMBER(time)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(content_language)
+ IPC_STRUCT_TRAITS_MEMBER(cld_language)
+ IPC_STRUCT_TRAITS_MEMBER(is_cld_reliable)
+ IPC_STRUCT_TRAITS_MEMBER(html_root_language)
+ IPC_STRUCT_TRAITS_MEMBER(adopted_language)
+ IPC_STRUCT_TRAITS_MEMBER(contents)
+IPC_STRUCT_TRAITS_END()
+
+//-----------------------------------------------------------------------------
+// RenderView messages
+// These are messages sent from the browser to the renderer process.
+
+// Tells the renderer to translate the page contents from one language to
+// another.
+IPC_MESSAGE_ROUTED4(ChromeViewMsg_TranslatePage,
+ int /* page id */,
+ std::string, /* the script injected in the page */
+ std::string, /* BCP 47/RFC 5646 language code the page
+ is in */
+ std::string /* BCP 47/RFC 5646 language code to translate
+ to */)
+
+#if defined(CLD2_DYNAMIC_MODE)
+// Informs the renderer process that Compact Language Detector (CLD) data is
+// available and provides an IPC::PlatformFileForTransit obtained from
+// IPC::GetFileHandleForProcess(...)
+// See also: ChromeViewHostMsg_NeedCLDData
+IPC_MESSAGE_ROUTED3(ChromeViewMsg_CLDDataAvailable,
+ IPC::PlatformFileForTransit /* ipc_file_handle */,
+ uint64 /* data_offset */,
+ uint64 /* data_length */)
+#endif
+
+//-----------------------------------------------------------------------------
+// Misc messages
+// These are messages sent from the renderer to the browser process.
+
+// Notification that the language for the tab has been determined.
+IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_TranslateLanguageDetermined,
+ LanguageDetectionDetails /* details about lang detection */,
+ bool /* whether the page needs translation */)
+
+// Notifies the browser that a page has been translated.
+IPC_MESSAGE_ROUTED4(ChromeViewHostMsg_PageTranslated,
+ int, /* page id */
+ std::string /* the original language */,
+ std::string /* the translated language */,
+ TranslateErrors::Type /* the error type if available */)
+
+// Tells the renderer to revert the text of translated page to its original
+// contents.
+IPC_MESSAGE_ROUTED1(ChromeViewMsg_RevertTranslation,
+ int /* page id */)
+
+#if defined(CLD2_DYNAMIC_MODE)
+// Informs the browser process that Compact Language Detector (CLD) data is
+// required by the originating renderer. The browser process should respond
+// with a ChromeViewMsg_CLDDataAvailable if the data is available, else it
+// should go unanswered (the renderer will ask again later).
+// See also: ChromeViewMsg_CLDDataAvailable
+IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_NeedCLDData)
+#endif