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 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_
10 #include "chrome/browser/spellchecker/spellcheck_message_filter.h"
11 #include "chrome/common/spellcheck_result.h"
12 #include "content/public/browser/browser_message_filter.h"
14 // A message filter implementation that receives
15 // the Mac-specific spell checker requests from SpellCheckProvider.
16 class SpellCheckMessageFilterMac : public content::BrowserMessageFilter {
18 explicit SpellCheckMessageFilterMac(int render_process_id);
20 // BrowserMessageFilter implementation.
21 void OverrideThreadForMessage(const IPC::Message& message,
22 content::BrowserThread::ID* thread) override;
23 bool OnMessageReceived(const IPC::Message& message) override;
25 // Adjusts remote_results by examining local_results. Any result that's both
26 // local and remote stays type SPELLING, all others are flagged GRAMMAR.
27 // (This is needed to force gray underline for remote-only results.)
28 static void CombineResults(
29 std::vector<SpellCheckResult>* remote_results,
30 const std::vector<SpellCheckResult>& local_results);
33 friend class TestingSpellCheckMessageFilter;
34 friend class SpellcheckMessageFilterMacTest;
36 ~SpellCheckMessageFilterMac() override;
38 void OnCheckSpelling(const base::string16& word, int route_id, bool* correct);
39 void OnFillSuggestionList(const base::string16& word,
40 std::vector<base::string16>* suggestions);
41 void OnShowSpellingPanel(bool show);
42 void OnUpdateSpellingPanelWithMisspelledWord(const base::string16& word);
43 void OnRequestTextCheck(int route_id,
45 const base::string16& text,
46 std::vector<SpellCheckMarker> markers);
48 int ToDocumentTag(int route_id);
49 void RetireDocumentTag(int route_id);
50 std::map<int,int> tag_map_;
52 int render_process_id_;
54 // A JSON-RPC client that calls the Spelling service in the background.
55 scoped_ptr<SpellingServiceClient> client_;
57 DISALLOW_COPY_AND_ASSIGN(SpellCheckMessageFilterMac);
60 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_