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/tab_contents/spelling_menu_observer.h" | 5 #include "chrome/browser/tab_contents/spelling_menu_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return false; | 209 return false; |
210 } | 210 } |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 void SpellingMenuObserver::ExecuteCommand(int command_id) { | 214 void SpellingMenuObserver::ExecuteCommand(int command_id) { |
215 DCHECK(IsCommandIdSupported(command_id)); | 215 DCHECK(IsCommandIdSupported(command_id)); |
216 | 216 |
217 if (command_id >= IDC_SPELLCHECK_SUGGESTION_0 && | 217 if (command_id >= IDC_SPELLCHECK_SUGGESTION_0 && |
218 command_id <= IDC_SPELLCHECK_SUGGESTION_LAST) { | 218 command_id <= IDC_SPELLCHECK_SUGGESTION_LAST) { |
219 proxy_->GetRenderViewHost()->Replace( | 219 proxy_->GetRenderViewHost()->ReplaceMisspelling( |
220 suggestions_[command_id - IDC_SPELLCHECK_SUGGESTION_0]); | 220 suggestions_[command_id - IDC_SPELLCHECK_SUGGESTION_0]); |
221 // GetSpellCheckHost() can return null when the suggested word is | 221 // GetSpellCheckHost() can return null when the suggested word is |
222 // provided by Web SpellCheck API. | 222 // provided by Web SpellCheck API. |
223 Profile* profile = proxy_->GetProfile(); | 223 Profile* profile = proxy_->GetProfile(); |
224 if (profile) { | 224 if (profile) { |
225 SpellcheckService* spellcheck_service = | 225 SpellcheckService* spellcheck_service = |
226 SpellcheckServiceFactory::GetForProfile(profile); | 226 SpellcheckServiceFactory::GetForProfile(profile); |
227 if (spellcheck_service && spellcheck_service->GetMetrics()) | 227 if (spellcheck_service && spellcheck_service->GetMetrics()) |
228 spellcheck_service->GetMetrics()->RecordReplacedWordStats(1); | 228 spellcheck_service->GetMetrics()->RecordReplacedWordStats(1); |
229 } | 229 } |
230 return; | 230 return; |
231 } | 231 } |
232 | 232 |
233 // When we choose the suggestion sent from the Spelling service, we replace | 233 // When we choose the suggestion sent from the Spelling service, we replace |
234 // the misspelled word with the suggestion and add it to our custom-word | 234 // the misspelled word with the suggestion and add it to our custom-word |
235 // dictionary so this word is not marked as misspelled any longer. | 235 // dictionary so this word is not marked as misspelled any longer. |
236 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION) { | 236 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION) { |
237 proxy_->GetRenderViewHost()->Replace(result_); | 237 proxy_->GetRenderViewHost()->ReplaceMisspelling(result_); |
238 misspelled_word_ = result_; | 238 misspelled_word_ = result_; |
239 } | 239 } |
240 | 240 |
241 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION || | 241 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION || |
242 command_id == IDC_SPELLCHECK_ADD_TO_DICTIONARY) { | 242 command_id == IDC_SPELLCHECK_ADD_TO_DICTIONARY) { |
243 // GetHostForProfile() can return null when the suggested word is | 243 // GetHostForProfile() can return null when the suggested word is |
244 // provided by Web SpellCheck API. | 244 // provided by Web SpellCheck API. |
245 Profile* profile = proxy_->GetProfile(); | 245 Profile* profile = proxy_->GetProfile(); |
246 if (profile) { | 246 if (profile) { |
247 SpellcheckService* spellcheck_service = | 247 SpellcheckService* spellcheck_service = |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 void SpellingMenuObserver::OnAnimationTimerExpired() { | 352 void SpellingMenuObserver::OnAnimationTimerExpired() { |
353 // Append '.' characters to the end of "Checking". | 353 // Append '.' characters to the end of "Checking". |
354 loading_frame_ = (loading_frame_ + 1) & 3; | 354 loading_frame_ = (loading_frame_ + 1) & 3; |
355 string16 loading_message = loading_message_ + string16(loading_frame_,'.'); | 355 string16 loading_message = loading_message_ + string16(loading_frame_,'.'); |
356 | 356 |
357 // Update the menu item with the text. We disable this item to prevent users | 357 // Update the menu item with the text. We disable this item to prevent users |
358 // from selecting it. | 358 // from selecting it. |
359 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 359 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
360 loading_message); | 360 loading_message); |
361 } | 361 } |
OLD | NEW |