OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" | 5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 108 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
109 PluginPrefs::GetForProfile(this), &GetResourceContext()); | 109 PluginPrefs::GetForProfile(this), &GetResourceContext()); |
110 | 110 |
111 BrowserThread::PostTask( | 111 BrowserThread::PostTask( |
112 BrowserThread::IO, FROM_HERE, | 112 BrowserThread::IO, FROM_HERE, |
113 NewRunnableFunction( | 113 NewRunnableFunction( |
114 &NotifyOTRProfileCreatedOnIOThread, profile_, this)); | 114 &NotifyOTRProfileCreatedOnIOThread, profile_, this)); |
115 } | 115 } |
116 | 116 |
117 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 117 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |
| 118 // Shutdown the DownloadManager here in the dtor as ProfileImpl does to |
| 119 // guarantee that it happens before the last scoped_refptr<DM> is reaped. |
| 120 // DownloadManager is lazily created, so check before accessing it. |
| 121 if (download_manager_.get()) { |
| 122 // Drop our download manager so we forget about all the downloads made |
| 123 // in incognito mode. |
| 124 download_manager_->Shutdown(); |
| 125 download_manager_ = NULL; |
| 126 } |
| 127 |
118 NotificationService::current()->Notify( | 128 NotificationService::current()->Notify( |
119 chrome::NOTIFICATION_PROFILE_DESTROYED, Source<Profile>(this), | 129 chrome::NOTIFICATION_PROFILE_DESTROYED, Source<Profile>(this), |
120 NotificationService::NoDetails()); | 130 NotificationService::NoDetails()); |
121 | 131 |
122 // There shouldn't be any browser window associated with this profile. | 132 // There shouldn't be any browser window associated with this profile. |
123 CHECK(!BrowserList::FindBrowserWithProfile(this)); | 133 CHECK(!BrowserList::FindBrowserWithProfile(this)); |
124 | 134 |
125 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 135 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
126 &GetResourceContext()); | 136 &GetResourceContext()); |
127 | 137 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 void OffTheRecordProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { | 542 void OffTheRecordProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { |
533 profile_->SetupChromeOSEnterpriseExtensionObserver(); | 543 profile_->SetupChromeOSEnterpriseExtensionObserver(); |
534 } | 544 } |
535 | 545 |
536 void OffTheRecordProfileImpl::InitChromeOSPreferences() { | 546 void OffTheRecordProfileImpl::InitChromeOSPreferences() { |
537 // The incognito profile shouldn't have Chrome OS's preferences. | 547 // The incognito profile shouldn't have Chrome OS's preferences. |
538 // The preferences are associated with the regular user profile. | 548 // The preferences are associated with the regular user profile. |
539 } | 549 } |
540 #endif // defined(OS_CHROMEOS) | 550 #endif // defined(OS_CHROMEOS) |
541 | 551 |
542 void OffTheRecordProfileImpl::ExitedOffTheRecordMode() { | |
543 // DownloadManager is lazily created, so check before accessing it. | |
544 if (download_manager_.get()) { | |
545 // Drop our download manager so we forget about all the downloads made | |
546 // in incognito mode. | |
547 download_manager_->Shutdown(); | |
548 download_manager_ = NULL; | |
549 } | |
550 } | |
551 | |
552 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { | 552 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { |
553 } | 553 } |
554 | 554 |
555 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { | 555 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { |
556 if (BrowserList::GetBrowserCount(this) == 0) | |
557 ExitedOffTheRecordMode(); | |
558 } | 556 } |
559 | 557 |
560 ChromeBlobStorageContext* OffTheRecordProfileImpl::GetBlobStorageContext() { | 558 ChromeBlobStorageContext* OffTheRecordProfileImpl::GetBlobStorageContext() { |
561 if (!blob_storage_context_) { | 559 if (!blob_storage_context_) { |
562 blob_storage_context_ = new ChromeBlobStorageContext(); | 560 blob_storage_context_ = new ChromeBlobStorageContext(); |
563 BrowserThread::PostTask( | 561 BrowserThread::PostTask( |
564 BrowserThread::IO, FROM_HERE, | 562 BrowserThread::IO, FROM_HERE, |
565 NewRunnableMethod( | 563 NewRunnableMethod( |
566 blob_storage_context_.get(), | 564 blob_storage_context_.get(), |
567 &ChromeBlobStorageContext::InitializeOnIOThread)); | 565 &ChromeBlobStorageContext::InitializeOnIOThread)); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 OffTheRecordProfileImpl* profile = NULL; | 700 OffTheRecordProfileImpl* profile = NULL; |
703 #if defined(OS_CHROMEOS) | 701 #if defined(OS_CHROMEOS) |
704 if (Profile::IsGuestSession()) | 702 if (Profile::IsGuestSession()) |
705 profile = new GuestSessionProfile(this); | 703 profile = new GuestSessionProfile(this); |
706 #endif | 704 #endif |
707 if (!profile) | 705 if (!profile) |
708 profile = new OffTheRecordProfileImpl(this); | 706 profile = new OffTheRecordProfileImpl(this); |
709 profile->Init(); | 707 profile->Init(); |
710 return profile; | 708 return profile; |
711 } | 709 } |
OLD | NEW |