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

Side by Side Diff: chrome/browser/ui/webui/options/language_dictionary_overlay_handler.cc

Issue 15940004: Add HasWord(string) method to SpellcheckCustomDictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Attempt to fix android compile again Created 7 years, 7 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
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/ui/webui/options/language_dictionary_overlay_handler.h" 5 #include "chrome/browser/ui/webui/options/language_dictionary_overlay_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/spellchecker/spellcheck_factory.h" 10 #include "chrome/browser/spellchecker/spellcheck_factory.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (!overlay_initialized_) 84 if (!overlay_initialized_)
85 return; 85 return;
86 86
87 if (!dictionary_) { 87 if (!dictionary_) {
88 dictionary_ = SpellcheckServiceFactory::GetForProfile( 88 dictionary_ = SpellcheckServiceFactory::GetForProfile(
89 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); 89 Profile::FromWebUI(web_ui()))->GetCustomDictionary();
90 dictionary_->AddObserver(this); 90 dictionary_->AddObserver(this);
91 } 91 }
92 92
93 ListValue list_value; 93 ListValue list_value;
94 list_value.AppendStrings(dictionary_->GetWords()); 94 const chrome::spellcheck_common::WordSet& words = dictionary_->GetWords();
95 for (chrome::spellcheck_common::WordSet::iterator it = words.begin();
Dan Beam 2013/05/24 02:57:51 nit: const_iterator
Dan Beam 2013/05/24 02:57:51 wouldn't it be nice to use auto here?! what a mou
please use gerrit instead 2013/05/24 16:20:01 Done.
96 it != words.end();
Dan Beam 2013/05/24 02:57:51 nit: it's probably pretty normal to put it != w
please use gerrit instead 2013/05/24 16:20:01 Done.
97 ++it) {
98 list_value.AppendString(*it);
99 }
95 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", 100 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList",
96 list_value); 101 list_value);
97 } 102 }
98 103
99 void LanguageDictionaryOverlayHandler::RefreshWords(const ListValue* args) { 104 void LanguageDictionaryOverlayHandler::RefreshWords(const ListValue* args) {
100 overlay_initialized_ = true; 105 overlay_initialized_ = true;
101 ResetDictionaryWords(); 106 ResetDictionaryWords();
102 } 107 }
103 108
104 void LanguageDictionaryOverlayHandler::AddWord(const ListValue* args) { 109 void LanguageDictionaryOverlayHandler::AddWord(const ListValue* args) {
105 std::string new_word; 110 std::string new_word;
106 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) { 111 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) {
107 NOTREACHED(); 112 NOTREACHED();
108 return; 113 return;
109 } 114 }
110 dictionary_->AddWord(new_word); 115 dictionary_->AddWord(new_word);
111 } 116 }
112 117
113 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { 118 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) {
114 std::string old_word; 119 std::string old_word;
115 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { 120 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) {
116 NOTREACHED(); 121 NOTREACHED();
117 return; 122 return;
118 } 123 }
119 dictionary_->RemoveWord(old_word); 124 dictionary_->RemoveWord(old_word);
120 } 125 }
121 126
122 } // namespace options 127 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/dictionary_helper.cc ('k') | chrome/common/spellcheck_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698