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_manager.h" | 5 #include "components/translate/core/browser/translate_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Don't translate any Chrome specific page, e.g., New Tab Page, Download, | 137 // Don't translate any Chrome specific page, e.g., New Tab Page, Download, |
138 // History, and so on. | 138 // History, and so on. |
139 const GURL& page_url = translate_driver_->GetVisibleURL(); | 139 const GURL& page_url = translate_driver_->GetVisibleURL(); |
140 if (!translate_client_->IsTranslatableURL(page_url)) { | 140 if (!translate_client_->IsTranslatableURL(page_url)) { |
141 TranslateBrowserMetrics::ReportInitiationStatus( | 141 TranslateBrowserMetrics::ReportInitiationStatus( |
142 TranslateBrowserMetrics::INITIATION_STATUS_URL_IS_NOT_SUPPORTED); | 142 TranslateBrowserMetrics::INITIATION_STATUS_URL_IS_NOT_SUPPORTED); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 // Get the accepted languages list. | 146 // Get the accepted languages list. |
147 std::vector<std::string> accept_languages_list; | 147 std::vector<std::string> accept_languages_list = base::SplitString( |
148 base::SplitString(prefs->GetString(accept_languages_pref_name_.c_str()), ',', | 148 prefs->GetString(accept_languages_pref_name_), ",", |
149 &accept_languages_list); | 149 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
150 | 150 |
151 std::string target_lang = GetTargetLanguage(accept_languages_list); | 151 std::string target_lang = GetTargetLanguage(accept_languages_list); |
152 std::string language_code = | 152 std::string language_code = |
153 TranslateDownloadManager::GetLanguageCode(page_lang); | 153 TranslateDownloadManager::GetLanguageCode(page_lang); |
154 | 154 |
155 // Don't translate similar languages (ex: en-US to en). | 155 // Don't translate similar languages (ex: en-US to en). |
156 if (language_code == target_lang) { | 156 if (language_code == target_lang) { |
157 TranslateBrowserMetrics::ReportInitiationStatus( | 157 TranslateBrowserMetrics::ReportInitiationStatus( |
158 TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES); | 158 TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES); |
159 return; | 159 return; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 | 404 |
405 bool TranslateManager::ignore_missing_key_for_testing_ = false; | 405 bool TranslateManager::ignore_missing_key_for_testing_ = false; |
406 | 406 |
407 // static | 407 // static |
408 void TranslateManager::SetIgnoreMissingKeyForTesting(bool ignore) { | 408 void TranslateManager::SetIgnoreMissingKeyForTesting(bool ignore) { |
409 ignore_missing_key_for_testing_ = ignore; | 409 ignore_missing_key_for_testing_ = ignore; |
410 } | 410 } |
411 | 411 |
412 } // namespace translate | 412 } // namespace translate |
OLD | NEW |