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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month 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_HOST_IMPL_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_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/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/spellchecker/spellcheck_host.h" 14 #include "chrome/browser/spellchecker/spellcheck_host.h"
15 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" 15 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h"
16 #include "content/common/net/url_fetcher.h" 16 #include "content/public/common/url_fetcher_delegate.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 19
20 // This class implements the SpellCheckHost interface to provide the 20 // This class implements the SpellCheckHost interface to provide the
21 // functionalities listed below: 21 // functionalities listed below:
22 // * Adding a word to the custom dictionary; 22 // * Adding a word to the custom dictionary;
23 // * Storing the custom dictionary to the file, and read it back 23 // * Storing the custom dictionary to the file, and read it back
24 // from the file during the initialization. 24 // from the file during the initialization.
25 // * Downloading a dictionary and map it for the renderer, and; 25 // * Downloading a dictionary and map it for the renderer, and;
26 // * Calling the platform spellchecker attached to the browser; 26 // * Calling the platform spellchecker attached to the browser;
27 // 27 //
28 // To download a dictionary and initialize it without blocking the UI thread, 28 // To download a dictionary and initialize it without blocking the UI thread,
29 // this class also implements the URLFetcher::Delegate() interface. This 29 // this class also implements the URLFetcher::Delegate() interface. This
30 // initialization status is notified to the UI thread through the 30 // initialization status is notified to the UI thread through the
31 // SpellCheckProfileProvider interface. 31 // SpellCheckProfileProvider interface.
32 // 32 //
33 // We expect a profile creates an instance of this class through a factory 33 // We expect a profile creates an instance of this class through a factory
34 // method, SpellCheckHost::Create() and uses only the SpellCheckHost interface 34 // method, SpellCheckHost::Create() and uses only the SpellCheckHost interface
35 // provided by this class. 35 // provided by this class.
36 // spell_check_host_ = SpellCheckHost::Create(...) 36 // spell_check_host_ = SpellCheckHost::Create(...)
37 // 37 //
38 // Available languages for the checker, which we need to specify via Create(), 38 // Available languages for the checker, which we need to specify via Create(),
39 // can be listed using SpellCheckHost::GetAvailableLanguages() static method. 39 // can be listed using SpellCheckHost::GetAvailableLanguages() static method.
40 class SpellCheckHostImpl : public SpellCheckHost, 40 class SpellCheckHostImpl : public SpellCheckHost,
41 public URLFetcher::Delegate, 41 public content::URLFetcherDelegate,
42 public content::NotificationObserver { 42 public content::NotificationObserver {
43 public: 43 public:
44 SpellCheckHostImpl(SpellCheckProfileProvider* profile, 44 SpellCheckHostImpl(SpellCheckProfileProvider* profile,
45 const std::string& language, 45 const std::string& language,
46 net::URLRequestContextGetter* request_context_getter, 46 net::URLRequestContextGetter* request_context_getter,
47 SpellCheckHostMetrics* metrics); 47 SpellCheckHostMetrics* metrics);
48 48
49 void Initialize(); 49 void Initialize();
50 50
51 // SpellCheckHost implementation 51 // SpellCheckHost implementation
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Write a custom dictionary addition to disk. 95 // Write a custom dictionary addition to disk.
96 void WriteWordToCustomDictionary(const std::string& word); 96 void WriteWordToCustomDictionary(const std::string& word);
97 97
98 // Returns a metrics counter associated with this object, 98 // Returns a metrics counter associated with this object,
99 // or null when metrics recording is disabled. 99 // or null when metrics recording is disabled.
100 virtual SpellCheckHostMetrics* GetMetrics() const; 100 virtual SpellCheckHostMetrics* GetMetrics() const;
101 101
102 // Returns true if the dictionary is ready to use. 102 // Returns true if the dictionary is ready to use.
103 virtual bool IsReady() const; 103 virtual bool IsReady() const;
104 104
105 // URLFetcher::Delegate implementation. Called when we finish downloading the 105 // content::URLFetcherDelegate implementation. Called when we finish
106 // spellcheck dictionary; saves the dictionary to |data_|. 106 // downloading the spellcheck dictionary; saves the dictionary to |data_|.
107 virtual void OnURLFetchComplete(const URLFetcher* source, 107 virtual void OnURLFetchComplete(const URLFetcher* source);
108 const GURL& url,
109 const net::URLRequestStatus& status,
110 int response_code,
111 const net::ResponseCookies& cookies,
112 const std::string& data);
113 108
114 // NotificationProfile implementation. 109 // NotificationProfile implementation.
115 virtual void Observe(int type, 110 virtual void Observe(int type,
116 const content::NotificationSource& source, 111 const content::NotificationSource& source,
117 const content::NotificationDetails& details); 112 const content::NotificationDetails& details);
118 113
119 // Saves |data_| to disk. Run on the file thread. 114 // Saves |data_| to disk. Run on the file thread.
120 void SaveDictionaryData(); 115 void SaveDictionaryData();
121 116
122 // Verifies the specified BDict file exists and it is sane. This function 117 // Verifies the specified BDict file exists and it is sane. This function
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 153
159 content::NotificationRegistrar registrar_; 154 content::NotificationRegistrar registrar_;
160 155
161 // An optional metrics counter given by the constructor. 156 // An optional metrics counter given by the constructor.
162 SpellCheckHostMetrics* metrics_; 157 SpellCheckHostMetrics* metrics_;
163 158
164 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl); 159 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl);
165 }; 160 };
166 161
167 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 162 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698