Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _ | 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 _ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _ |
| 7 | 7 |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/ui/webui/options/language_options_handler.h" | 12 #include "chrome/browser/ui/webui/options/language_options_handler.h" |
| 10 #include "chromeos/ime/component_extension_ime_manager.h" | 13 #include "chromeos/ime/component_extension_ime_manager.h" |
| 11 #include "chromeos/ime/input_method_descriptor.h" | 14 #include "chromeos/ime/input_method_descriptor.h" |
| 12 | 15 |
| 13 namespace chromeos { | 16 namespace chromeos { |
| 14 namespace options { | 17 namespace options { |
| 15 | 18 |
| 16 // GetUILanguageList() returns concatenated list of list of vendor languages | 19 // GetUILanguageList() returns a concatenated list of the most relevant |
| 17 // followed by other languages. An entry with "code" attribute set to this value | 20 // languages followed by all others. An entry with its "code" attribute set to |
| 18 // is inserted in between. | 21 // this value is inserted in between. |
| 19 extern const char kVendorOtherLanguagesListDivider[]; | 22 extern const char kMostRelevantLanguagesDivider[]; |
| 20 | 23 |
| 21 // Language options page UI handler for Chrome OS. For non-Chrome OS, | 24 // Language options page UI handler for Chrome OS. For non-Chrome OS, |
| 22 // see LanguageOptionsHnadler. | 25 // see LanguageOptionsHnadler. |
| 23 class CrosLanguageOptionsHandler | 26 class CrosLanguageOptionsHandler |
| 24 : public ::options::LanguageOptionsHandlerCommon, | 27 : public ::options::LanguageOptionsHandlerCommon, |
| 25 public ComponentExtensionIMEManager::Observer { | 28 public ComponentExtensionIMEManager::Observer { |
| 26 public: | 29 public: |
| 27 CrosLanguageOptionsHandler(); | 30 CrosLanguageOptionsHandler(); |
| 28 virtual ~CrosLanguageOptionsHandler(); | 31 virtual ~CrosLanguageOptionsHandler(); |
| 29 | 32 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 44 // Note that true in languageCodeSet does not mean anything. We just use | 47 // Note that true in languageCodeSet does not mean anything. We just use |
| 45 // the dictionary as a set. | 48 // the dictionary as a set. |
| 46 static base::ListValue* GetInputMethodList( | 49 static base::ListValue* GetInputMethodList( |
| 47 const input_method::InputMethodDescriptors& descriptors); | 50 const input_method::InputMethodDescriptors& descriptors); |
| 48 | 51 |
| 49 // Gets the list of accept languages with the given input descriptors. | 52 // Gets the list of accept languages with the given input descriptors. |
| 50 // Listed languages will be used as Accept-Language header. | 53 // Listed languages will be used as Accept-Language header. |
| 51 // The return value will look like: | 54 // The return value will look like: |
| 52 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, | 55 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, |
| 53 // ...] | 56 // ...] |
| 54 // "most relevant" languages, as set in initial_locale in VPD, will be first | 57 // The most relevant languages, as set in initial_locale in VPD, will be first |
| 55 // in the list. | 58 // in the list. |
| 56 static base::ListValue* GetAcceptLanguageList( | 59 static base::ListValue* GetAcceptLanguageList( |
| 57 const input_method::InputMethodDescriptors& descriptors); | 60 const input_method::InputMethodDescriptors& descriptors); |
| 58 | 61 |
| 59 // Gets the list of UI languages with the given input descriptors. | 62 // Gets the list of UI languages with the given input descriptors. |
| 60 // The return value will look like: | 63 // The return value will look like: |
| 61 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, | 64 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, |
| 62 // ...] | 65 // ...] |
| 63 // "most relevant" languages, as set in initial_locale in VPD, will be first | 66 // The |most_relevant_language_codes| will be first in the list. If |
| 64 // in the list. | 67 // |most_relevant_language_codes| is NULL, a list of most relevant languages |
| 65 // An entry with "code" attribute set to kVendorOtherLanguagesListDivider is | 68 // is read from initial_locale in VPD. An entry with its "code" attribute set |
| 66 // used as a divider to separate "most relevant" languages against other. | 69 // to kMostRelevantLanguagesDivider is inserted between the most relevant |
| 70 // languages and all others. | |
| 67 static base::ListValue* GetUILanguageList( | 71 static base::ListValue* GetUILanguageList( |
|
Nikita (slow)
2014/07/17 06:14:54
How about moving GetUILanguageList/GetLanguageList
bartfab (slow)
2014/07/21 14:28:29
Done.
| |
| 68 const input_method::InputMethodDescriptors& descriptors); | 72 const input_method::InputMethodDescriptors& descriptors, |
| 73 const std::vector<std::string>* most_relevant_language_codes); | |
| 69 | 74 |
| 70 // Converts input method descriptors to the list of input methods. | 75 // Converts input method descriptors to the list of input methods. |
| 71 // The return value will look like: | 76 // The return value will look like: |
| 72 // [{'id': '_ext_ime_nejguenhnsnjnwychcnsdsdjketest', | 77 // [{'id': '_ext_ime_nejguenhnsnjnwychcnsdsdjketest', |
| 73 // 'displayName': 'Sample IME'}, ...] | 78 // 'displayName': 'Sample IME'}, ...] |
| 74 static base::ListValue* ConvertInputMethodDescriptorsToIMEList( | 79 static base::ListValue* ConvertInputMethodDescriptorsToIMEList( |
| 75 const input_method::InputMethodDescriptors& descriptors); | 80 const input_method::InputMethodDescriptors& descriptors); |
| 76 | 81 |
| 77 private: | 82 private: |
| 78 // LanguageOptionsHandlerCommon implementation. | 83 // LanguageOptionsHandlerCommon implementation. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 91 void InputMethodEnableCallback(const base::ListValue* args); | 96 void InputMethodEnableCallback(const base::ListValue* args); |
| 92 | 97 |
| 93 // Called when the input method options page is opened. | 98 // Called when the input method options page is opened. |
| 94 // |args| will contain the input method ID as string (ex. "mozc"). | 99 // |args| will contain the input method ID as string (ex. "mozc"). |
| 95 void InputMethodOptionsOpenCallback(const base::ListValue* args); | 100 void InputMethodOptionsOpenCallback(const base::ListValue* args); |
| 96 | 101 |
| 97 // ComponentExtensionIMEManager::Observer override. | 102 // ComponentExtensionIMEManager::Observer override. |
| 98 virtual void OnImeComponentExtensionInitialized() OVERRIDE; | 103 virtual void OnImeComponentExtensionInitialized() OVERRIDE; |
| 99 | 104 |
| 100 // Gets the list of languages with |descriptors| based on | 105 // Gets the list of languages with |descriptors| based on |
| 101 // |base_language_codes|. | 106 // |base_language_codes|. The |most_relevant_language_codes| will be first in |
| 102 // |insert_divider| means to insert entry with "code" attribute set to | 107 // the list. If |insert_divider| is true, an entry with its "code" attribute |
| 103 // kVendorOtherLanguagesListDivider between "most relevant" languages and | 108 // set to kMostRelevantLanguagesDivider is placed between the most relevant |
| 104 // other. | 109 // languages and all others. |
| 105 static base::ListValue* GetLanguageListInternal( | 110 static base::ListValue* GetLanguageListInternal( |
| 106 const input_method::InputMethodDescriptors& descriptors, | 111 const input_method::InputMethodDescriptors& descriptors, |
| 107 const std::vector<std::string>& base_language_codes, | 112 const std::vector<std::string>& base_language_codes, |
| 113 const std::vector<std::string>& most_relevant_language_codes, | |
| 108 bool insert_divider); | 114 bool insert_divider); |
| 109 | 115 |
| 110 // OptionsPageUIHandler implementation. | 116 // OptionsPageUIHandler implementation. |
| 111 virtual void InitializePage() OVERRIDE; | 117 virtual void InitializePage() OVERRIDE; |
| 112 | 118 |
| 113 // Adds the name of the extension that provides the IME to each entry in the | 119 // Adds the name of the extension that provides the IME to each entry in the |
| 114 // |list| of extension IMEs. | 120 // |list| of extension IMEs. |
| 115 void AddImeProvider(base::ListValue* list); | 121 void AddImeProvider(base::ListValue* list); |
| 116 | 122 |
| 117 // True if the component extension list was appended into input method list. | 123 // True if the component extension list was appended into input method list. |
| 118 bool composition_extension_appended_; | 124 bool composition_extension_appended_; |
| 119 | 125 |
| 120 // True if this page was initialized. | 126 // True if this page was initialized. |
| 121 bool is_page_initialized_; | 127 bool is_page_initialized_; |
| 122 | 128 |
| 123 DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler); | 129 DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler); |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } // namespace options | 132 } // namespace options |
| 127 } // namespace chromeos | 133 } // namespace chromeos |
| 128 | 134 |
| 129 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLE R_H_ | 135 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLE R_H_ |
| OLD | NEW |