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

Side by Side Diff: chrome/browser/spellchecker.h

Issue 160565: Adds support for the os x spelling panel to chromium. Users can... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « chrome/browser/spellcheck_unittest.cc ('k') | chrome/browser/spellchecker.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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 #ifndef CHROME_BROWSER_SPELLCHECKER_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_H_
6 #define CHROME_BROWSER_SPELLCHECKER_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include <string> 9 #include <string>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const std::string& language, 57 const std::string& language,
58 URLRequestContext* request_context, 58 URLRequestContext* request_context,
59 const FilePath& custom_dictionary_file_name); 59 const FilePath& custom_dictionary_file_name);
60 60
61 // Only delete on the I/O thread (see above). 61 // Only delete on the I/O thread (see above).
62 ~SpellChecker(); 62 ~SpellChecker();
63 63
64 // SpellCheck a word. 64 // SpellCheck a word.
65 // Returns true if spelled correctly, false otherwise. 65 // Returns true if spelled correctly, false otherwise.
66 // If the spellchecker failed to initialize, always returns true. 66 // If the spellchecker failed to initialize, always returns true.
67 // The |tag| parameter should either be a unique identifier for the document
68 // that the word came from (if the current platform requires it), or 0.
67 // In addition, finds the suggested words for a given word 69 // In addition, finds the suggested words for a given word
68 // and puts them into |*optional_suggestions|. 70 // and puts them into |*optional_suggestions|.
69 // If the word is spelled correctly, the vector is empty. 71 // If the word is spelled correctly, the vector is empty.
70 // If optional_suggestions is NULL, suggested words will not be looked up. 72 // If optional_suggestions is NULL, suggested words will not be looked up.
71 // Note that Doing suggest lookups can be slow. 73 // Note that Doing suggest lookups can be slow.
72 bool SpellCheckWord(const wchar_t* in_word, 74 bool SpellCheckWord(const wchar_t* in_word,
73 int in_word_len, 75 int in_word_len,
76 int tag,
74 int* misspelling_start, 77 int* misspelling_start,
75 int* misspelling_len, 78 int* misspelling_len,
76 std::vector<std::wstring>* optional_suggestions); 79 std::vector<std::wstring>* optional_suggestions);
77 80
78 // Find a possible correctly spelled word for a misspelled word. Computes an 81 // Find a possible correctly spelled word for a misspelled word. Computes an
79 // empty string if input misspelled word is too long, there is ambiguity, or 82 // empty string if input misspelled word is too long, there is ambiguity, or
80 // the correct spelling cannot be determined. 83 // the correct spelling cannot be determined.
81 void GetAutoCorrectionWord(const std::wstring& word, 84 void GetAutoCorrectionWord(const std::wstring& word, int tag,
82 std::wstring* autocorrect_word); 85 std::wstring* autocorrect_word);
83 86
84 // Turn auto spell correct support ON or OFF. 87 // Turn auto spell correct support ON or OFF.
85 // |turn_on| = true means turn ON; false means turn OFF. 88 // |turn_on| = true means turn ON; false means turn OFF.
86 void EnableAutoSpellCorrect(bool turn_on); 89 void EnableAutoSpellCorrect(bool turn_on);
87 90
88 // Add custom word to the dictionary, which means: 91 // Add custom word to the dictionary, which means:
89 // a) Add it to the current hunspell object for immediate use, 92 // a) Add it to the current hunspell object for immediate use,
90 // b) Add the word to a file in disk for custom dictionary. 93 // b) Add the word to a file in disk for custom dictionary.
91 void AddWord(const std::wstring& word); 94 void AddWord(const std::wstring& word);
(...skipping 25 matching lines...) Expand all
117 // TODO(sidchat): Save to disk in the file thread instead of the IO thread. 120 // TODO(sidchat): Save to disk in the file thread instead of the IO thread.
118 virtual void OnURLFetchComplete(const URLFetcher* source, 121 virtual void OnURLFetchComplete(const URLFetcher* source,
119 const GURL& url, 122 const GURL& url,
120 const URLRequestStatus& status, 123 const URLRequestStatus& status,
121 int response_code, 124 int response_code,
122 const ResponseCookies& cookies, 125 const ResponseCookies& cookies,
123 const std::string& data); 126 const std::string& data);
124 127
125 // When called, relays the request to check the spelling to the proper 128 // When called, relays the request to check the spelling to the proper
126 // backend, either hunspell or a platform-specific backend. 129 // backend, either hunspell or a platform-specific backend.
127 bool CheckSpelling(const std::string& word_to_check); 130 bool CheckSpelling(const std::string& word_to_check, int tag);
128 131
129 // When called, relays the request to fill the list with suggestions to 132 // When called, relays the request to fill the list with suggestions to
130 // the proper backend, either hunspell or a platform-specific backend. 133 // the proper backend, either hunspell or a platform-specific backend.
131 void FillSuggestionList(const std::string& wrong_word, 134 void FillSuggestionList(const std::string& wrong_word,
132 std::vector<std::wstring>* optional_suggestions); 135 std::vector<std::wstring>* optional_suggestions);
133 136
134 // Initializes the Hunspell Dictionary. 137 // Initializes the Hunspell Dictionary.
135 bool Initialize(); 138 bool Initialize();
136 139
137 // After |hunspell_| is initialized, this function is called to add custom 140 // After |hunspell_| is initialized, this function is called to add custom
138 // words from the custom dictionary to the |hunspell_|. 141 // words from the custom dictionary to the |hunspell_|.
139 void AddCustomWordsToHunspell(); 142 void AddCustomWordsToHunspell();
140 143
141 // Memory maps the given .bdic file. On success, it will return true and will 144 // Memory maps the given .bdic file. On success, it will return true and will
142 // place the data and length into the given out parameters. 145 // place the data and length into the given out parameters.
143 bool MapBdictFile(const unsigned char** data, size_t* length); 146 bool MapBdictFile(const unsigned char** data, size_t* length);
144 147
145 // Returns whether or not the given word is a contraction of valid words 148 // Returns whether or not the given word is a contraction of valid words
146 // (e.g. "word:word"). 149 // (e.g. "word:word").
147 bool IsValidContraction(const string16& word); 150 bool IsValidContraction(const string16& word, int tag);
148 151
149 // Return the file name of the dictionary, including the path and the version 152 // Return the file name of the dictionary, including the path and the version
150 // numbers. 153 // numbers.
151 FilePath GetVersionedFileName(const std::string& language, 154 FilePath GetVersionedFileName(const std::string& language,
152 const FilePath& dict_dir); 155 const FilePath& dict_dir);
153 156
154 static std::string GetCorrespondingSpellCheckLanguage( 157 static std::string GetCorrespondingSpellCheckLanguage(
155 const std::string& language); 158 const std::string& language);
156 159
157 // Start downloading a dictionary from the server. On completion, the 160 // Start downloading a dictionary from the server. On completion, the
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 229
227 // Used for generating callbacks to spellchecker, since spellchecker is a 230 // Used for generating callbacks to spellchecker, since spellchecker is a
228 // non-reference counted object. 231 // non-reference counted object.
229 ScopedRunnableMethodFactory<SpellChecker> 232 ScopedRunnableMethodFactory<SpellChecker>
230 on_dictionary_save_complete_callback_factory_; 233 on_dictionary_save_complete_callback_factory_;
231 234
232 DISALLOW_COPY_AND_ASSIGN(SpellChecker); 235 DISALLOW_COPY_AND_ASSIGN(SpellChecker);
233 }; 236 };
234 237
235 #endif // CHROME_BROWSER_SPELLCHECKER_H_ 238 #endif // CHROME_BROWSER_SPELLCHECKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/spellcheck_unittest.cc ('k') | chrome/browser/spellchecker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698