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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_
7#pragma once
8
9#include "chrome/browser/chromeos/input_method/input_method_util.h"
10#include "chrome/browser/ui/webui/options/language_options_handler.h"
11
12namespace chromeos {
13
14// Language options page UI handler for Chrome OS.  For non-Chrome OS,
15// see LanguageOptionsHnadler.
16class CrosLanguageOptionsHandler : public LanguageOptionsHandlerCommon {
17 public:
18  CrosLanguageOptionsHandler();
19  virtual ~CrosLanguageOptionsHandler();
20
21  // OptionsPageUIHandler implementation.
22  virtual void GetLocalizedValues(DictionaryValue* localized_strings);
23
24  // DOMMessageHandler implementation.
25  virtual void RegisterMessages();
26
27  // The following static methods are public for ease of testing.
28
29  // Gets the list of input methods from the given input descriptors.
30  // The return value will look like:
31  // [{'id': 'pinyin', 'displayName': 'Pinyin',
32  //   'languageCodeSet': {'zh-CW': true}},  ...]
33  //
34  // Note that true in languageCodeSet does not mean anything. We just use
35  // the dictionary as a set.
36  static ListValue* GetInputMethodList(
37      const chromeos::InputMethodDescriptors& descriptors);
38
39  // Gets the list of languages from the given input descriptors.
40  // The return value will look like:
41  // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'},
42  //  ...]
43  static ListValue* GetLanguageList(
44      const chromeos::InputMethodDescriptors& descriptors);
45
46 private:
47  // LanguageOptionsHandlerCommon implementation.
48  virtual string16 GetProductName();
49  virtual void SetApplicationLocale(const std::string& language_code);
50
51  // Called when the sign-out button is clicked.
52  void RestartCallback(const ListValue* args);
53
54  // Called when the input method is disabled.
55  // |args| will contain the input method ID as string (ex. "mozc").
56  void InputMethodDisableCallback(const ListValue* args);
57
58  // Called when the input method is enabled.
59  // |args| will contain the input method ID as string (ex. "mozc").
60  void InputMethodEnableCallback(const ListValue* args);
61
62  // Called when the input method options page is opened.
63  // |args| will contain the input method ID as string (ex. "mozc").
64  void InputMethodOptionsOpenCallback(const ListValue* args);
65
66  DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler);
67};
68
69} // namespace chromeos
70
71#endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_
72