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

Unified Diff: chrome/browser/spellcheck_host.h

Issue 357003: Move the spellchecker to the renderer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.cc ('k') | chrome/browser/spellcheck_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellcheck_host.h
===================================================================
--- chrome/browser/spellcheck_host.h (revision 0)
+++ chrome/browser/spellcheck_host.h (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SPELLCHECK_HOST_H_
+#define CHROME_BROWSER_SPELLCHECK_HOST_H_
+
+#include <string>
+#include <vector>
+
+#include "base/file_descriptor_posix.h"
+#include "base/file_path.h"
+#include "base/ref_counted.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/net/url_fetcher.h"
+
+class SpellCheckHost : public base::RefCountedThreadSafe<SpellCheckHost,
+ ChromeThread::DeleteOnFileThread>,
+ public URLFetcher::Delegate {
+ public:
+ class Observer {
+ public:
+ virtual void SpellCheckHostInitialized() = 0;
+ };
+
+ SpellCheckHost(Observer* observer,
+ const std::string& language,
+ URLRequestContextGetter* request_context_getter);
+
+ // Clear |observer_|. Used to prevent calling back to a deleted object.
+ void UnsetObserver();
+
+ // Add the given word to the custom words list and inform renderer of the
+ // update.
+ void AddWord(const std::string& word);
+
+ const base::FileDescriptor& bdict_fd() const { return fd_; };
+
+ const std::vector<std::string>& custom_words() const { return custom_words_; }
+
+ const std::string& last_added_word() const { return custom_words_.back(); }
+
+ const std::string& language() const { return language_; }
+
+ private:
+ // These two classes can destruct us.
+ friend class DeleteTask<SpellCheckHost>;
jam 2009/11/06 01:51:53 nit: order
+ friend class ChromeThread;
+ virtual ~SpellCheckHost();
+
+ // Load and parse the custom words dictionary and open the bdic file.
+ // Executed on the file thread.
+ void Initialize();
+
+ // Inform |observer_| that initialization has finished.
+ void InformObserverOfInitialization();
+
+ // If |bdict_file_| is missing, we attempt to download it.
+ void DownloadDictionary();
+
+ // Write a custom dictionary addition to disk.
+ void WriteWordToCustomDictionary(const std::string& word);
+
+ // URLFetcher::Delegate implementation. Called when we finish downloading the
+ // spellcheck dictionary; saves the dictionary to disk.
+ virtual void OnURLFetchComplete(const URLFetcher* source,
+ const GURL& url,
+ const URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const std::string& data);
+
+ // May be NULL.
+ Observer* observer_;
+
+ // The desired location of the dictionary file (whether or not it exists yet).
+ FilePath bdict_file_;
+
+ // The location of the custom words file.
+ FilePath custom_dictionary_file_;
+
+ // The language of the dictionary file.
+ std::string language_;
+
+ // On POSIX, the file descriptor for the dictionary file.
+ base::FileDescriptor fd_;
+
+ // In-memory cache of the custom words file.
+ std::vector<std::string> custom_words_;
+
+ // We don't want to attempt to download a missing dictionary file more than
+ // once.
+ bool tried_to_download_;
+
+ // Used for downloading the dictionary file.
+ URLRequestContextGetter* request_context_getter_;
+
+ // Used for downloading the dictionary file.
+ scoped_ptr<URLFetcher> fetcher_;
+};
+
+#endif // CHROME_BROWSER_SPELLCHECK_HOST_H_
Property changes on: chrome/browser/spellcheck_host.h
___________________________________________________________________
Added: svn:mergeinfo
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.cc ('k') | chrome/browser/spellcheck_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698