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"
14 #define IPC_MESSAGE_START SpellCheckMsgStart
16 IPC_ENUM_TRAITS(SpellCheckResult::Decoration
)
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()
26 IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker
)
27 IPC_STRUCT_TRAITS_MEMBER(hash
)
28 IPC_STRUCT_TRAITS_MEMBER(offset
)
29 IPC_STRUCT_TRAITS_END()
31 // Messages sent from the browser to the renderer.
33 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck
,
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 */)
45 // Words have been added and removed in the custom dictionary; update the local
47 IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged
,
48 std::vector
<std::string
> /* words_added */,
49 std::vector
<std::string
> /* words_removed */)
51 // Toggle the auto spell correct functionality.
52 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect
,
55 // Request a list of all document markers in the renderer for spelling service
57 IPC_MESSAGE_CONTROL0(SpellCheckMsg_RequestDocumentMarkers
)
59 // Send a list of document markers in the renderer to the spelling service
61 IPC_MESSAGE_CONTROL1(SpellCheckHostMsg_RespondDocumentMarkers
,
62 std::vector
<uint32
> /* document marker identifiers */)
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 base::string16
/* sentence */,
73 std::vector
<SpellCheckResult
>)
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
)
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
>)
87 IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel
,
91 // Messages sent from the renderer to the browser.
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
)
98 // Tracks spell checking occurrence to collect histogram.
99 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked
,
100 base::string16
/* word */,
101 bool /* true if checked word is misspelled */)
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 base::string16
/* sentence */,
111 std::vector
<SpellCheckMarker
> /* markers */)
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*/)
119 // Tells the browser to update the spelling panel with the given word.
120 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord
,
121 base::string16
/* the word to update the panel with */)
123 // TODO(groby): This needs to originate from SpellcheckProvider.
124 IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling
,
125 base::string16
/* word */,
129 IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList
,
130 base::string16
/* word */,
131 std::vector
<base::string16
> /* suggestions */)
133 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck
,
134 int /* route_id for response */,
135 int /* request identifier given by WebKit */,
136 base::string16
/* sentence */,
137 std::vector
<SpellCheckMarker
> /* markers */)
139 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck
,