diff options
author | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 00:30:04 +0000 |
---|---|---|
committer | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 00:30:04 +0000 |
commit | 0ed0b7e7673321d88c2aacdd1034086e138a6688 (patch) | |
tree | 10b06a80ecc15de1d74f352ac6b1edf6484262c9 | |
parent | f2f3a5c60e21cba9c37c7b182c073e671785d4f2 (diff) | |
download | chromium_src-0ed0b7e7673321d88c2aacdd1034086e138a6688.zip chromium_src-0ed0b7e7673321d88c2aacdd1034086e138a6688.tar.gz chromium_src-0ed0b7e7673321d88c2aacdd1034086e138a6688.tar.bz2 |
Refactor TabModel to not hold a profile.
If we close all of the tabs in the incognito profile, the profile goes
away. We need to not cache the profile as we have a bad pointer.
BUG=
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11417089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168930 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 15 insertions, 8 deletions
diff --git a/chrome/browser/sync/glue/synced_window_delegate_android.cc b/chrome/browser/sync/glue/synced_window_delegate_android.cc index 68ef69a..4d8f4ba 100644 --- a/chrome/browser/sync/glue/synced_window_delegate_android.cc +++ b/chrome/browser/sync/glue/synced_window_delegate_android.cc @@ -44,7 +44,7 @@ SyncedWindowDelegateAndroid::SyncedWindowDelegateAndroid( SyncedWindowDelegateAndroid::~SyncedWindowDelegateAndroid() {} bool SyncedWindowDelegateAndroid::HasWindow() const { - return !tab_model_->GetProfile()->IsOffTheRecord(); + return !tab_model_->IsOffTheRecord(); } SessionID::id_type SyncedWindowDelegateAndroid::GetSessionId() const { diff --git a/chrome/browser/ui/android/tab_model/tab_model.cc b/chrome/browser/ui/android/tab_model/tab_model.cc index 57f6fff..5bf6a80 100644 --- a/chrome/browser/ui/android/tab_model/tab_model.cc +++ b/chrome/browser/ui/android/tab_model/tab_model.cc @@ -23,9 +23,12 @@ TabModel::~TabModel() { } void TabModel::BroadcastSessionRestoreComplete() { - DCHECK(GetProfile()); - NotificationService::current()->Notify( - chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE, - content::Source<Profile>(GetProfile()), - NotificationService::NoDetails()); + if (GetProfile()) { + NotificationService::current()->Notify( + chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE, + content::Source<Profile>(GetProfile()), + NotificationService::NoDetails()); + } else { + NOTREACHED(); + } } diff --git a/chrome/browser/ui/android/tab_model/tab_model.h b/chrome/browser/ui/android/tab_model/tab_model.h index 9c8dc7d..e1e40ee 100644 --- a/chrome/browser/ui/android/tab_model/tab_model.h +++ b/chrome/browser/ui/android/tab_model/tab_model.h @@ -39,6 +39,7 @@ class TabModel { virtual void OpenClearBrowsingData() const = 0; virtual Profile* GetProfile() const = 0; + virtual bool IsOffTheRecord() const = 0; virtual browser_sync::SyncedWindowDelegate* GetSyncedWindowDelegate() = 0; diff --git a/chrome/browser/ui/android/tab_model/tab_model_list.cc b/chrome/browser/ui/android/tab_model/tab_model_list.cc index 7afce2e..aecd9e4 100644 --- a/chrome/browser/ui/android/tab_model/tab_model_list.cc +++ b/chrome/browser/ui/android/tab_model/tab_model_list.cc @@ -34,9 +34,12 @@ void TabModelList::RemoveTabModel(TabModel* tab_model) { TabModel* TabModelList::GetTabModelWithProfile( Profile* profile) { + if (!profile) + return NULL; + for (TabModelList::const_iterator i = TabModelList::begin(); i != TabModelList::end(); ++i) { - if ((*i)->GetProfile()->IsSameProfile(profile)) + if (profile->IsSameProfile((*i)->GetProfile())) return *i; } @@ -57,7 +60,7 @@ TabModel* TabModelList::FindTabModelWithId( bool TabModelList::IsOffTheRecordSessionActive() { for (TabModelList::const_iterator i = TabModelList::begin(); i != TabModelList::end(); i++) { - if ((*i)->GetProfile()->IsOffTheRecord() && (*i)->GetTabCount() > 0) + if ((*i)->IsOffTheRecord() && (*i)->GetTabCount() > 0) return true; } |