diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 16:23:10 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 16:23:10 +0000 |
commit | ad6700608c48f3c48624baf3b3b8cf5c919705cb (patch) | |
tree | 463da13dd8d1a6fcf624bdf06f299d25a82679f2 /chrome | |
parent | 7f90af2d38c31478321a2666f034ec285ad98c80 (diff) | |
download | chromium_src-ad6700608c48f3c48624baf3b3b8cf5c919705cb.zip chromium_src-ad6700608c48f3c48624baf3b3b8cf5c919705cb.tar.gz chromium_src-ad6700608c48f3c48624baf3b3b8cf5c919705cb.tar.bz2 |
Delete GlobarError and Protector only after the error was removed from global list.
BUG=None
TEST=Make Protector bubble appear, click on Go to settings, then on Wrench menu button. Chrome should not crash.
Review URL: http://codereview.chromium.org/8384036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 11 insertions, 3 deletions
diff --git a/chrome/browser/protector/protector.cc b/chrome/browser/protector/protector.cc index 1b2d041..df21493 100644 --- a/chrome/browser/protector/protector.cc +++ b/chrome/browser/protector/protector.cc @@ -57,13 +57,16 @@ void Protector::OnDecisionTimeout() { OnChangesAction(&SettingChange::DoDefault); } +void Protector::OnRemovedFromProfile() { + BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); +} + void Protector::OnChangesAction(SettingChangeAction action) { DCHECK(error_.get()); SettingChangeVector* changes = error_->mutable_changes(); for (SettingChangeVector::iterator it = changes->begin(); it != changes->end(); ++it) ((*it)->*action)(this); - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); } diff --git a/chrome/browser/protector/protector.h b/chrome/browser/protector/protector.h index 9ef5142..38bf6c4 100644 --- a/chrome/browser/protector/protector.h +++ b/chrome/browser/protector/protector.h @@ -44,6 +44,7 @@ class Protector : public SettingsChangeGlobalErrorDelegate { virtual void OnApplyChanges() OVERRIDE; virtual void OnDiscardChanges() OVERRIDE; virtual void OnDecisionTimeout() OVERRIDE; + virtual void OnRemovedFromProfile() OVERRIDE; private: friend class DeleteTask<Protector>; diff --git a/chrome/browser/protector/settings_change_global_error.cc b/chrome/browser/protector/settings_change_global_error.cc index 97b72ad..113f29c 100644 --- a/chrome/browser/protector/settings_change_global_error.cc +++ b/chrome/browser/protector/settings_change_global_error.cc @@ -153,17 +153,17 @@ bool SettingsChangeGlobalError::IsAcceptButtonDefault() { } void SettingsChangeGlobalError::BubbleViewAcceptButtonPressed() { + closed_by_button_ = true; DCHECK(delegate_); VLOG(1) << "Apply changes"; delegate_->OnApplyChanges(); - closed_by_button_ = true; } void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { + closed_by_button_ = true; DCHECK(delegate_); VLOG(1) << "Discard changes"; delegate_->OnDiscardChanges(); - closed_by_button_ = true; } void SettingsChangeGlobalError::RemoveFromProfile() { @@ -172,6 +172,7 @@ void SettingsChangeGlobalError::RemoveFromProfile() { GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); if (!closed_by_button_) delegate_->OnDecisionTimeout(); + delegate_->OnRemovedFromProfile(); } void SettingsChangeGlobalError::BubbleViewDidClose() { diff --git a/chrome/browser/protector/settings_change_global_error_delegate.h b/chrome/browser/protector/settings_change_global_error_delegate.h index e761850..5ac2240 100644 --- a/chrome/browser/protector/settings_change_global_error_delegate.h +++ b/chrome/browser/protector/settings_change_global_error_delegate.h @@ -24,6 +24,9 @@ class SettingsChangeGlobalErrorDelegate { // Called if user clicked outside the bubble and timeout for its reshow // has passed. virtual void OnDecisionTimeout() = 0; + + // Called when error is removed from profile so it's safe to delete it. + virtual void OnRemovedFromProfile() = 0; }; } // namespace protector |