Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / language_options_handler_common.h
blob65b45cfd425950f404a37bf1c39d9fdef04bb0c0
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
10 #include "chrome/browser/ui/webui/options/options_ui.h"
12 namespace base {
13 class DictionaryValue;
14 class ListValue;
17 namespace options {
19 // The base class for language options page UI handlers. This class has code
20 // common to the Chrome OS and non-Chrome OS implementation of the handler.
21 class LanguageOptionsHandlerCommon
22 : public OptionsPageUIHandler,
23 public SpellcheckHunspellDictionary::Observer {
24 public:
25 LanguageOptionsHandlerCommon();
26 virtual ~LanguageOptionsHandlerCommon();
28 // OptionsPageUIHandler implementation.
29 virtual void GetLocalizedValues(
30 base::DictionaryValue* localized_strings) OVERRIDE;
31 virtual void Uninitialize() OVERRIDE;
33 // DOMMessageHandler implementation.
34 virtual void RegisterMessages() OVERRIDE;
36 // SpellcheckHunspellDictionary::Observer implementation.
37 virtual void OnHunspellDictionaryInitialized() OVERRIDE;
38 virtual void OnHunspellDictionaryDownloadBegin() OVERRIDE;
39 virtual void OnHunspellDictionaryDownloadSuccess() OVERRIDE;
40 virtual void OnHunspellDictionaryDownloadFailure() OVERRIDE;
42 // The following static methods are public for ease of testing.
44 // Gets the set of language codes that can be used as UI language.
45 // The return value will look like:
46 // {'en-US': true, 'fi': true, 'fr': true, ...}
48 // Note that true in values does not mean anything. We just use the
49 // dictionary as a set.
50 static base::DictionaryValue* GetUILanguageCodeSet();
52 // Gets the set of language codes that can be used for spellchecking.
53 // The return value will look like:
54 // {'en-US': true, 'fi': true, 'fr': true, ...}
56 // Note that true in values does not mean anything. We just use the
57 // dictionary as a set.
58 static base::DictionaryValue* GetSpellCheckLanguageCodeSet();
60 private:
61 // Returns the name of the product (ex. "Chrome" or "Chrome OS").
62 virtual base::string16 GetProductName() = 0;
64 // Sets the application locale.
65 virtual void SetApplicationLocale(const std::string& language_code) = 0;
67 // Called when the language options is opened.
68 void LanguageOptionsOpenCallback(const base::ListValue* args);
70 // Called when the UI language is changed.
71 // |args| will contain the language code as string (ex. "fr").
72 void UiLanguageChangeCallback(const base::ListValue* args);
74 // Called when the spell check language is changed.
75 // |args| will contain the language code as string (ex. "fr").
76 void SpellCheckLanguageChangeCallback(const base::ListValue* args);
78 // Called when the user clicks "Retry" button for a spellcheck dictionary that
79 // has failed to download.
80 void RetrySpellcheckDictionaryDownload(const base::ListValue* args);
82 // Called when the user saves the language list preferences.
83 void UpdateLanguageListCallback(const base::ListValue* args);
85 // Updates the hunspell dictionary that is used for spellchecking.
86 void RefreshHunspellDictionary();
88 // Returns the hunspell dictionary that is used for spellchecking. Never null.
89 base::WeakPtr<SpellcheckHunspellDictionary>& GetHunspellDictionary();
91 // The hunspell dictionary that is used for spellchecking. Might be null.
92 base::WeakPtr<SpellcheckHunspellDictionary> hunspell_dictionary_;
94 DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandlerCommon);
97 } // namespace options
99 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_