From 1ffed9387c38f75fe7ff13ec54a3cf893005b103 Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Thu, 11 Dec 2008 19:20:26 +0000 Subject: Try and make some spellcheck code more obvious by using typedefs. I am not convinced this patch is a net win. Please share your thoughts on if using a Language/Languages set of types is better or worse than what we're doing now. Review URL: http://codereview.chromium.org/13367 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6807 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/spellchecker.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'chrome/browser/spellchecker.h') diff --git a/chrome/browser/spellchecker.h b/chrome/browser/spellchecker.h index 1283712..45eb73d 100644 --- a/chrome/browser/spellchecker.h +++ b/chrome/browser/spellchecker.h @@ -37,6 +37,9 @@ class URLRequestContext; // deleted on the I/O thread itself. class SpellChecker : public base::RefCountedThreadSafe { public: + typedef std::wstring Language; + typedef std::vector Languages; + // Creates the spellchecker by reading dictionaries from the given directory, // and defaulting to the given language. Both strings must be provided. // @@ -46,7 +49,7 @@ class SpellChecker : public base::RefCountedThreadSafe { // can figure out the custom dictionary file. It is non empty only for unit // testing. SpellChecker(const std::wstring& dict_dir, - const std::wstring& language, + const Language& language, URLRequestContext* request_context, const std::wstring& custom_dictionary_file_name); @@ -73,14 +76,14 @@ class SpellChecker : public base::RefCountedThreadSafe { void AddWord(const std::wstring& word); // Get SpellChecker supported languages. - static void SpellCheckLanguages(std::vector* languages); + static void SpellCheckLanguages(Languages* languages); // This function computes a vector of strings which are to be displayed in // the context menu over a text area for changing spell check languages. It // returns the index of the current spell check language in the vector. static int GetSpellCheckLanguagesToDisplayInContextMenu( Profile* profile, - std::vector* display_language_list); + Languages* display_languages); private: // Download dictionary files when required. @@ -101,15 +104,14 @@ class SpellChecker : public base::RefCountedThreadSafe { // Returns whether or not the given word is a contraction of valid words // (e.g. "word:word"). - bool IsValidContraction(const std::wstring& word); + bool IsValidContraction(const Language& word); // Return the file name of the dictionary, including the path and the version // numbers. - std::wstring GetVersionedFileName(const std::wstring& language, + std::wstring GetVersionedFileName(const Language& language, const std::wstring& dict_dir); - static std::wstring GetCorrespondingSpellCheckLanguage( - const std::wstring& language); + static Language GetCorrespondingSpellCheckLanguage(const Language& language); // Path to the spellchecker file. std::wstring bdict_file_name_; -- cgit v1.1