Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/background/background_contents_service_factory.h" | 16 #include "chrome/browser/background/background_contents_service_factory.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_plugin_service_filter.h" | 18 #include "chrome/browser/chrome_plugin_service_filter.h" |
| 19 #include "chrome/browser/content_settings/host_content_settings_map.h" | 19 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 20 #include "chrome/browser/download/download_service.h" | 20 #include "chrome/browser/download/download_service.h" |
| 21 #include "chrome/browser/download/download_service_factory.h" | 21 #include "chrome/browser/download/download_service_factory.h" |
| 22 #include "chrome/browser/extensions/api/webrequest/webrequest_api.h" | 22 #include "chrome/browser/extensions/api/webrequest/webrequest_api.h" |
| 23 #include "chrome/browser/extensions/extension_info_map.h" | 23 #include "chrome/browser/extensions/extension_info_map.h" |
| 24 #include "chrome/browser/extensions/extension_message_service.h" | |
| 25 #include "chrome/browser/extensions/extension_pref_store.h" | 24 #include "chrome/browser/extensions/extension_pref_store.h" |
| 26 #include "chrome/browser/extensions/extension_process_manager.h" | 25 #include "chrome/browser/extensions/extension_process_manager.h" |
| 27 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 27 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 28 #include "chrome/browser/extensions/extension_system.h" | |
| 29 #include "chrome/browser/extensions/extension_system_factory.h" | |
| 29 #include "chrome/browser/io_thread.h" | 30 #include "chrome/browser/io_thread.h" |
| 30 #include "chrome/browser/net/proxy_service_factory.h" | 31 #include "chrome/browser/net/proxy_service_factory.h" |
| 31 #include "chrome/browser/plugin_prefs.h" | 32 #include "chrome/browser/plugin_prefs.h" |
| 32 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 33 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 33 #include "chrome/browser/prefs/pref_service.h" | 34 #include "chrome/browser/prefs/pref_service.h" |
| 34 #include "chrome/browser/profiles/profile_dependency_manager.h" | 35 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 35 #include "chrome/browser/themes/theme_service.h" | 36 #include "chrome/browser/themes/theme_service.h" |
| 36 #include "chrome/browser/transport_security_persister.h" | 37 #include "chrome/browser/transport_security_persister.h" |
| 37 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 38 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } // namespace | 85 } // namespace |
| 85 | 86 |
| 86 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 87 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
| 87 : profile_(real_profile), | 88 : profile_(real_profile), |
| 88 prefs_(real_profile->GetOffTheRecordPrefs()), | 89 prefs_(real_profile->GetOffTheRecordPrefs()), |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 90 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 90 start_time_(Time::Now()) { | 91 start_time_(Time::Now()) { |
| 91 } | 92 } |
| 92 | 93 |
| 93 void OffTheRecordProfileImpl::Init() { | 94 void OffTheRecordProfileImpl::Init() { |
| 94 extension_process_manager_.reset(ExtensionProcessManager::Create(this)); | |
| 95 | |
| 96 BrowserList::AddObserver(this); | 95 BrowserList::AddObserver(this); |
| 97 | 96 |
| 98 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 97 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
| 99 | 98 |
| 99 // Make sure extension_process_manager is initialized. | |
| 100 ExtensionSystemFactory::GetForProfile(this); | |
| 101 | |
| 100 DCHECK_NE(IncognitoModePrefs::DISABLED, | 102 DCHECK_NE(IncognitoModePrefs::DISABLED, |
| 101 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 103 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |
| 102 | 104 |
| 103 // TODO(oshima): Remove the need to eagerly initialize the request context | 105 // TODO(oshima): Remove the need to eagerly initialize the request context |
| 104 // getter. chromeos::OnlineAttempt is illegally trying to access this | 106 // getter. chromeos::OnlineAttempt is illegally trying to access this |
| 105 // Profile member from a thread other than the UI thread, so we need to | 107 // Profile member from a thread other than the UI thread, so we need to |
| 106 // prevent a race. | 108 // prevent a race. |
| 107 #if defined(OS_CHROMEOS) | 109 #if defined(OS_CHROMEOS) |
| 108 GetRequestContext(); | 110 GetRequestContext(); |
| 109 #endif // defined(OS_CHROMEOS) | 111 #endif // defined(OS_CHROMEOS) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 121 } | 123 } |
| 122 | 124 |
| 123 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 125 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |
| 124 content::NotificationService::current()->Notify( | 126 content::NotificationService::current()->Notify( |
| 125 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), | 127 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), |
| 126 content::NotificationService::NoDetails()); | 128 content::NotificationService::NoDetails()); |
| 127 | 129 |
| 128 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 130 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
| 129 &io_data_.GetResourceContextNoInit()); | 131 &io_data_.GetResourceContextNoInit()); |
| 130 | 132 |
| 133 ExtensionService* extension_service = | |
| 134 ExtensionSystemFactory::GetForProfile(this)->extension_service(); | |
| 135 if (extension_service) { | |
| 136 extension_service->extension_prefs()-> | |
| 137 ClearIncognitoSessionOnlyContentSettings(); | |
| 138 } | |
| 139 | |
| 131 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 140 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
| 132 | 141 |
| 133 BrowserThread::PostTask( | 142 BrowserThread::PostTask( |
| 134 BrowserThread::IO, FROM_HERE, | 143 BrowserThread::IO, FROM_HERE, |
| 135 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); | 144 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); |
| 136 | 145 |
| 137 // Clean up all DB files/directories | 146 // Clean up all DB files/directories |
| 138 if (db_tracker_) { | 147 if (db_tracker_) { |
| 139 BrowserThread::PostTask( | 148 BrowserThread::PostTask( |
| 140 BrowserThread::FILE, FROM_HERE, | 149 BrowserThread::FILE, FROM_HERE, |
| 141 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 150 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 142 db_tracker_.get())); | 151 db_tracker_.get())); |
| 143 } | 152 } |
| 144 | 153 |
| 145 BrowserList::RemoveObserver(this); | 154 BrowserList::RemoveObserver(this); |
| 146 | 155 |
| 147 if (host_content_settings_map_) | 156 if (host_content_settings_map_) |
| 148 host_content_settings_map_->ShutdownOnUIThread(); | 157 host_content_settings_map_->ShutdownOnUIThread(); |
| 149 | 158 |
| 150 if (pref_proxy_config_tracker_.get()) | 159 if (pref_proxy_config_tracker_.get()) |
| 151 pref_proxy_config_tracker_->DetachFromPrefService(); | 160 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 152 | 161 |
| 153 ExtensionService* extension_service = GetExtensionService(); | |
| 154 if (extension_service) { | |
| 155 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | |
| 156 extension_prefs->ClearIncognitoSessionOnlyContentSettings(); | |
| 157 } | |
| 158 | |
| 159 // Clears any data the network stack contains that may be related to the | 162 // Clears any data the network stack contains that may be related to the |
| 160 // OTR session. | 163 // OTR session. |
| 161 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 164 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 162 } | 165 } |
| 163 | 166 |
| 164 std::string OffTheRecordProfileImpl::GetProfileName() { | 167 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 165 // Incognito profile should not return the profile name. | 168 // Incognito profile should not return the profile name. |
| 166 return std::string(); | 169 return std::string(); |
| 167 } | 170 } |
| 168 | 171 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 return db_tracker_; | 205 return db_tracker_; |
| 203 } | 206 } |
| 204 | 207 |
| 205 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { | 208 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { |
| 206 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord | 209 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord |
| 207 // because we don't want to leak the sites that the user has visited before. | 210 // because we don't want to leak the sites that the user has visited before. |
| 208 return NULL; | 211 return NULL; |
| 209 } | 212 } |
| 210 | 213 |
| 211 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { | 214 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { |
| 212 return GetOriginalProfile()->GetExtensionService(); | 215 return ExtensionSystemFactory::GetForProfile(this)->extension_service(); |
|
Miranda Callahan
2012/02/09 22:10:04
see my comments in the regular profile_impl code;
| |
| 213 } | 216 } |
| 214 | 217 |
| 215 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { | 218 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { |
| 216 return GetOriginalProfile()->GetUserScriptMaster(); | 219 return ExtensionSystemFactory::GetForProfile(this)->user_script_master(); |
| 217 } | |
| 218 | |
| 219 ExtensionDevToolsManager* | |
| 220 OffTheRecordProfileImpl::GetExtensionDevToolsManager() { | |
| 221 // TODO(mpcomplete): figure out whether we should return the original | |
| 222 // profile's version. | |
| 223 return NULL; | |
| 224 } | 220 } |
| 225 | 221 |
| 226 ExtensionProcessManager* | 222 ExtensionProcessManager* |
| 227 OffTheRecordProfileImpl::GetExtensionProcessManager() { | 223 OffTheRecordProfileImpl::GetExtensionProcessManager() { |
| 228 return extension_process_manager_.get(); | 224 return ExtensionSystemFactory::GetForProfile(this)->process_manager(); |
| 229 } | |
| 230 | |
| 231 ExtensionMessageService* | |
| 232 OffTheRecordProfileImpl::GetExtensionMessageService() { | |
| 233 return GetOriginalProfile()->GetExtensionMessageService(); | |
| 234 } | 225 } |
| 235 | 226 |
| 236 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { | 227 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { |
| 237 return GetOriginalProfile()->GetExtensionEventRouter(); | 228 return ExtensionSystemFactory::GetForProfile(this)->event_router(); |
| 238 } | 229 } |
| 239 | 230 |
| 240 ExtensionSpecialStoragePolicy* | 231 ExtensionSpecialStoragePolicy* |
| 241 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { | 232 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { |
| 242 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); | 233 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); |
| 243 } | 234 } |
| 244 | 235 |
| 245 SSLHostState* OffTheRecordProfileImpl::GetSSLHostState() { | 236 SSLHostState* OffTheRecordProfileImpl::GetSSLHostState() { |
| 246 if (!ssl_host_state_.get()) | 237 if (!ssl_host_state_.get()) |
| 247 ssl_host_state_.reset(new SSLHostState()); | 238 ssl_host_state_.reset(new SSLHostState()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 return NULL; | 438 return NULL; |
| 448 } | 439 } |
| 449 | 440 |
| 450 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { | 441 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { |
| 451 return NULL; | 442 return NULL; |
| 452 } | 443 } |
| 453 | 444 |
| 454 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { | 445 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { |
| 455 } | 446 } |
| 456 | 447 |
| 457 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) { | |
| 458 NOTREACHED(); | |
| 459 } | |
| 460 | |
| 461 void OffTheRecordProfileImpl::InitPromoResources() { | 448 void OffTheRecordProfileImpl::InitPromoResources() { |
| 462 NOTREACHED(); | 449 NOTREACHED(); |
| 463 } | 450 } |
| 464 | 451 |
| 465 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { | 452 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { |
| 466 NOTREACHED(); | 453 NOTREACHED(); |
| 467 } | 454 } |
| 468 | 455 |
| 469 FilePath OffTheRecordProfileImpl::last_selected_directory() { | 456 FilePath OffTheRecordProfileImpl::last_selected_directory() { |
| 470 const FilePath& directory = last_selected_directory_; | 457 const FilePath& directory = last_selected_directory_; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 500 if (!blob_storage_context_) { | 487 if (!blob_storage_context_) { |
| 501 blob_storage_context_ = new ChromeBlobStorageContext(); | 488 blob_storage_context_ = new ChromeBlobStorageContext(); |
| 502 BrowserThread::PostTask( | 489 BrowserThread::PostTask( |
| 503 BrowserThread::IO, FROM_HERE, | 490 BrowserThread::IO, FROM_HERE, |
| 504 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, | 491 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, |
| 505 blob_storage_context_.get())); | 492 blob_storage_context_.get())); |
| 506 } | 493 } |
| 507 return blob_storage_context_; | 494 return blob_storage_context_; |
| 508 } | 495 } |
| 509 | 496 |
| 510 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() { | |
| 511 return profile_->GetExtensionInfoMap(); | |
| 512 } | |
| 513 | |
| 514 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { | 497 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { |
| 515 if (!chrome_url_data_manager_.get()) | 498 if (!chrome_url_data_manager_.get()) |
| 516 chrome_url_data_manager_.reset(new ChromeURLDataManager( | 499 chrome_url_data_manager_.reset(new ChromeURLDataManager( |
| 517 io_data_.GetChromeURLDataManagerBackendGetter())); | 500 io_data_.GetChromeURLDataManagerBackendGetter())); |
| 518 return chrome_url_data_manager_.get(); | 501 return chrome_url_data_manager_.get(); |
| 519 } | 502 } |
| 520 | 503 |
| 521 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { | 504 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { |
| 522 return NULL; | 505 return NULL; |
| 523 } | 506 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 OffTheRecordProfileImpl* profile = NULL; | 618 OffTheRecordProfileImpl* profile = NULL; |
| 636 #if defined(OS_CHROMEOS) | 619 #if defined(OS_CHROMEOS) |
| 637 if (Profile::IsGuestSession()) | 620 if (Profile::IsGuestSession()) |
| 638 profile = new GuestSessionProfile(this); | 621 profile = new GuestSessionProfile(this); |
| 639 #endif | 622 #endif |
| 640 if (!profile) | 623 if (!profile) |
| 641 profile = new OffTheRecordProfileImpl(this); | 624 profile = new OffTheRecordProfileImpl(this); |
| 642 profile->Init(); | 625 profile->Init(); |
| 643 return profile; | 626 return profile; |
| 644 } | 627 } |
| OLD | NEW |