Home | History | Annotate | Download | only in common
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Multiply-included message file, hence no include guard.
      6 
      7 #include "components/translate/core/common/language_detection_details.h"
      8 #include "components/translate/core/common/translate_errors.h"
      9 #include "content/public/common/common_param_traits.h"
     10 #include "ipc/ipc_message_macros.h"
     11 #include "ipc/ipc_message_utils.h"
     12 
     13 #if defined(CLD2_DYNAMIC_MODE)
     14 #include "ipc/ipc_platform_file.h"
     15 #endif
     16 
     17 #define IPC_MESSAGE_START TranslateMsgStart
     18 
     19 IPC_ENUM_TRAITS(TranslateErrors::Type)
     20 
     21 IPC_STRUCT_TRAITS_BEGIN(LanguageDetectionDetails)
     22   IPC_STRUCT_TRAITS_MEMBER(time)
     23   IPC_STRUCT_TRAITS_MEMBER(url)
     24   IPC_STRUCT_TRAITS_MEMBER(content_language)
     25   IPC_STRUCT_TRAITS_MEMBER(cld_language)
     26   IPC_STRUCT_TRAITS_MEMBER(is_cld_reliable)
     27   IPC_STRUCT_TRAITS_MEMBER(html_root_language)
     28   IPC_STRUCT_TRAITS_MEMBER(adopted_language)
     29   IPC_STRUCT_TRAITS_MEMBER(contents)
     30 IPC_STRUCT_TRAITS_END()
     31 
     32 //-----------------------------------------------------------------------------
     33 // RenderView messages
     34 // These are messages sent from the browser to the renderer process.
     35 
     36 // Tells the renderer to translate the page contents from one language to
     37 // another.
     38 IPC_MESSAGE_ROUTED4(ChromeViewMsg_TranslatePage,
     39                     int /* page id */,
     40                     std::string, /* the script injected in the page */
     41                     std::string, /* BCP 47/RFC 5646 language code the page
     42                                     is in */
     43                     std::string /* BCP 47/RFC 5646 language code to translate
     44                                    to */)
     45 
     46 #if defined(CLD2_DYNAMIC_MODE)
     47 // Informs the renderer process that Compact Language Detector (CLD) data is
     48 // available and provides an IPC::PlatformFileForTransit obtained from
     49 // IPC::GetFileHandleForProcess(...)
     50 // See also: ChromeViewHostMsg_NeedCLDData
     51 IPC_MESSAGE_ROUTED3(ChromeViewMsg_CLDDataAvailable,
     52                     IPC::PlatformFileForTransit /* ipc_file_handle */,
     53                     uint64 /* data_offset */,
     54                     uint64 /* data_length */)
     55 #endif
     56 
     57 //-----------------------------------------------------------------------------
     58 // Misc messages
     59 // These are messages sent from the renderer to the browser process.
     60 
     61 // Notification that the language for the tab has been determined.
     62 IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_TranslateLanguageDetermined,
     63                     LanguageDetectionDetails /* details about lang detection */,
     64                     bool /* whether the page needs translation */)
     65 
     66 // Notifies the browser that a page has been translated.
     67 IPC_MESSAGE_ROUTED4(ChromeViewHostMsg_PageTranslated,
     68                     int,                  /* page id */
     69                     std::string           /* the original language */,
     70                     std::string           /* the translated language */,
     71                     TranslateErrors::Type /* the error type if available */)
     72 
     73 // Tells the renderer to revert the text of translated page to its original
     74 // contents.
     75 IPC_MESSAGE_ROUTED1(ChromeViewMsg_RevertTranslation,
     76                     int /* page id */)
     77 
     78 #if defined(CLD2_DYNAMIC_MODE)
     79 // Informs the browser process that Compact Language Detector (CLD) data is
     80 // required by the originating renderer. The browser process should respond
     81 // with a ChromeViewMsg_CLDDataAvailable if the data is available, else it
     82 // should go unanswered (the renderer will ask again later).
     83 // See also: ChromeViewMsg_CLDDataAvailable
     84 IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_NeedCLDData)
     85 #endif
     86