summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-21 04:49:51 +0000
committertedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-21 04:49:51 +0000
commita4c81ac834818aad6b4f6f5e0f5e76553490fe98 (patch)
tree0e9996a1afc36a4dab48dce3cdb319fab6f759ad
parent36e45b8eb00d815bf045afb7377ef734428537a4 (diff)
downloadchromium_src-a4c81ac834818aad6b4f6f5e0f5e76553490fe98.zip
chromium_src-a4c81ac834818aad6b4f6f5e0f5e76553490fe98.tar.gz
chromium_src-a4c81ac834818aad6b4f6f5e0f5e76553490fe98.tar.bz2
Fix the off the record profile reference in Android's TabModel.
BUG= Review URL: https://chromiumcodereview.appspot.com/12611023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189526 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/android/tab_model/tab_model.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/chrome/browser/ui/android/tab_model/tab_model.cc b/chrome/browser/ui/android/tab_model/tab_model.cc
index b4fdd1b..9ecf372 100644
--- a/chrome/browser/ui/android/tab_model/tab_model.cc
+++ b/chrome/browser/ui/android/tab_model/tab_model.cc
@@ -33,7 +33,9 @@ TabModel::TabModel(Profile* profile)
// incognito tabs. We therefore must listen for when this happens, and
// remove our pointer to the profile accordingly.
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
- content::Source<Profile>(profile_));
+ content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
+ content::NotificationService::AllSources());
} else {
is_off_the_record_ = false;
}
@@ -117,6 +119,17 @@ void TabModel::Observe(
// Our profile just got destroyed, so we delete our pointer to it.
profile_ = NULL;
break;
+ case chrome::NOTIFICATION_PROFILE_CREATED:
+ // Our incognito tab model out lives the profile, so we need to recapture
+ // the pointer if ours was previously deleted.
+ // NOTIFICATION_PROFILE_DESTROYED is not sent for every destruction, so
+ // we overwrite the pointer regardless of whether it's NULL.
+ if (is_off_the_record_) {
+ Profile* profile = content::Source<Profile>(source).ptr();
+ if (profile && profile->IsOffTheRecord())
+ profile_ = profile;
+ }
+ break;
default:
NOTREACHED();
}