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 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" | 5 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/barrier_closure.h" | 10 #include "base/barrier_closure.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 destination_->AddRef(); | 89 destination_->AddRef(); |
90 } | 90 } |
91 | 91 |
92 void SpellingRequest::RequestCheck( | 92 void SpellingRequest::RequestCheck( |
93 const base::string16& text, | 93 const base::string16& text, |
94 int route_id, | 94 int route_id, |
95 int identifier, | 95 int identifier, |
96 int document_tag, | 96 int document_tag, |
97 const std::vector<SpellCheckMarker>& markers) { | 97 const std::vector<SpellCheckMarker>& markers) { |
98 DCHECK(!text.empty()); | 98 DCHECK(!text.empty()); |
99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 99 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
100 | 100 |
101 route_id_ = route_id; | 101 route_id_ = route_id; |
102 identifier_ = identifier; | 102 identifier_ = identifier; |
103 document_tag_ = document_tag; | 103 document_tag_ = document_tag; |
104 markers_ = markers; | 104 markers_ = markers; |
105 | 105 |
106 // Send the remote query out. The barrier owns |this|, ensuring it is deleted | 106 // Send the remote query out. The barrier owns |this|, ensuring it is deleted |
107 // after completion. | 107 // after completion. |
108 completion_barrier_ = | 108 completion_barrier_ = |
109 BarrierClosure(2, | 109 BarrierClosure(2, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 destination_->Release(); | 156 destination_->Release(); |
157 | 157 |
158 // Object is self-managed - at this point, its life span is over. | 158 // Object is self-managed - at this point, its life span is over. |
159 // No need to delete, since the OnCheckCompleted callback owns |this|. | 159 // No need to delete, since the OnCheckCompleted callback owns |this|. |
160 } | 160 } |
161 | 161 |
162 void SpellingRequest::OnRemoteCheckCompleted( | 162 void SpellingRequest::OnRemoteCheckCompleted( |
163 bool success, | 163 bool success, |
164 const base::string16& text, | 164 const base::string16& text, |
165 const std::vector<SpellCheckResult>& results) { | 165 const std::vector<SpellCheckResult>& results) { |
166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 166 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
167 remote_success_ = success; | 167 remote_success_ = success; |
168 remote_results_ = results; | 168 remote_results_ = results; |
169 | 169 |
170 SpellcheckService* spellcheck_service = | 170 SpellcheckService* spellcheck_service = |
171 SpellcheckServiceFactory::GetForRenderProcessId(render_process_id_); | 171 SpellcheckServiceFactory::GetForRenderProcessId(render_process_id_); |
172 if (spellcheck_service) { | 172 if (spellcheck_service) { |
173 spellcheck_service->GetFeedbackSender()->OnSpellcheckResults( | 173 spellcheck_service->GetFeedbackSender()->OnSpellcheckResults( |
174 render_process_id_, | 174 render_process_id_, |
175 text, | 175 text, |
176 markers_, | 176 markers_, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 const base::string16& word) { | 268 const base::string16& word) { |
269 spellcheck_mac::UpdateSpellingPanelWithMisspelledWord(word); | 269 spellcheck_mac::UpdateSpellingPanelWithMisspelledWord(word); |
270 } | 270 } |
271 | 271 |
272 void SpellCheckMessageFilterMac::OnRequestTextCheck( | 272 void SpellCheckMessageFilterMac::OnRequestTextCheck( |
273 int route_id, | 273 int route_id, |
274 int identifier, | 274 int identifier, |
275 const base::string16& text, | 275 const base::string16& text, |
276 std::vector<SpellCheckMarker> markers) { | 276 std::vector<SpellCheckMarker> markers) { |
277 DCHECK(!text.empty()); | 277 DCHECK(!text.empty()); |
278 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 278 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
279 | 279 |
280 // Initialize the spellcheck service if needed. The service will send the | 280 // Initialize the spellcheck service if needed. The service will send the |
281 // language code for text breaking to the renderer. (Text breaking is required | 281 // language code for text breaking to the renderer. (Text breaking is required |
282 // for the context menu to show spelling suggestions.) Initialization must | 282 // for the context menu to show spelling suggestions.) Initialization must |
283 // happen on UI thread. | 283 // happen on UI thread. |
284 SpellcheckServiceFactory::GetForRenderProcessId(render_process_id_); | 284 SpellcheckServiceFactory::GetForRenderProcessId(render_process_id_); |
285 | 285 |
286 // Erase invalid markers (with offsets out of boundaries of text length). | 286 // Erase invalid markers (with offsets out of boundaries of text length). |
287 markers.erase( | 287 markers.erase( |
288 std::remove_if( | 288 std::remove_if( |
(...skipping 15 matching lines...) Expand all Loading... |
304 } | 304 } |
305 | 305 |
306 // TODO(groby): We are currently not notified of retired tags. We need | 306 // TODO(groby): We are currently not notified of retired tags. We need |
307 // to track destruction of RenderViewHosts on the browser process side | 307 // to track destruction of RenderViewHosts on the browser process side |
308 // to update our mappings when a document goes away. | 308 // to update our mappings when a document goes away. |
309 void SpellCheckMessageFilterMac::RetireDocumentTag(int route_id) { | 309 void SpellCheckMessageFilterMac::RetireDocumentTag(int route_id) { |
310 spellcheck_mac::CloseDocumentWithTag(ToDocumentTag(route_id)); | 310 spellcheck_mac::CloseDocumentWithTag(ToDocumentTag(route_id)); |
311 tag_map_.erase(route_id); | 311 tag_map_.erase(route_id); |
312 } | 312 } |
313 | 313 |
OLD | NEW |