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_ui_delegate.h" | 5 #include "components/translate/core/browser/translate_ui_delegate.h" |
6 | 6 |
7 #include "base/i18n/string_compare.h" | 7 #include "base/i18n/string_compare.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "components/translate/core/browser/language_state.h" | 9 #include "components/translate/core/browser/language_state.h" |
10 #include "components/translate/core/browser/translate_client.h" | 10 #include "components/translate/core/browser/translate_client.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // null if unable to find the right collator. | 33 // null if unable to find the right collator. |
34 // | 34 // |
35 // TODO(hajimehoshi): Write a test for icu::Collator::createInstance. | 35 // TODO(hajimehoshi): Write a test for icu::Collator::createInstance. |
36 scoped_ptr<icu::Collator> CreateCollator(const std::string& locale) { | 36 scoped_ptr<icu::Collator> CreateCollator(const std::string& locale) { |
37 UErrorCode error = U_ZERO_ERROR; | 37 UErrorCode error = U_ZERO_ERROR; |
38 icu::Locale loc(locale.c_str()); | 38 icu::Locale loc(locale.c_str()); |
39 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(loc, error)); | 39 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(loc, error)); |
40 if (!collator || !U_SUCCESS(error)) | 40 if (!collator || !U_SUCCESS(error)) |
41 return nullptr; | 41 return nullptr; |
42 collator->setStrength(icu::Collator::PRIMARY); | 42 collator->setStrength(icu::Collator::PRIMARY); |
43 return collator.Pass(); | 43 return collator; |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 namespace translate { | 48 namespace translate { |
49 | 49 |
50 TranslateUIDelegate::TranslateUIDelegate( | 50 TranslateUIDelegate::TranslateUIDelegate( |
51 const base::WeakPtr<TranslateManager>& translate_manager, | 51 const base::WeakPtr<TranslateManager>& translate_manager, |
52 const std::string& original_language, | 52 const std::string& original_language, |
53 const std::string& target_language) | 53 const std::string& target_language) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true); | 298 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true); |
299 } | 299 } |
300 | 300 |
301 std::string TranslateUIDelegate::GetPageHost() { | 301 std::string TranslateUIDelegate::GetPageHost() { |
302 if (!translate_driver_->HasCurrentPage()) | 302 if (!translate_driver_->HasCurrentPage()) |
303 return std::string(); | 303 return std::string(); |
304 return translate_driver_->GetLastCommittedURL().HostNoBrackets(); | 304 return translate_driver_->GetLastCommittedURL().HostNoBrackets(); |
305 } | 305 } |
306 | 306 |
307 } // namespace translate | 307 } // namespace translate |
OLD | NEW |