1// Copyright (c) 2011 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#include "chrome/browser/spellcheck_message_filter.h" 6 7#include "chrome/browser/spellchecker_platform_engine.h" 8#include "chrome/common/spellcheck_messages.h" 9 10SpellCheckMessageFilter::SpellCheckMessageFilter() { 11} 12 13SpellCheckMessageFilter::~SpellCheckMessageFilter() { 14} 15 16bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message, 17 bool* message_was_ok) { 18 bool handled = true; 19 IPC_BEGIN_MESSAGE_MAP_EX(SpellCheckMessageFilter, message, *message_was_ok) 20 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformCheckSpelling, 21 OnPlatformCheckSpelling) 22 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformFillSuggestionList, 23 OnPlatformFillSuggestionList) 24 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_GetDocumentTag, OnGetDocumentTag) 25 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_DocumentWithTagClosed, 26 OnDocumentWithTagClosed) 27 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_ShowSpellingPanel, 28 OnShowSpellingPanel) 29 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord, 30 OnUpdateSpellingPanelWithMisspelledWord) 31 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformRequestTextCheck, 32 OnPlatformRequestTextCheck) 33 IPC_MESSAGE_UNHANDLED(handled = false) 34 IPC_END_MESSAGE_MAP() 35 return handled; 36} 37 38void SpellCheckMessageFilter::OnPlatformCheckSpelling(const string16& word, 39 int tag, 40 bool* correct) { 41 *correct = SpellCheckerPlatform::CheckSpelling(word, tag); 42} 43 44void SpellCheckMessageFilter::OnPlatformFillSuggestionList( 45 const string16& word, 46 std::vector<string16>* suggestions) { 47 SpellCheckerPlatform::FillSuggestionList(word, suggestions); 48} 49 50void SpellCheckMessageFilter::OnGetDocumentTag(int* tag) { 51 *tag = SpellCheckerPlatform::GetDocumentTag(); 52} 53 54void SpellCheckMessageFilter::OnDocumentWithTagClosed(int tag) { 55 SpellCheckerPlatform::CloseDocumentWithTag(tag); 56} 57 58void SpellCheckMessageFilter::OnShowSpellingPanel(bool show) { 59 SpellCheckerPlatform::ShowSpellingPanel(show); 60} 61 62void SpellCheckMessageFilter::OnUpdateSpellingPanelWithMisspelledWord( 63 const string16& word) { 64 SpellCheckerPlatform::UpdateSpellingPanelWithMisspelledWord(word); 65} 66 67void SpellCheckMessageFilter::OnPlatformRequestTextCheck( 68 int route_id, 69 int identifier, 70 int document_tag, 71 const string16& text) { 72 SpellCheckerPlatform::RequestTextCheck( 73 route_id, identifier, document_tag, text, this); 74} 75