| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ |
| 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ |
| 7 | 7 |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 virtual void OnHunspellDictionaryDownloadSuccess() = 0; | 41 virtual void OnHunspellDictionaryDownloadSuccess() = 0; |
| 42 | 42 |
| 43 // Dictionary download failed. | 43 // Dictionary download failed. |
| 44 virtual void OnHunspellDictionaryDownloadFailure() = 0; | 44 virtual void OnHunspellDictionaryDownloadFailure() = 0; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 SpellcheckHunspellDictionary( | 47 SpellcheckHunspellDictionary( |
| 48 const std::string& language, | 48 const std::string& language, |
| 49 net::URLRequestContextGetter* request_context_getter, | 49 net::URLRequestContextGetter* request_context_getter, |
| 50 SpellcheckService* spellcheck_service); | 50 SpellcheckService* spellcheck_service); |
| 51 virtual ~SpellcheckHunspellDictionary(); | 51 ~SpellcheckHunspellDictionary() override; |
| 52 | 52 |
| 53 // SpellcheckDictionary implementation: | 53 // SpellcheckDictionary implementation: |
| 54 virtual void Load() override; | 54 void Load() override; |
| 55 | 55 |
| 56 // Retry downloading |dictionary_file_|. | 56 // Retry downloading |dictionary_file_|. |
| 57 void RetryDownloadDictionary( | 57 void RetryDownloadDictionary( |
| 58 net::URLRequestContextGetter* request_context_getter); | 58 net::URLRequestContextGetter* request_context_getter); |
| 59 | 59 |
| 60 // Returns true if the dictionary is ready to use. | 60 // Returns true if the dictionary is ready to use. |
| 61 virtual bool IsReady() const; | 61 virtual bool IsReady() const; |
| 62 | 62 |
| 63 const base::File& GetDictionaryFile() const; | 63 const base::File& GetDictionaryFile() const; |
| 64 const std::string& GetLanguage() const; | 64 const std::string& GetLanguage() const; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // The desired location of the dictionary file, whether or not it exists. | 98 // The desired location of the dictionary file, whether or not it exists. |
| 99 base::FilePath path; | 99 base::FilePath path; |
| 100 | 100 |
| 101 // The dictionary file. | 101 // The dictionary file. |
| 102 base::File file; | 102 base::File file; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // net::URLFetcherDelegate implementation. Called when dictionary download | 105 // net::URLFetcherDelegate implementation. Called when dictionary download |
| 106 // finishes. | 106 // finishes. |
| 107 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 107 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 108 | 108 |
| 109 // Determine the correct url to download the dictionary. | 109 // Determine the correct url to download the dictionary. |
| 110 GURL GetDictionaryURL(); | 110 GURL GetDictionaryURL(); |
| 111 | 111 |
| 112 // Attempt to download the dictionary. | 112 // Attempt to download the dictionary. |
| 113 void DownloadDictionary(GURL url); | 113 void DownloadDictionary(GURL url); |
| 114 | 114 |
| 115 // Figures out the location for the dictionary, verifies its contents, and | 115 // Figures out the location for the dictionary, verifies its contents, and |
| 116 // opens it. | 116 // opens it. |
| 117 static DictionaryFile OpenDictionaryFile(const base::FilePath& path); | 117 static DictionaryFile OpenDictionaryFile(const base::FilePath& path); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Dictionary file path and descriptor. | 158 // Dictionary file path and descriptor. |
| 159 DictionaryFile dictionary_file_; | 159 DictionaryFile dictionary_file_; |
| 160 | 160 |
| 161 base::WeakPtrFactory<SpellcheckHunspellDictionary> weak_ptr_factory_; | 161 base::WeakPtrFactory<SpellcheckHunspellDictionary> weak_ptr_factory_; |
| 162 | 162 |
| 163 DISALLOW_COPY_AND_ASSIGN(SpellcheckHunspellDictionary); | 163 DISALLOW_COPY_AND_ASSIGN(SpellcheckHunspellDictionary); |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ | 166 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_ |
| OLD | NEW |