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

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

Issue 198163004: Revert 257524 "Move IsStringASCII/UTF8 to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 <functional> 7 #include <functional>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/important_file_writer.h" 10 #include "base/files/important_file_writer.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return INVALID_CHECKSUM; 69 return INVALID_CHECKSUM;
70 } 70 }
71 base::TrimWhitespaceASCII(contents, base::TRIM_ALL, &contents); 71 base::TrimWhitespaceASCII(contents, base::TRIM_ALL, &contents);
72 base::SplitString(contents, '\n', &words); 72 base::SplitString(contents, '\n', &words);
73 return VALID_CHECKSUM; 73 return VALID_CHECKSUM;
74 } 74 }
75 75
76 // Returns true for invalid words and false for valid words. 76 // Returns true for invalid words and false for valid words.
77 bool IsInvalidWord(const std::string& word) { 77 bool IsInvalidWord(const std::string& word) {
78 std::string tmp; 78 std::string tmp;
79 return !base::IsStringUTF8(word) || 79 return !IsStringUTF8(word) ||
80 word.length() > 80 word.length() >
81 chrome::spellcheck_common::MAX_CUSTOM_DICTIONARY_WORD_BYTES || 81 chrome::spellcheck_common::MAX_CUSTOM_DICTIONARY_WORD_BYTES ||
82 word.empty() || 82 word.empty() ||
83 base::TRIM_NONE != base::TrimWhitespaceASCII(word, base::TRIM_ALL, &tmp); 83 base::TRIM_NONE != base::TrimWhitespaceASCII(word, base::TRIM_ALL, &tmp);
84 } 84 }
85 85
86 // Loads the custom spellcheck dictionary from |path| into |custom_words|. If 86 // Loads the custom spellcheck dictionary from |path| into |custom_words|. If
87 // the dictionary checksum is not valid, but backup checksum is valid, then 87 // the dictionary checksum is not valid, but backup checksum is valid, then
88 // restores the backup and loads that into |custom_words| instead. If the backup 88 // restores the backup and loads that into |custom_words| instead. If the backup
89 // is invalid too, then clears |custom_words|. Must be called on the file 89 // is invalid too, then clears |custom_words|. Must be called on the file
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 void SpellcheckCustomDictionary::Notify( 528 void SpellcheckCustomDictionary::Notify(
529 const SpellcheckCustomDictionary::Change& dictionary_change) { 529 const SpellcheckCustomDictionary::Change& dictionary_change) {
530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
531 if (!IsLoaded() || dictionary_change.empty()) 531 if (!IsLoaded() || dictionary_change.empty())
532 return; 532 return;
533 FOR_EACH_OBSERVER(Observer, 533 FOR_EACH_OBSERVER(Observer,
534 observers_, 534 observers_,
535 OnCustomDictionaryChanged(dictionary_change)); 535 OnCustomDictionaryChanged(dictionary_change));
536 } 536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698