Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / spellchecker / spellcheck_message_filter_mac.h
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 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_
7
8 #include <map>
9
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"
13
14 // A message filter implementation that receives
15 // the Mac-specific spell checker requests from SpellCheckProvider.
16 class SpellCheckMessageFilterMac : public content::BrowserMessageFilter {
17  public:
18   explicit SpellCheckMessageFilterMac(int render_process_id);
19
20   // BrowserMessageFilter implementation.
21   void OverrideThreadForMessage(const IPC::Message& message,
22                                 content::BrowserThread::ID* thread) override;
23   bool OnMessageReceived(const IPC::Message& message) override;
24
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);
31
32  private:
33   friend class TestingSpellCheckMessageFilter;
34   friend class SpellcheckMessageFilterMacTest;
35
36   ~SpellCheckMessageFilterMac() override;
37
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,
44                           int identifier,
45                           const base::string16& text,
46                           std::vector<SpellCheckMarker> markers);
47
48   int ToDocumentTag(int route_id);
49   void RetireDocumentTag(int route_id);
50   std::map<int,int> tag_map_;
51
52   int render_process_id_;
53
54   // A JSON-RPC client that calls the Spelling service in the background.
55   scoped_ptr<SpellingServiceClient> client_;
56
57   DISALLOW_COPY_AND_ASSIGN(SpellCheckMessageFilterMac);
58 };
59
60 #endif  // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_