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_SPELLING_SERVICE_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLING_SERVICE_CLIENT_H_ |
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLING_SERVICE_CLIENT_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLING_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 SUGGEST = 1, | 69 SUGGEST = 1, |
70 SPELLCHECK = 2, | 70 SPELLCHECK = 2, |
71 }; | 71 }; |
72 typedef base::Callback<void( | 72 typedef base::Callback<void( |
73 bool /* success */, | 73 bool /* success */, |
74 const base::string16& /* text */, | 74 const base::string16& /* text */, |
75 const std::vector<SpellCheckResult>& /* results */)> | 75 const std::vector<SpellCheckResult>& /* results */)> |
76 TextCheckCompleteCallback; | 76 TextCheckCompleteCallback; |
77 | 77 |
78 SpellingServiceClient(); | 78 SpellingServiceClient(); |
79 virtual ~SpellingServiceClient(); | 79 ~SpellingServiceClient() override; |
80 | 80 |
81 // Sends a text-check request to the Spelling service. When we send a request | 81 // Sends a text-check request to the Spelling service. When we send a request |
82 // to the Spelling service successfully, this function returns true. (This | 82 // to the Spelling service successfully, this function returns true. (This |
83 // does not mean the service finishes checking text successfully.) We will | 83 // does not mean the service finishes checking text successfully.) We will |
84 // call |callback| when we receive a text-check response from the service. | 84 // call |callback| when we receive a text-check response from the service. |
85 bool RequestTextCheck(content::BrowserContext* context, | 85 bool RequestTextCheck(content::BrowserContext* context, |
86 ServiceType type, | 86 ServiceType type, |
87 const base::string16& text, | 87 const base::string16& text, |
88 const TextCheckCompleteCallback& callback); | 88 const TextCheckCompleteCallback& callback); |
89 | 89 |
(...skipping 13 matching lines...) Expand all Loading... |
103 | 103 |
104 // The callback function to be called when we receive a response from the | 104 // The callback function to be called when we receive a response from the |
105 // Spelling service and parse it. | 105 // Spelling service and parse it. |
106 TextCheckCompleteCallback callback; | 106 TextCheckCompleteCallback callback; |
107 | 107 |
108 // The text checked by the Spelling service. | 108 // The text checked by the Spelling service. |
109 base::string16 text; | 109 base::string16 text; |
110 }; | 110 }; |
111 | 111 |
112 // net::URLFetcherDelegate implementation. | 112 // net::URLFetcherDelegate implementation. |
113 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 113 void OnURLFetchComplete(const net::URLFetcher* source) override; |
114 | 114 |
115 // Creates a URLFetcher object used for sending a JSON-RPC request. This | 115 // Creates a URLFetcher object used for sending a JSON-RPC request. This |
116 // function is overridden by unit tests to prevent them from actually sending | 116 // function is overridden by unit tests to prevent them from actually sending |
117 // requests to the Spelling service. | 117 // requests to the Spelling service. |
118 virtual net::URLFetcher* CreateURLFetcher(const GURL& url); | 118 virtual net::URLFetcher* CreateURLFetcher(const GURL& url); |
119 | 119 |
120 // The URLFetcher object used for sending a JSON-RPC request. | 120 // The URLFetcher object used for sending a JSON-RPC request. |
121 std::map<const net::URLFetcher*, TextCheckCallbackData*> spellcheck_fetchers_; | 121 std::map<const net::URLFetcher*, TextCheckCallbackData*> spellcheck_fetchers_; |
122 }; | 122 }; |
123 | 123 |
124 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLING_SERVICE_CLIENT_H_ | 124 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLING_SERVICE_CLIENT_H_ |
OLD | NEW |