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) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_START SpellCheckMsgStart 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)IPC_ENUM_TRAITS(SpellCheckResult::Decoration) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(SpellCheckResult) 194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(decoration) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(location) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(length) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(replacement) 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(hash) 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_STRUCT_TRAITS_END() 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker) 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(hash) 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(offset) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END() 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Messages sent from the browser to the renderer. 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck, 34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Passes some initialization params from the browser to the renderer's 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// spellchecker. This can be called directly after startup or in (async) 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// response to a RequestDictionary ViewHost message. 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckMsg_Init, 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC::PlatformFileForTransit /* bdict_file */, 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::set<std::string> /* custom_dict_words */, 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string /* language */, 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* auto spell correct */) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Words have been added and removed in the custom dictionary; update the local 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// custom word list. 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged, 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::vector<std::string> /* words_added */, 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::vector<std::string> /* words_removed */) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Toggle the auto spell correct functionality. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect, 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* enable */) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Request a list of all document markers in the renderer for spelling service 56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// feedback. 57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_CONTROL0(SpellCheckMsg_RequestDocumentMarkers) 58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Send a list of document markers in the renderer to the spelling service 60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// feedback sender. 61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_CONTROL1(SpellCheckHostMsg_RespondDocumentMarkers, 62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::vector<uint32> /* document marker identifiers */) 63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_MACOSX) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sends text-check results from the Spelling service when the service finishes 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// checking text received by a SpellCheckHostMsg_CallSpellingService message. 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// If the service is not available, the 4th parameter should be false and the 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// 5th parameter should contain the requested sentence. 69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IPC_MESSAGE_ROUTED4(SpellCheckMsg_RespondSpellingService, 70a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int /* request identifier given by WebKit */, 71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool /* succeeded calling service */, 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* sentence */, 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<SpellCheckResult>) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This message tells the renderer to advance to the next misspelling. It is 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sent when the user clicks the "Find Next" button on the spelling panel. 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling) 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Sends when NSSpellChecker finishes checking text received by a preceding 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SpellCheckHostMsg_RequestTextCheck message. 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckMsg_RespondTextCheck, 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request identifier given by WebKit */, 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<SpellCheckResult>) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel, 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Messages sent from the renderer to the browser. 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The renderer has tried to spell check a word, but couldn't because no 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// dictionary was available to load. Request that the browser find an 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// appropriate dictionary and return it. 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tracks spell checking occurrence to collect histogram. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked, 100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* word */, 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* true if checked word is misspelled */) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_MACOSX) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Asks the Spelling service to check text. When the service finishes checking 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the input text, it sends a SpellingCheckMsg_RespondSpellingService with 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// text-check results. 10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_CallSpellingService, 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* route_id for response */, 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request identifier given by WebKit */, 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* sentence */, 11190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<SpellCheckMarker> /* markers */) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the browser to display or not display the SpellingPanel 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel, 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* if true, then show it, otherwise hide it*/) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the browser to update the spelling panel with the given word. 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord, 121a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* the word to update the panel with */) 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(groby): This needs to originate from SpellcheckProvider. 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling, 125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* word */, 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* route_id */, 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* correct */) 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList, 130a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* word */, 131a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) std::vector<base::string16> /* suggestions */) 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck, 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* route_id for response */, 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request identifier given by WebKit */, 136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 /* sentence */, 137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) std::vector<SpellCheckMarker> /* markers */) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck, 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* enabled */, 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool /* checked */) 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // OS_MACOSX 143