Remove obsolete for_web_contents parameter in FontRenderParamsQuery.
[chromium-blink-merge.git] / chrome / installer / util / language_selector.h
blobf9b991bd0db3fd856e62927be912b3bdb72762da
1 // Copyright (c) 2010 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 declares a helper class for selecting a supported language from a
6 // set of candidates.
8 #ifndef CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
9 #define CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
11 #include <string>
12 #include <vector>
14 #include "base/basictypes.h"
16 namespace installer {
18 // A helper class for selecting a supported language from a set of candidates.
19 // By default, the candidates are retrieved from the operating system.
20 class LanguageSelector {
21 public:
22 // Default constructor will select from the set of languages supported by the
23 // operating system.
24 LanguageSelector();
26 // Constructor for testing purposes.
27 explicit LanguageSelector(const std::vector<std::wstring>& candidates);
29 ~LanguageSelector();
31 // The offset of the matched language (i.e., IDS_L10N_OFFSET_*).
32 int offset() const { return offset_; }
34 // The full name of the candidate language for which a match was found.
35 const std::wstring& matched_candidate() const { return matched_candidate_; }
37 // The name of the selected translation.
38 std::wstring selected_translation() const { return GetLanguageName(offset_); }
40 // Returns the name of a translation given its offset.
41 static std::wstring GetLanguageName(int offset);
43 private:
44 typedef bool (*SelectPred_Fn)(const std::wstring&, int*);
46 static bool SelectIf(const std::vector<std::wstring>& candidates,
47 SelectPred_Fn select_predicate,
48 std::wstring* matched_name, int* matched_offset);
49 void DoSelect(const std::vector<std::wstring>& candidates);
51 std::wstring matched_candidate_;
52 int offset_;
54 DISALLOW_COPY_AND_ASSIGN(LanguageSelector);
57 } // namespace installer.
59 #endif // CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_