summaryrefslogtreecommitdiffstats
path: root/chrome/browser/spellchecker.cc
diff options
context:
space:
mode:
authorsidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 17:55:42 +0000
committersidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 17:55:42 +0000
commitc674dbea1070e03a7412f1f71f197c880b659953 (patch)
tree83c5a0de4355730f17bf039cc83f4b31d84e7b91 /chrome/browser/spellchecker.cc
parent4a1dccb2563495d89007e55eb9709699cb855ba1 (diff)
downloadchromium_src-c674dbea1070e03a7412f1f71f197c880b659953.zip
chromium_src-c674dbea1070e03a7412f1f71f197c880b659953.tar.gz
chromium_src-c674dbea1070e03a7412f1f71f197c880b659953.tar.bz2
Update SpellChecker to download the latest version of the bdic dictionary files.
Review URL: http://codereview.chromium.org/6474 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/spellchecker.cc')
-rw-r--r--chrome/browser/spellchecker.cc44
1 files changed, 41 insertions, 3 deletions
diff --git a/chrome/browser/spellchecker.cc b/chrome/browser/spellchecker.cc
index 186791a..d5a8a6c 100644
--- a/chrome/browser/spellchecker.cc
+++ b/chrome/browser/spellchecker.cc
@@ -194,12 +194,50 @@ void SpellChecker::RegisterUserPrefs(PrefService* prefs) {
IDS_SPELLCHECK_DICTIONARY);
}
+std::wstring SpellChecker::GetVersionedFileName(const std::wstring& language,
+ const std::wstring& dict_dir) {
+ // The default version string currently in use.
+ static const wchar_t kDefaultVersionString[] = L"-1-1";
+
+ // Use this struct to insert version strings for dictionary files which have
+ // special version strings, other than the default version string.
+ // For de-DE, we are currently using de-DE-1-1-1 for versioning, because
+ // de-DE-1-1.bdic, in the download server, corresponds to a less used
+ // dictionary. This version, i.e., de-DE-1-1-1.bdic, is actually renamed
+ // from de-DE-neu-1-1.bic.
+ static const struct {
+ // The language input.
+ const char* language;
+
+ // The corresponding version.
+ const char* version;
+ } special_version_string[] = {
+ "de-DE", "-1-1-1",
+ };
+
+ // Generate the bdict file name using default version string or special
+ // version string, depending on the language.
+ std::wstring versioned_bdict_file_name(language + kDefaultVersionString +
+ L".bdic");
+ std::string language_string(WideToUTF8(language));
+ for (int i = 0; i < arraysize(special_version_string); i++ ) {
+ if (language_string.compare(special_version_string[i].language) == 0) {
+ versioned_bdict_file_name =
+ language + UTF8ToWide(special_version_string[i].version) + L".bdic";
+ break;
+ }
+ }
+
+ std::wstring bdict_file_name(dict_dir);
+ file_util::AppendToPath(&bdict_file_name, versioned_bdict_file_name);
+ return bdict_file_name;
+}
+
SpellChecker::SpellChecker(const std::wstring& dict_dir,
const std::wstring& language,
URLRequestContext* request_context,
const std::wstring& custom_dictionary_file_name)
- : bdict_file_name_(dict_dir),
- custom_dictionary_file_name_(custom_dictionary_file_name),
+ : custom_dictionary_file_name_(custom_dictionary_file_name),
bdict_file_(NULL),
bdict_mapping_(NULL),
bdict_mapped_data_(NULL),
@@ -223,7 +261,7 @@ SpellChecker::SpellChecker(const std::wstring& dict_dir,
file_loop_ = file_thread->message_loop();
// Get the path to the spellcheck file.
- file_util::AppendToPath(&bdict_file_name_, language + L".bdic");
+ bdict_file_name_ = GetVersionedFileName(language, dict_dir);
// Get the path to the custom dictionary file.
if (custom_dictionary_file_name_.empty()) {