15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// IPC messages for spellcheck.
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Multiply-included message file, hence no include guard.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/common/spellcheck_marker.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/spellcheck_result.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_message_macros.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_platform_file.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(ENABLE_SPELLCHECK)
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#error "Spellcheck should be enabled"
15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_START SpellCheckMsgStart
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)IPC_ENUM_TRAITS(SpellCheckResult::Decoration)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(SpellCheckResult)
224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(decoration)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(location)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(length)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(replacement)
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(hash)
2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_STRUCT_TRAITS_END()
2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker)
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(hash)
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(offset)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END()
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Messages sent from the browser to the renderer.
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck,
37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                     bool)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Passes some initialization params from the browser to the renderer's
4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// spellchecker. This can be called directly after startup or in (async)
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// response to a RequestDictionary ViewHost message.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckMsg_Init,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     IPC::PlatformFileForTransit /* bdict_file */,
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                     std::set<std::string> /* custom_dict_words */,
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     std::string /* language */,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     bool /* auto spell correct */)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Words have been added and removed in the custom dictionary; update the local
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// custom word list.
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged,
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     std::vector<std::string> /* words_added */,
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     std::vector<std::string> /* words_removed */)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Toggle the auto spell correct functionality.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect,
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     bool /* enable */)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Request a list of all document markers in the renderer for spelling service
59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// feedback.
60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_CONTROL0(SpellCheckMsg_RequestDocumentMarkers)
61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Send a list of document markers in the renderer to the spelling service
63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// feedback sender.
64c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckHostMsg_RespondDocumentMarkers,
65c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                     std::vector<uint32> /* document marker identifiers */)
66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_MACOSX)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sends text-check results from the Spelling service when the service finishes
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// checking text received by a SpellCheckHostMsg_CallSpellingService message.
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// If the service is not available, the 4th parameter should be false and the
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// 5th parameter should contain the requested sentence.
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_ROUTED4(SpellCheckMsg_RespondSpellingService,
73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                    int             /* request identifier given by WebKit */,
74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                    bool            /* succeeded calling service */,
75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                    base::string16  /* sentence */,
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    std::vector<SpellCheckResult>)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This message tells the renderer to advance to the next misspelling. It is
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sent when the user clicks the "Find Next" button on the spelling panel.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling)
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Sends when NSSpellChecker finishes checking text received by a preceding
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SpellCheckHostMsg_RequestTextCheck message.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckMsg_RespondTextCheck,
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    int        /* request identifier given by WebKit */,
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    std::vector<SpellCheckResult>)
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel,
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    bool)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Messages sent from the renderer to the browser.
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The renderer has tried to spell check a word, but couldn't because no
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// dictionary was available to load. Request that the browser find an
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// appropriate dictionary and return it.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tracks spell checking occurrence to collect histogram.
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked,
103a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                    base::string16 /* word */,
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    bool /* true if checked word is misspelled */)
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_MACOSX)
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Asks the Spelling service to check text. When the service finishes checking
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the input text, it sends a SpellingCheckMsg_RespondSpellingService with
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// text-check results.
11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_CallSpellingService,
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int /* route_id for response */,
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int /* request identifier given by WebKit */,
113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                     base::string16 /* sentence */,
11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                     std::vector<SpellCheckMarker> /* markers */)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the browser to display or not display the SpellingPanel
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel,
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    bool /* if true, then show it, otherwise hide it*/)
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the browser to update the spelling panel with the given word.
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord,
124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                    base::string16 /* the word to update the panel with */)
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(groby): This needs to originate from SpellcheckProvider.
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling,
128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            base::string16 /* word */,
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int /* route_id */,
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            bool /* correct */)
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList,
133a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            base::string16 /* word */,
134a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            std::vector<base::string16> /* suggestions */)
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck,
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int /* route_id for response */,
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int /* request identifier given by WebKit */,
139a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                     base::string16 /* sentence */,
140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                     std::vector<SpellCheckMarker> /* markers */)
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck,
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    bool /* enabled */,
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    bool /* checked */)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_MACOSX
146