Index: chrome/browser/profiles/profile_destroyer.cc |
diff --git a/chrome/browser/profiles/profile_destroyer.cc b/chrome/browser/profiles/profile_destroyer.cc |
index 5ce9aaa4c3796ca8484347ef00281ce5a4f63b4b..91d795ba230f493da013c36770af8cf9983a2747 100644 |
--- a/chrome/browser/profiles/profile_destroyer.cc |
+++ b/chrome/browser/profiles/profile_destroyer.cc |
@@ -8,7 +8,12 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/message_loop.h" |
#include "base/trace_event/trace_event.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/user_manager.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/render_process_host.h" |
namespace { |
@@ -57,8 +62,9 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) { |
if (hosts.empty() || !profile->IsOffTheRecord()) { |
if (profile->IsOffTheRecord()) |
profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); |
- else |
+ else { DLOG(ERROR) << "Delete the profile! " << profile->GetPath().MaybeAsASCII(); |
delete profile; |
+ } |
} else { |
// The instance will destroy itself once all render process hosts referring |
// to it are properly terminated. |
@@ -89,6 +95,28 @@ void ProfileDestroyer::DestroyOffTheRecordProfileNow(Profile* const profile) { |
profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); |
} |
+// static |
+void ProfileDestroyer::DestroyGuestProfileIfAppropriate() { |
+ ProfileManager* profile_manager = g_browser_process->profile_manager(); |
+ DCHECK(profile_manager); |
+ Profile* guest_profile = profile_manager-> |
+ GetProfileByPath(ProfileManager::GetGuestProfilePath()); |
+ DLOG(ERROR) << "Calling DestroyGuestProfileIfAppropriate!"; |
+ if (!guest_profile) |
+ return; |
+ |
+ if (BrowserList::IsOffTheRecordSessionActiveForProfile(guest_profile)) |
+ return; |
+ |
+ DLOG(ERROR) << "Deleting the Guest Profile!"; |
+ |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&ProfileDestroyer::DestroyProfileWhenAppropriate, |
+ guest_profile)); |
+} |
+ |
ProfileDestroyer::ProfileDestroyer(Profile* const profile, HostSet* hosts) |
: timer_(false, false), |
num_hosts_(0), |
@@ -155,7 +183,7 @@ void ProfileDestroyer::DestroyProfile() { |
return; |
} |
- DCHECK(profile_->IsOffTheRecord()); |
+ DCHECK(profile_->IsOffTheRecord() || profile_->IsGuestSession()); |
DCHECK(profile_->GetOriginalProfile()); |
profile_->GetOriginalProfile()->DestroyOffTheRecordProfile(); |
profile_ = NULL; |