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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary.cc

Issue 11280013: Unit-tests for removing words from the dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@dictionary
Patch Set: Created 8 years, 1 month 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 | chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc » ('j') | 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/spellchecker/spellcheck_custom_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const WordList& SpellcheckCustomDictionary::GetWords() const { 42 const WordList& SpellcheckCustomDictionary::GetWords() const {
43 return words_; 43 return words_;
44 } 44 }
45 45
46 void SpellcheckCustomDictionary::LoadDictionaryIntoCustomWordList( 46 void SpellcheckCustomDictionary::LoadDictionaryIntoCustomWordList(
47 WordList* custom_words) { 47 WordList* custom_words) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
49 49
50 std::string contents; 50 std::string contents;
51 file_util::ReadFileToString(custom_dictionary_path_, &contents); 51 file_util::ReadFileToString(custom_dictionary_path_, &contents);
52 if (contents.empty()) 52 if (contents.empty()) {
53 custom_words->clear();
53 return; 54 return;
55 }
54 56
55 base::SplitString(contents, '\n', custom_words); 57 base::SplitString(contents, '\n', custom_words);
56 // Clear out empty words. 58 // Clear out empty words.
57 custom_words->erase(remove_if(custom_words->begin(), custom_words->end(), 59 custom_words->erase(remove_if(custom_words->begin(), custom_words->end(),
58 mem_fun_ref(&std::string::empty)), custom_words->end()); 60 mem_fun_ref(&std::string::empty)), custom_words->end());
59 } 61 }
60 62
61 void SpellcheckCustomDictionary::SetCustomWordList(WordList* custom_words) { 63 void SpellcheckCustomDictionary::SetCustomWordList(WordList* custom_words) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
63 65
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return custom_words; 207 return custom_words;
206 } 208 }
207 209
208 void SpellcheckCustomDictionary::SetCustomWordListAndDelete( 210 void SpellcheckCustomDictionary::SetCustomWordListAndDelete(
209 WordList* custom_words) { 211 WordList* custom_words) {
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
211 213
212 SetCustomWordList(custom_words); 214 SetCustomWordList(custom_words);
213 delete custom_words; 215 delete custom_words;
214 } 216 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698