| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/translate/translate_manager.h" | 5 #include "chrome/browser/translate/translate_manager.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 540 } |
| 541 | 541 |
| 542 return iter->second.count(language) != 0; | 542 return iter->second.count(language) != 0; |
| 543 } | 543 } |
| 544 | 544 |
| 545 void TranslateManager::InitAcceptLanguages(PrefService* prefs) { | 545 void TranslateManager::InitAcceptLanguages(PrefService* prefs) { |
| 546 // We have been asked for this profile, build the languages. | 546 // We have been asked for this profile, build the languages. |
| 547 std::string accept_langs_str = prefs->GetString(prefs::kAcceptLanguages); | 547 std::string accept_langs_str = prefs->GetString(prefs::kAcceptLanguages); |
| 548 std::vector<std::string> accept_langs_list; | 548 std::vector<std::string> accept_langs_list; |
| 549 LanguageSet accept_langs_set; | 549 LanguageSet accept_langs_set; |
| 550 SplitString(accept_langs_str, ',', &accept_langs_list); | 550 base::SplitString(accept_langs_str, ',', &accept_langs_list); |
| 551 std::vector<std::string>::const_iterator iter; | 551 std::vector<std::string>::const_iterator iter; |
| 552 std::string ui_lang = | 552 std::string ui_lang = |
| 553 GetLanguageCode(g_browser_process->GetApplicationLocale()); | 553 GetLanguageCode(g_browser_process->GetApplicationLocale()); |
| 554 bool is_ui_english = StartsWithASCII(ui_lang, "en-", false); | 554 bool is_ui_english = StartsWithASCII(ui_lang, "en-", false); |
| 555 for (iter = accept_langs_list.begin(); | 555 for (iter = accept_langs_list.begin(); |
| 556 iter != accept_langs_list.end(); ++iter) { | 556 iter != accept_langs_list.end(); ++iter) { |
| 557 // Get rid of the locale extension if any (ex: en-US -> en), but for Chinese | 557 // Get rid of the locale extension if any (ex: en-US -> en), but for Chinese |
| 558 // for which the CLD reports zh-CN and zh-TW. | 558 // for which the CLD reports zh-CN and zh-TW. |
| 559 std::string accept_lang(*iter); | 559 std::string accept_lang(*iter); |
| 560 size_t index = iter->find("-"); | 560 size_t index = iter->find("-"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( | 610 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( |
| 611 TabContents* tab) { | 611 TabContents* tab) { |
| 612 for (int i = 0; i < tab->infobar_delegate_count(); ++i) { | 612 for (int i = 0; i < tab->infobar_delegate_count(); ++i) { |
| 613 TranslateInfoBarDelegate* delegate = | 613 TranslateInfoBarDelegate* delegate = |
| 614 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 614 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
| 615 if (delegate) | 615 if (delegate) |
| 616 return delegate; | 616 return delegate; |
| 617 } | 617 } |
| 618 return NULL; | 618 return NULL; |
| 619 } | 619 } |
| OLD | NEW |