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.
5 // IPC messages for spellcheck.
6 // Multiply-included message file, hence no include guard.
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"
13 #if !defined(ENABLE_SPELLCHECK)
14 #error "Spellcheck should be enabled"
17 #define IPC_MESSAGE_START SpellCheckMsgStart
19 IPC_ENUM_TRAITS(SpellCheckResult::Decoration
)
21 IPC_STRUCT_TRAITS_BEGIN(SpellCheckResult
)
22 IPC_STRUCT_TRAITS_MEMBER(decoration
)
23 IPC_STRUCT_TRAITS_MEMBER(location
)
24 IPC_STRUCT_TRAITS_MEMBER(length
)
25 IPC_STRUCT_TRAITS_MEMBER(replacement
)
26 IPC_STRUCT_TRAITS_MEMBER(hash
)
27 IPC_STRUCT_TRAITS_END()
29 IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker
)
30 IPC_STRUCT_TRAITS_MEMBER(hash
)
31 IPC_STRUCT_TRAITS_MEMBER(offset
)
32 IPC_STRUCT_TRAITS_END()
34 // Messages sent from the browser to the renderer.
36 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck
,
39 // Passes some initialization params from the browser to the renderer's
40 // spellchecker. This can be called directly after startup or in (async)
41 // response to a RequestDictionary ViewHost message.
42 IPC_MESSAGE_CONTROL4(SpellCheckMsg_Init
,
43 IPC::PlatformFileForTransit
/* bdict_file */,
44 std::set
<std::string
> /* custom_dict_words */,
45 std::string
/* language */,
46 bool /* auto spell correct */)
48 // Words have been added and removed in the custom dictionary; update the local
50 IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged
,
51 std::vector
<std::string
> /* words_added */,
52 std::vector
<std::string
> /* words_removed */)
54 // Toggle the auto spell correct functionality.
55 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect
,
58 #if !defined(OS_MACOSX)
59 // Sends text-check results from the Spelling service when the service finishes
60 // checking text received by a SpellCheckHostMsg_CallSpellingService message.
61 // If the service is not available, the 4th parameter should be false and the
62 // 5th parameter should contain the requested sentence.
63 IPC_MESSAGE_ROUTED4(SpellCheckMsg_RespondSpellingService
,
64 int /* request identifier given by WebKit */,
65 bool /* succeeded calling service */,
66 base::string16
/* sentence */,
67 std::vector
<SpellCheckResult
>)
70 #if defined(OS_MACOSX)
71 // This message tells the renderer to advance to the next misspelling. It is
72 // sent when the user clicks the "Find Next" button on the spelling panel.
73 IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling
)
75 // Sends when NSSpellChecker finishes checking text received by a preceding
76 // SpellCheckHostMsg_RequestTextCheck message.
77 IPC_MESSAGE_ROUTED2(SpellCheckMsg_RespondTextCheck
,
78 int /* request identifier given by WebKit */,
79 std::vector
<SpellCheckResult
>)
81 IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel
,
85 // Messages sent from the renderer to the browser.
87 // The renderer has tried to spell check a word, but couldn't because no
88 // dictionary was available to load. Request that the browser find an
89 // appropriate dictionary and return it.
90 IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary
)
92 // Tracks spell checking occurrence to collect histogram.
93 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked
,
94 base::string16
/* word */,
95 bool /* true if checked word is misspelled */)
97 #if !defined(OS_MACOSX)
98 // Asks the Spelling service to check text. When the service finishes checking
99 // the input text, it sends a SpellingCheckMsg_RespondSpellingService with
100 // text-check results.
101 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_CallSpellingService
,
102 int /* route_id for response */,
103 int /* request identifier given by WebKit */,
104 base::string16
/* sentence */,
105 std::vector
<SpellCheckMarker
> /* markers */)
108 #if defined(OS_MACOSX)
109 // Tells the browser to display or not display the SpellingPanel
110 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel
,
111 bool /* if true, then show it, otherwise hide it*/)
113 // Tells the browser to update the spelling panel with the given word.
114 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord
,
115 base::string16
/* the word to update the panel with */)
117 // TODO(groby): This needs to originate from SpellcheckProvider.
118 IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling
,
119 base::string16
/* word */,
123 IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList
,
124 base::string16
/* word */,
125 std::vector
<base::string16
> /* suggestions */)
127 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck
,
128 int /* route_id for response */,
129 int /* request identifier given by WebKit */,
130 base::string16
/* sentence */,
131 std::vector
<SpellCheckMarker
> /* markers */)
133 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck
,