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

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

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 7 years, 11 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
OLDNEW
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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 12 matching lines...) Expand all
23 namespace base { 23 namespace base {
24 class WaitableEvent; 24 class WaitableEvent;
25 } 25 }
26 26
27 namespace content { 27 namespace content {
28 class RenderProcessHost; 28 class RenderProcessHost;
29 } 29 }
30 30
31 // Encapsulates the browser side spellcheck service. There is one of these per 31 // Encapsulates the browser side spellcheck service. There is one of these per
32 // profile and each is created by the SpellCheckServiceFactory. The 32 // profile and each is created by the SpellCheckServiceFactory. The
33 // SpellCheckService maintains any per-profile information about spellcheck. 33 // SpellcheckService maintains any per-profile information about spellcheck.
34 class SpellcheckService : public ProfileKeyedService, 34 class SpellcheckService : public ProfileKeyedService,
35 public content::NotificationObserver, 35 public content::NotificationObserver,
36 public SpellcheckCustomDictionary::Observer { 36 public SpellcheckCustomDictionary::Observer {
37 public: 37 public:
38 // Event types used for reporting the status of this class and its derived 38 // Event types used for reporting the status of this class and its derived
39 // classes to browser tests. 39 // classes to browser tests.
40 enum EventType { 40 enum EventType {
41 BDICT_NOTINITIALIZED, 41 BDICT_NOTINITIALIZED,
42 BDICT_CORRUPTED, 42 BDICT_CORRUPTED,
43 }; 43 };
(...skipping 19 matching lines...) Expand all
63 // Signals the event attached by AttachTestEvent() to report the specified 63 // Signals the event attached by AttachTestEvent() to report the specified
64 // event to browser tests. This function is called by this class and its 64 // event to browser tests. This function is called by this class and its
65 // derived classes to report their status. This function does not do anything 65 // derived classes to report their status. This function does not do anything
66 // when we do not set an event to |status_event_|. 66 // when we do not set an event to |status_event_|.
67 static bool SignalStatusEvent(EventType type); 67 static bool SignalStatusEvent(EventType type);
68 68
69 // Instantiates SpellCheckHostMetrics object and makes it ready for recording 69 // Instantiates SpellCheckHostMetrics object and makes it ready for recording
70 // metrics. This should be called only if the metrics recording is active. 70 // metrics. This should be called only if the metrics recording is active.
71 void StartRecordingMetrics(bool spellcheck_enabled); 71 void StartRecordingMetrics(bool spellcheck_enabled);
72 72
73 // Pass all renderers some basic initialization infomration. 73 // Pass all renderers some basic initialization information.
74 void InitForAllRenderers(); 74 void InitForAllRenderers();
75 75
76 // Pass the renderer some basic intialization information. Note that the 76 // Pass the renderer some basic initialization information. Note that the
77 // renderer will not load Hunspell until it needs to. 77 // renderer will not load Hunspell until it needs to.
78 void InitForRenderer(content::RenderProcessHost* process); 78 void InitForRenderer(content::RenderProcessHost* process);
79 79
80 // Returns a metrics counter associated with this object, 80 // Returns a metrics counter associated with this object,
81 // or null when metrics recording is disabled. 81 // or null when metrics recording is disabled.
82 SpellCheckHostMetrics* GetMetrics() const; 82 SpellCheckHostMetrics* GetMetrics() const;
83 83
84 // Returns the instance of the custom dictionary. 84 // Returns the instance of the custom dictionary.
85 SpellcheckCustomDictionary* GetCustomDictionary(); 85 SpellcheckCustomDictionary* GetCustomDictionary();
86 86
87 // NotificationProfile implementation. 87 // NotificationProfile implementation.
88 virtual void Observe(int type, 88 virtual void Observe(int type,
89 const content::NotificationSource& source, 89 const content::NotificationSource& source,
90 const content::NotificationDetails& details) OVERRIDE; 90 const content::NotificationDetails& details) OVERRIDE;
91 91
92 // SpellcheckCustomDictionary::Observer implementation. 92 // SpellcheckCustomDictionary::Observer implementation.
93 virtual void OnCustomDictionaryLoaded() OVERRIDE; 93 virtual void OnCustomDictionaryLoaded() OVERRIDE;
94 virtual void OnCustomDictionaryWordAdded(const std::string& word) OVERRIDE; 94 virtual void OnCustomDictionaryChanged(
95 virtual void OnCustomDictionaryWordRemoved(const std::string& word) OVERRIDE; 95 const SpellcheckCustomDictionary::Change* dictionary_change) OVERRIDE;
groby-ooo-7-16 2013/01/15 01:19:20 I'd prefer this to be a const ref. (For one, this
please use gerrit instead 2013/01/16 02:06:05 Done.
96 96
97 private: 97 private:
98 FRIEND_TEST_ALL_PREFIXES(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT); 98 FRIEND_TEST_ALL_PREFIXES(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT);
99 99
100 // Attaches an event so browser tests can listen the status events. 100 // Attaches an event so browser tests can listen the status events.
101 static void AttachStatusEvent(base::WaitableEvent* status_event); 101 static void AttachStatusEvent(base::WaitableEvent* status_event);
102 102
103 // Waits until a spellchecker updates its status. This function returns 103 // Waits until a spellchecker updates its status. This function returns
104 // immediately when we do not set an event to |status_event_|. 104 // immediately when we do not set an event to |status_event_|.
105 static EventType WaitStatusEvent(); 105 static EventType WaitStatusEvent();
(...skipping 17 matching lines...) Expand all
123 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; 123 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_;
124 124
125 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; 125 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_;
126 126
127 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; 127 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); 129 DISALLOW_COPY_AND_ASSIGN(SpellcheckService);
130 }; 130 };
131 131
132 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ 132 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698