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 #if !defined(ENABLE_SPELLCHECK) 14 #error "Spellcheck should be enabled" 15 #endif 16 17 #define IPC_MESSAGE_START SpellCheckMsgStart 18 19 IPC_ENUM_TRAITS(SpellCheckResult::Decoration) 20 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() 28 29 IPC_STRUCT_TRAITS_BEGIN(SpellCheckMarker) 30 IPC_STRUCT_TRAITS_MEMBER(hash) 31 IPC_STRUCT_TRAITS_MEMBER(offset) 32 IPC_STRUCT_TRAITS_END() 33 34 // Messages sent from the browser to the renderer. 35 36 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableSpellCheck, 37 bool) 38 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 */) 47 48 // Words have been added and removed in the custom dictionary; update the local 49 // custom word list. 50 IPC_MESSAGE_CONTROL2(SpellCheckMsg_CustomDictionaryChanged, 51 std::vector<std::string> /* words_added */, 52 std::vector<std::string> /* words_removed */) 53 54 // Toggle the auto spell correct functionality. 55 IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect, 56 bool /* enable */) 57 58 // Request a list of all document markers in the renderer for spelling service 59 // feedback. 60 IPC_MESSAGE_CONTROL0(SpellCheckMsg_RequestDocumentMarkers) 61 62 // Send a list of document markers in the renderer to the spelling service 63 // feedback sender. 64 IPC_MESSAGE_CONTROL1(SpellCheckHostMsg_RespondDocumentMarkers, 65 std::vector<uint32> /* document marker identifiers */) 66 67 #if !defined(OS_MACOSX) 68 // Sends text-check results from the Spelling service when the service finishes 69 // checking text received by a SpellCheckHostMsg_CallSpellingService message. 70 // If the service is not available, the 4th parameter should be false and the 71 // 5th parameter should contain the requested sentence. 72 IPC_MESSAGE_ROUTED4(SpellCheckMsg_RespondSpellingService, 73 int /* request identifier given by WebKit */, 74 bool /* succeeded calling service */, 75 base::string16 /* sentence */, 76 std::vector<SpellCheckResult>) 77 #endif 78 79 #if defined(OS_MACOSX) 80 // This message tells the renderer to advance to the next misspelling. It is 81 // sent when the user clicks the "Find Next" button on the spelling panel. 82 IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling) 83 84 // Sends when NSSpellChecker finishes checking text received by a preceding 85 // SpellCheckHostMsg_RequestTextCheck message. 86 IPC_MESSAGE_ROUTED2(SpellCheckMsg_RespondTextCheck, 87 int /* request identifier given by WebKit */, 88 std::vector<SpellCheckResult>) 89 90 IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel, 91 bool) 92 #endif 93 94 // Messages sent from the renderer to the browser. 95 96 // The renderer has tried to spell check a word, but couldn't because no 97 // dictionary was available to load. Request that the browser find an 98 // appropriate dictionary and return it. 99 IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary) 100 101 // Tracks spell checking occurrence to collect histogram. 102 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_NotifyChecked, 103 base::string16 /* word */, 104 bool /* true if checked word is misspelled */) 105 106 #if !defined(OS_MACOSX) 107 // Asks the Spelling service to check text. When the service finishes checking 108 // the input text, it sends a SpellingCheckMsg_RespondSpellingService with 109 // text-check results. 110 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_CallSpellingService, 111 int /* route_id for response */, 112 int /* request identifier given by WebKit */, 113 base::string16 /* sentence */, 114 std::vector<SpellCheckMarker> /* markers */) 115 #endif 116 117 #if defined(OS_MACOSX) 118 // Tells the browser to display or not display the SpellingPanel 119 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel, 120 bool /* if true, then show it, otherwise hide it*/) 121 122 // Tells the browser to update the spelling panel with the given word. 123 IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord, 124 base::string16 /* the word to update the panel with */) 125 126 // TODO(groby): This needs to originate from SpellcheckProvider. 127 IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_CheckSpelling, 128 base::string16 /* word */, 129 int /* route_id */, 130 bool /* correct */) 131 132 IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_FillSuggestionList, 133 base::string16 /* word */, 134 std::vector<base::string16> /* suggestions */) 135 136 IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_RequestTextCheck, 137 int /* route_id for response */, 138 int /* request identifier given by WebKit */, 139 base::string16 /* sentence */, 140 std::vector<SpellCheckMarker> /* markers */) 141 142 IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck, 143 bool /* enabled */, 144 bool /* checked */) 145 #endif // OS_MACOSX 146