OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/translate/core/browser/translate_accept_languages.h" | 5 #include "components/translate/core/browser/translate_accept_languages.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "components/translate/core/browser/translate_download_manager.h" | 11 #include "components/translate/core/browser/translate_download_manager.h" |
12 #include "components/translate/core/common/translate_util.h" | 12 #include "components/translate/core/common/translate_util.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 | 14 |
| 15 namespace translate { |
| 16 |
15 TranslateAcceptLanguages::TranslateAcceptLanguages( | 17 TranslateAcceptLanguages::TranslateAcceptLanguages( |
16 PrefService* prefs, | 18 PrefService* prefs, |
17 const char* accept_languages_pref) | 19 const char* accept_languages_pref) |
18 : accept_languages_pref_(accept_languages_pref) { | 20 : accept_languages_pref_(accept_languages_pref) { |
19 InitAcceptLanguages(prefs); | 21 InitAcceptLanguages(prefs); |
20 | 22 |
21 // Also start listening for changes in the accept languages. | 23 // Also start listening for changes in the accept languages. |
22 pref_change_registrar_.Init(prefs); | 24 pref_change_registrar_.Init(prefs); |
23 pref_change_registrar_.Add( | 25 pref_change_registrar_.Add( |
24 accept_languages_pref, | 26 accept_languages_pref, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // for which the CLD reports zh-CN and zh-TW. | 74 // for which the CLD reports zh-CN and zh-TW. |
73 std::string accept_lang(*iter); | 75 std::string accept_lang(*iter); |
74 size_t index = iter->find("-"); | 76 size_t index = iter->find("-"); |
75 if (index != std::string::npos && *iter != "zh-CN" && *iter != "zh-TW") | 77 if (index != std::string::npos && *iter != "zh-CN" && *iter != "zh-TW") |
76 accept_lang = iter->substr(0, index); | 78 accept_lang = iter->substr(0, index); |
77 | 79 |
78 accept_languages_.insert(accept_lang); | 80 accept_languages_.insert(accept_lang); |
79 } | 81 } |
80 } | 82 } |
81 | 83 |
| 84 } // namespace translate |
OLD | NEW |