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

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

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

Powered by Google App Engine
This is Rietveld 408576698