Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: chrome/browser/tab_contents/spelling_menu_observer.cc

Issue 15736012: Send ADD_TO_DICT feedback to spelling service when user adds word to dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge master Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // When we choose the suggestion sent from the Spelling service, we replace 269 // When we choose the suggestion sent from the Spelling service, we replace
270 // the misspelled word with the suggestion and add it to our custom-word 270 // the misspelled word with the suggestion and add it to our custom-word
271 // dictionary so this word is not marked as misspelled any longer. 271 // dictionary so this word is not marked as misspelled any longer.
272 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION) { 272 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION) {
273 proxy_->GetRenderViewHost()->ReplaceMisspelling(result_); 273 proxy_->GetRenderViewHost()->ReplaceMisspelling(result_);
274 misspelled_word_ = result_; 274 misspelled_word_ = result_;
275 } 275 }
276 276
277 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION || 277 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION ||
278 command_id == IDC_SPELLCHECK_ADD_TO_DICTIONARY) { 278 command_id == IDC_SPELLCHECK_ADD_TO_DICTIONARY) {
279 // GetHostForProfile() can return null when the suggested word is 279 // GetHostForProfile() can return null when the suggested word is provided
280 // provided by Web SpellCheck API. 280 // by Web SpellCheck API.
281 Profile* profile = proxy_->GetProfile(); 281 Profile* profile = proxy_->GetProfile();
282 if (profile) { 282 if (profile) {
283 SpellcheckService* spellcheck_service = 283 SpellcheckService* spellcheck =
284 SpellcheckServiceFactory::GetForProfile(profile); 284 SpellcheckServiceFactory::GetForProfile(profile);
285 if (spellcheck_service) 285 if (spellcheck) {
286 spellcheck_service->GetCustomDictionary()->AddWord( 286 spellcheck->GetCustomDictionary()->AddWord(UTF16ToUTF8(
287 UTF16ToUTF8(misspelled_word_)); 287 misspelled_word_));
288 spellcheck->GetFeedbackSender()->AddedToDictionary(misspelling_hash_);
289 }
288 } 290 }
289 #if defined(OS_MACOSX) 291 #if defined(OS_MACOSX)
290 spellcheck_mac::AddWord(misspelled_word_); 292 spellcheck_mac::AddWord(misspelled_word_);
291 #endif 293 #endif
292 } 294 }
293 295
294 // The spelling service can be toggled by the user only if it is not managed. 296 // The spelling service can be toggled by the user only if it is not managed.
295 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && 297 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE &&
296 integrate_spelling_service_.IsUserModifiable()) { 298 integrate_spelling_service_.IsUserModifiable()) {
297 // When a user enables the "Ask Google for spelling suggestions" item, we 299 // When a user enables the "Ask Google for spelling suggestions" item, we
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void SpellingMenuObserver::OnAnimationTimerExpired() { 405 void SpellingMenuObserver::OnAnimationTimerExpired() {
404 // Append '.' characters to the end of "Checking". 406 // Append '.' characters to the end of "Checking".
405 loading_frame_ = (loading_frame_ + 1) & 3; 407 loading_frame_ = (loading_frame_ + 1) & 3;
406 string16 loading_message = loading_message_ + string16(loading_frame_,'.'); 408 string16 loading_message = loading_message_ + string16(loading_frame_,'.');
407 409
408 // Update the menu item with the text. We disable this item to prevent users 410 // Update the menu item with the text. We disable this item to prevent users
409 // from selecting it. 411 // from selecting it.
410 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 412 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
411 loading_message); 413 loading_message);
412 } 414 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698