Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5403)

Unified Diff: chrome/browser/translate/translate_manager.cc

Issue 7669051: Fixed crash on TranslateManager with multiple profiles. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/translate/translate_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/translate/translate_manager.cc
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index b75fe3af305768950991891bbe0a6e562f1f1031..66c91e862994a3cc7d6f8e7e4f04c1a6a51a7ee7 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -326,15 +326,19 @@ void TranslateManager::Observe(int type,
break;
}
case chrome::NOTIFICATION_PROFILE_DESTROYED: {
- Profile* profile = Source<Profile>(source).ptr();
+ PrefService* pref_service = Source<Profile>(source).ptr()->GetPrefs();
notification_registrar_.Remove(this,
chrome::NOTIFICATION_PROFILE_DESTROYED,
source);
- size_t count = accept_languages_.erase(profile->GetPrefs());
+ size_t count = accept_languages_.erase(pref_service);
// We should know about this profile since we are listening for
// notifications on it.
- DCHECK(count > 0);
- pref_change_registrar_.Remove(prefs::kAcceptLanguages, this);
+ DCHECK(count == 1u);
+ PrefChangeRegistrar* pref_change_registrar =
+ pref_change_registrars_[pref_service];
+ count = pref_change_registrars_.erase(pref_service);
+ DCHECK(count == 1u);
+ delete pref_change_registrar;
break;
}
case chrome::NOTIFICATION_PREF_CHANGED: {
@@ -443,8 +447,6 @@ void TranslateManager::InitiateTranslation(TabContents* tab,
if (!prefs->GetBoolean(prefs::kEnableTranslate))
return;
- pref_change_registrar_.Init(prefs);
-
// Allow disabling of translate from the command line to assist with
// automated browser testing.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableTranslate))
@@ -662,7 +664,12 @@ bool TranslateManager::IsAcceptLanguage(TabContents* tab,
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
Source<Profile>(profile));
// Also start listening for changes in the accept languages.
- pref_change_registrar_.Add(prefs::kAcceptLanguages, this);
+ DCHECK(pref_change_registrars_.find(pref_service) ==
+ pref_change_registrars_.end());
+ PrefChangeRegistrar* pref_change_registrar = new PrefChangeRegistrar;
+ pref_change_registrar->Init(pref_service);
+ pref_change_registrar->Add(prefs::kAcceptLanguages, this);
+ pref_change_registrars_[pref_service] = pref_change_registrar;
iter = accept_languages_.find(pref_service);
}
« no previous file with comments | « chrome/browser/translate/translate_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698