OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 infobar = TranslateInfoBarDelegate::CreateDelegate( | 644 infobar = TranslateInfoBarDelegate::CreateDelegate( |
645 TranslateInfoBarDelegate::AFTER_TRANSLATE, tab, | 645 TranslateInfoBarDelegate::AFTER_TRANSLATE, tab, |
646 details->source_language, details->target_language); | 646 details->source_language, details->target_language); |
647 } | 647 } |
648 ShowInfoBar(tab, infobar); | 648 ShowInfoBar(tab, infobar); |
649 } | 649 } |
650 | 650 |
651 bool TranslateManager::IsAcceptLanguage(TabContents* tab, | 651 bool TranslateManager::IsAcceptLanguage(TabContents* tab, |
652 const std::string& language) { | 652 const std::string& language) { |
653 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); | 653 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
654 PrefService* pref_service = profile->GetOriginalProfile()->GetPrefs(); | 654 profile = profile->GetOriginalProfile(); |
| 655 PrefService* pref_service = profile->GetPrefs(); |
655 PrefServiceLanguagesMap::const_iterator iter = | 656 PrefServiceLanguagesMap::const_iterator iter = |
656 accept_languages_.find(pref_service); | 657 accept_languages_.find(pref_service); |
657 if (iter == accept_languages_.end()) { | 658 if (iter == accept_languages_.end()) { |
658 InitAcceptLanguages(pref_service); | 659 InitAcceptLanguages(pref_service); |
659 // Listen for this profile going away, in which case we would need to clear | 660 // Listen for this profile going away, in which case we would need to clear |
660 // the accepted languages for the profile. | 661 // the accepted languages for the profile. |
661 notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 662 notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
662 Source<Profile>(profile)); | 663 Source<Profile>(profile)); |
663 // Also start listening for changes in the accept languages. | 664 // Also start listening for changes in the accept languages. |
664 pref_change_registrar_.Add(prefs::kAcceptLanguages, this); | 665 pref_change_registrar_.Add(prefs::kAcceptLanguages, this); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 return NULL; | 791 return NULL; |
791 | 792 |
792 for (size_t i = 0; i < wrapper->infobar_count(); ++i) { | 793 for (size_t i = 0; i < wrapper->infobar_count(); ++i) { |
793 TranslateInfoBarDelegate* delegate = | 794 TranslateInfoBarDelegate* delegate = |
794 wrapper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 795 wrapper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
795 if (delegate) | 796 if (delegate) |
796 return delegate; | 797 return delegate; |
797 } | 798 } |
798 return NULL; | 799 return NULL; |
799 } | 800 } |
OLD | NEW |