- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / spellcheck_messages.h
1 // Copyright (c) 2012 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 // IPC messages for spellcheck.
6 // Multiply-included message file, hence no include guard.
7
8 #include "chrome/common/spellcheck_marker.h"
9 #include "chrome/common/spellcheck_result.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "ipc/ipc_platform_file.h"
12
13
14 #define IPC_MESSAGE_START SpellCheckMsgStart
15
16 IPC_ENUM_TRAITS(SpellCheckResult::Decoration)
17
18 IPC_STRUCT_TRAITS_BEGIN(SpellCheckResult)
19   IPC_STRUCT_TRAITS_MEMBER(decoration)
20   IPC_STRUCT_TRAITS_MEMBER(location)
21   IPC_STRUCT_TRAITS_MEMBER(length)
22   IPC_STRUCT_TRAITS_MEMBER(replacement)
23   IPC_STRUCT_TRAITS_MEMBER(hash)
24 IPC_STRUCT_TRAITS_END()
25
26 IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker)
27   IPC_STRUCT_TRAITS_MEMBER(hash)
28   IPC_STRUCT_TRAITS_MEMBER(offset)
29 IPC_STRUCT_TRAITS_END()
30
31 // Messages sent from the browser to the renderer.
32
33 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck,
34                      bool)
35
36 // Passes some initialization params from the browser to the renderer's
37 // spellchecker. This can be called directly after startup or in (async)
38 // response to a RequestDictionary ViewHost message.
39 IPC_MESSAGE_CONTROL4(SpellCheckMsg_Init,
40                      IPC::PlatformFileForTransit /* bdict_file */,
41                      std::set<std::string> /* custom_dict_words */,
42                      std::string /* language */,
43                      bool /* auto spell correct */)
44
45 // Words have been added and removed in the custom dictionary; update the local
46 // custom word list.
47 IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged,
48                      std::vector<std::string> /* words_added */,
49                      std::vector<std::string> /* words_removed */)
50
51 // Toggle the auto spell correct functionality.
52 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect,
53                      bool /* enable */)
54
55 // Request a list of all document markers in the renderer for spelling service
56 // feedback.
57 IPC_MESSAGE_CONTROL0(SpellCheckMsg_RequestDocumentMarkers)
58
59 // Send a list of document markers in the renderer to the spelling service
60 // feedback sender.
61 IPC_MESSAGE_CONTROL1(SpellCheckHostMsg_RespondDocumentMarkers,
62                      std::vector<uint32> /* document marker identifiers */)
63
64 #if !defined(OS_MACOSX)
65 // Sends text-check results from the Spelling service when the service finishes
66 // checking text received by a SpellCheckHostMsg_CallSpellingService message.
67 // If the service is not available, the 4th parameter should be false and the
68 // 5th parameter should contain the requested sentence.
69 IPC_MESSAGE_ROUTED4(SpellCheckMsg_RespondSpellingService,
70                     int         /* request identifier given by WebKit */,
71                     bool        /* succeeded calling service */,
72                     string16    /* sentence */,
73                     std::vector<SpellCheckResult>)
74 #endif
75
76 #if defined(OS_MACOSX)
77 // This message tells the renderer to advance to the next misspelling. It is
78 // sent when the user clicks the "Find Next" button on the spelling panel.
79 IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling)
80
81 // Sends when NSSpellChecker finishes checking text received by a preceding
82 // SpellCheckHostMsg_RequestTextCheck message.
83 IPC_MESSAGE_ROUTED2(SpellCheckMsg_RespondTextCheck,
84                     int        /* request identifier given by WebKit */,
85                     std::vector<SpellCheckResult>)
86
87 IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel,
88                     bool)
89 #endif
90
91 // Messages sent from the renderer to the browser.
92
93 // The renderer has tried to spell check a word, but couldn't because no
94 // dictionary was available to load. Request that the browser find an
95 // appropriate dictionary and return it.
96 IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary)
97
98 // Tracks spell checking occurrence to collect histogram.
99 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked,
100                     string16 /* word */,
101                     bool /* true if checked word is misspelled */)
102
103 #if !defined(OS_MACOSX)
104 // Asks the Spelling service to check text. When the service finishes checking
105 // the input text, it sends a SpellingCheckMsg_RespondSpellingService with
106 // text-check results.
107 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_CallSpellingService,
108                      int /* route_id for response */,
109                      int /* request identifier given by WebKit */,
110                      string16 /* sentence */,
111                      std::vector<SpellCheckMarker> /* markers */)
112 #endif
113
114 #if defined(OS_MACOSX)
115 // Tells the browser to display or not display the SpellingPanel
116 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel,
117                     bool /* if true, then show it, otherwise hide it*/)
118
119 // Tells the browser to update the spelling panel with the given word.
120 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord,
121                     string16 /* the word to update the panel with */)
122
123 // TODO(groby): This needs to originate from SpellcheckProvider.
124 IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling,
125                             string16 /* word */,
126                             int /* route_id */,
127                             bool /* correct */)
128
129 IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList,
130                             string16 /* word */,
131                             std::vector<string16> /* suggestions */)
132
133 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck,
134                      int /* route_id for response */,
135                      int /* request identifier given by WebKit */,
136                      string16 /* sentence */,
137                      std::vector<SpellCheckMarker> /* markers */)
138
139 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck,
140                     bool /* enabled */,
141                     bool /* checked */)
142 #endif  // OS_MACOSX