spellchecker_platform_engine.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file defines the interface that any platform-specific spellchecker
6// needs to implement in order to be used by the browser.
7
8#ifndef CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_
9#define CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_
10#pragma once
11
12#include <string>
13#include <vector>
14
15#include "base/string16.h"
16
17namespace SpellCheckerPlatform {
18
19// Get the languages supported by the platform spellchecker and store them in
20// |spellcheck_languages|. Note that they must be converted to
21// Chromium style codes (en-US not en_US). See spellchecker.cc for a full list.
22void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages);
23
24// Returns true if there is a platform-specific spellchecker that can be used.
25bool SpellCheckerAvailable();
26
27// Returns true if the platform spellchecker has a spelling panel.
28bool SpellCheckerProvidesPanel();
29
30// Returns true if the platform spellchecker panel is visible.
31bool SpellingPanelVisible();
32
33// Shows the spelling panel if |show| is true and hides it if it is not.
34void ShowSpellingPanel(bool show);
35
36// Changes the word show in the spelling panel to be |word|. Note that the
37// spelling panel need not be displayed for this to work.
38void UpdateSpellingPanelWithMisspelledWord(const string16& word);
39
40// Do any initialization needed for spellchecker.
41void Init();
42// TODO(pwicks): should we add a companion to this, TearDown or something?
43
44// Translates the codes used by chrome to the language codes used by os x
45// and checks the given language agains the languages that the current system
46// supports. If the platform-specific spellchecker supports the language,
47// then returns true, otherwise false.
48bool PlatformSupportsLanguage(const std::string& current_language);
49
50// Sets the language for the platform-specific spellchecker.
51void SetLanguage(const std::string& lang_to_set);
52
53// Checks the spelling of the given string, using the platform-specific
54// spellchecker. Returns true if the word is spelled correctly.
55bool CheckSpelling(const string16& word_to_check, int tag);
56
57// Fills the given vector |optional_suggestions| with a number (up to
58// kMaxSuggestions, which is defined in spellchecker_common.h) of suggestions
59// for the string |wrong_word|.
60void FillSuggestionList(const string16& wrong_word,
61                        std::vector<string16>* optional_suggestions);
62
63// Adds the given word to the platform dictionary.
64void AddWord(const string16& word);
65
66// Remove a given word from the platform dictionary.
67void RemoveWord(const string16& word);
68
69// Gets a unique tag to identify a document. Used in ignoring words.
70int GetDocumentTag();
71
72// Tells the platform spellchecker to ignore a word. This doesn't take a tag
73// because in most of the situations in which it is called, the only way to know
74// the tag for sure is to ask the renderer, which would mean blocking in the
75// browser, so (on the mac, anyway) we remember the most recent tag and use
76// it, since it should always be from the same document.
77void IgnoreWord(const string16& word);
78
79// Tells the platform spellchecker that a document associated with a tag has
80// closed. Generally, this means that any ignored words associated with that
81// document can now be forgotten.
82void CloseDocumentWithTag(int tag);
83
84}  // namespace SpellCheckerPlatform
85
86#endif  // CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_
87