| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PROFILE_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_PROFILE_H_ |
| 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_PROFILE_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_PROFILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 15 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 class SpellCheckHost; | 18 class SpellCheckHost; |
| 18 class SpellCheckHostMetrics; | 19 class SpellCheckHostMetrics; |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 49 REINITIALIZE_CREATED_HOST, | 50 REINITIALIZE_CREATED_HOST, |
| 50 // An existing SpellCheckHost insntace is deleted, that means | 51 // An existing SpellCheckHost insntace is deleted, that means |
| 51 // the spell-check feature just tunred from enabled to disabled. | 52 // the spell-check feature just tunred from enabled to disabled. |
| 52 // The state should be synced to renderer processes | 53 // The state should be synced to renderer processes |
| 53 REINITIALIZE_REMOVED_HOST, | 54 REINITIALIZE_REMOVED_HOST, |
| 54 // The API did nothing. SpellCheckHost instance isn't created nor | 55 // The API did nothing. SpellCheckHost instance isn't created nor |
| 55 // deleted. | 56 // deleted. |
| 56 REINITIALIZE_DID_NOTHING | 57 REINITIALIZE_DID_NOTHING |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 SpellCheckProfile(); | 60 explicit SpellCheckProfile(const FilePath& profile_dir); |
| 60 virtual ~SpellCheckProfile(); | 61 virtual ~SpellCheckProfile(); |
| 61 | 62 |
| 62 // Retrieves SpellCheckHost object. | 63 // Retrieves SpellCheckHost object. |
| 63 // This can return NULL when the spell-checking is disabled | 64 // This can return NULL when the spell-checking is disabled |
| 64 // or the host object is not ready yet. | 65 // or the host object is not ready yet. |
| 65 SpellCheckHost* GetHost(); | 66 SpellCheckHost* GetHost(); |
| 66 | 67 |
| 67 // Initializes or deletes SpellCheckHost object if necessary. | 68 // Initializes or deletes SpellCheckHost object if necessary. |
| 68 // The caller should provide URLRequestContextGetter for | 69 // The caller should provide URLRequestContextGetter for |
| 69 // possible dictionary download. | 70 // possible dictionary download. |
| 70 // | 71 // |
| 71 // If |force| is true, the host instance is newly created | 72 // If |force| is true, the host instance is newly created |
| 72 // regardless there is existing instance. | 73 // regardless there is existing instance. |
| 73 ReinitializeResult ReinitializeHost( | 74 ReinitializeResult ReinitializeHost( |
| 74 bool force, | 75 bool force, |
| 75 bool enable, | 76 bool enable, |
| 76 const std::string& language, | 77 const std::string& language, |
| 77 net::URLRequestContextGetter* request_context); | 78 net::URLRequestContextGetter* request_context); |
| 78 | 79 |
| 79 // Instantiates SpellCheckHostMetrics object and | 80 // Instantiates SpellCheckHostMetrics object and |
| 80 // makes it ready for recording metrics. | 81 // makes it ready for recording metrics. |
| 81 // This should be called only if the metrics recording is active. | 82 // This should be called only if the metrics recording is active. |
| 82 void StartRecordingMetrics(bool spellcheck_enabled); | 83 void StartRecordingMetrics(bool spellcheck_enabled); |
| 83 | 84 |
| 84 // SpellCheckProfileProvider implementation. | 85 // SpellCheckProfileProvider implementation. |
| 85 virtual void SpellCheckHostInitialized(CustomWordList* custom_words); | 86 virtual void SpellCheckHostInitialized(CustomWordList* custom_words); |
| 86 virtual const CustomWordList& GetCustomWords() const; | 87 virtual const CustomWordList& GetCustomWords() const; |
| 87 virtual void CustomWordAddedLocally(const std::string& word); | 88 virtual void CustomWordAddedLocally(const std::string& word); |
| 88 | 89 |
| 90 // Methods about custom dictionary. |
| 91 virtual void LoadCustomDictionary(CustomWordList* custom_words); |
| 92 virtual void WriteWordToCustomDictionary(const std::string& word); |
| 93 |
| 89 protected: | 94 protected: |
| 90 // Only tests should override this. | 95 // Only tests should override this. |
| 91 virtual SpellCheckHost* CreateHost( | 96 virtual SpellCheckHost* CreateHost( |
| 92 SpellCheckProfileProvider* provider, | 97 SpellCheckProfileProvider* provider, |
| 93 const std::string& language, | 98 const std::string& language, |
| 94 net::URLRequestContextGetter* request_context, | 99 net::URLRequestContextGetter* request_context, |
| 95 SpellCheckHostMetrics* metrics); | 100 SpellCheckHostMetrics* metrics); |
| 96 | 101 |
| 97 virtual bool IsTesting() const; | 102 virtual bool IsTesting() const; |
| 98 | 103 |
| 99 private: | 104 private: |
| 100 scoped_refptr<SpellCheckHost> host_; | 105 scoped_refptr<SpellCheckHost> host_; |
| 101 scoped_ptr<SpellCheckHostMetrics> metrics_; | 106 scoped_ptr<SpellCheckHostMetrics> metrics_; |
| 102 | 107 |
| 103 // Indicates whether |host_| has told us initialization is | 108 // Indicates whether |host_| has told us initialization is |
| 104 // finished. | 109 // finished. |
| 105 bool host_ready_; | 110 bool host_ready_; |
| 106 | 111 |
| 107 // In-memory cache of the custom words file. | 112 // In-memory cache of the custom words file. |
| 108 scoped_ptr<CustomWordList> custom_words_; | 113 scoped_ptr<CustomWordList> custom_words_; |
| 109 | 114 |
| 115 // A path for custom dictionary per profile. |
| 116 FilePath custom_dictionary_path_; |
| 117 |
| 110 DISALLOW_COPY_AND_ASSIGN(SpellCheckProfile); | 118 DISALLOW_COPY_AND_ASSIGN(SpellCheckProfile); |
| 111 }; | 119 }; |
| 112 | 120 |
| 113 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_PROFILE_H_ | 121 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_PROFILE_H_ |
| OLD | NEW |