| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ |
| 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" | 10 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
| 11 #include "chrome/common/spellcheck_result.h" | 11 #include "chrome/common/spellcheck_result.h" |
| 12 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
| 13 | 13 |
| 14 // A message filter implementation that receives | 14 // A message filter implementation that receives |
| 15 // the Mac-specific spell checker requests from SpellCheckProvider. | 15 // the Mac-specific spell checker requests from SpellCheckProvider. |
| 16 class SpellCheckMessageFilterMac : public content::BrowserMessageFilter { | 16 class SpellCheckMessageFilterMac : public content::BrowserMessageFilter { |
| 17 public: | 17 public: |
| 18 explicit SpellCheckMessageFilterMac(int render_process_id); | 18 explicit SpellCheckMessageFilterMac(int render_process_id); |
| 19 | 19 |
| 20 // BrowserMessageFilter implementation. | 20 // BrowserMessageFilter implementation. |
| 21 virtual void OverrideThreadForMessage( | 21 void OverrideThreadForMessage(const IPC::Message& message, |
| 22 const IPC::Message& message, | 22 content::BrowserThread::ID* thread) override; |
| 23 content::BrowserThread::ID* thread) override; | 23 bool OnMessageReceived(const IPC::Message& message) override; |
| 24 virtual bool OnMessageReceived(const IPC::Message& message) override; | |
| 25 | 24 |
| 26 // Adjusts remote_results by examining local_results. Any result that's both | 25 // Adjusts remote_results by examining local_results. Any result that's both |
| 27 // local and remote stays type SPELLING, all others are flagged GRAMMAR. | 26 // local and remote stays type SPELLING, all others are flagged GRAMMAR. |
| 28 // (This is needed to force gray underline for remote-only results.) | 27 // (This is needed to force gray underline for remote-only results.) |
| 29 static void CombineResults( | 28 static void CombineResults( |
| 30 std::vector<SpellCheckResult>* remote_results, | 29 std::vector<SpellCheckResult>* remote_results, |
| 31 const std::vector<SpellCheckResult>& local_results); | 30 const std::vector<SpellCheckResult>& local_results); |
| 32 | 31 |
| 33 private: | 32 private: |
| 34 friend class TestingSpellCheckMessageFilter; | 33 friend class TestingSpellCheckMessageFilter; |
| 35 friend class SpellcheckMessageFilterMacTest; | 34 friend class SpellcheckMessageFilterMacTest; |
| 36 | 35 |
| 37 virtual ~SpellCheckMessageFilterMac(); | 36 ~SpellCheckMessageFilterMac() override; |
| 38 | 37 |
| 39 void OnCheckSpelling(const base::string16& word, int route_id, bool* correct); | 38 void OnCheckSpelling(const base::string16& word, int route_id, bool* correct); |
| 40 void OnFillSuggestionList(const base::string16& word, | 39 void OnFillSuggestionList(const base::string16& word, |
| 41 std::vector<base::string16>* suggestions); | 40 std::vector<base::string16>* suggestions); |
| 42 void OnShowSpellingPanel(bool show); | 41 void OnShowSpellingPanel(bool show); |
| 43 void OnUpdateSpellingPanelWithMisspelledWord(const base::string16& word); | 42 void OnUpdateSpellingPanelWithMisspelledWord(const base::string16& word); |
| 44 void OnRequestTextCheck(int route_id, | 43 void OnRequestTextCheck(int route_id, |
| 45 int identifier, | 44 int identifier, |
| 46 const base::string16& text, | 45 const base::string16& text, |
| 47 std::vector<SpellCheckMarker> markers); | 46 std::vector<SpellCheckMarker> markers); |
| 48 | 47 |
| 49 int ToDocumentTag(int route_id); | 48 int ToDocumentTag(int route_id); |
| 50 void RetireDocumentTag(int route_id); | 49 void RetireDocumentTag(int route_id); |
| 51 std::map<int,int> tag_map_; | 50 std::map<int,int> tag_map_; |
| 52 | 51 |
| 53 int render_process_id_; | 52 int render_process_id_; |
| 54 | 53 |
| 55 // A JSON-RPC client that calls the Spelling service in the background. | 54 // A JSON-RPC client that calls the Spelling service in the background. |
| 56 scoped_ptr<SpellingServiceClient> client_; | 55 scoped_ptr<SpellingServiceClient> client_; |
| 57 | 56 |
| 58 DISALLOW_COPY_AND_ASSIGN(SpellCheckMessageFilterMac); | 57 DISALLOW_COPY_AND_ASSIGN(SpellCheckMessageFilterMac); |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ | 60 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_MESSAGE_FILTER_MAC_H_ |
| OLD | NEW |