| 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" |
| 25 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 26 #include "chrome/browser/extensions/extension_process_manager.h" | 26 #include "chrome/browser/extensions/extension_process_manager.h" |
| 27 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 29 #include "chrome/browser/extensions/extension_system.h" |
| 30 #include "chrome/browser/extensions/extension_system_factory.h" |
| 29 #include "chrome/browser/io_thread.h" | 31 #include "chrome/browser/io_thread.h" |
| 30 #include "chrome/browser/net/proxy_service_factory.h" | 32 #include "chrome/browser/net/proxy_service_factory.h" |
| 31 #include "chrome/browser/plugin_prefs.h" | 33 #include "chrome/browser/plugin_prefs.h" |
| 32 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 33 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
| 34 #include "chrome/browser/profiles/profile_dependency_manager.h" | 36 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 35 #include "chrome/browser/themes/theme_service.h" | 37 #include "chrome/browser/themes/theme_service.h" |
| 36 #include "chrome/browser/transport_security_persister.h" | 38 #include "chrome/browser/transport_security_persister.h" |
| 37 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 39 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } // namespace | 80 } // namespace |
| 79 | 81 |
| 80 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 82 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
| 81 : profile_(real_profile), | 83 : profile_(real_profile), |
| 82 prefs_(real_profile->GetOffTheRecordPrefs()), | 84 prefs_(real_profile->GetOffTheRecordPrefs()), |
| 83 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 85 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 84 start_time_(Time::Now()) { | 86 start_time_(Time::Now()) { |
| 85 } | 87 } |
| 86 | 88 |
| 87 void OffTheRecordProfileImpl::Init() { | 89 void OffTheRecordProfileImpl::Init() { |
| 88 extension_process_manager_.reset(ExtensionProcessManager::Create(this)); | |
| 89 | |
| 90 BrowserList::AddObserver(this); | 90 BrowserList::AddObserver(this); |
| 91 | 91 |
| 92 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 92 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
| 93 | 93 |
| 94 DCHECK_NE(IncognitoModePrefs::DISABLED, | 94 DCHECK_NE(IncognitoModePrefs::DISABLED, |
| 95 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 95 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |
| 96 | 96 |
| 97 // TODO(oshima): Remove the need to eagerly initialize the request context | 97 // TODO(oshima): Remove the need to eagerly initialize the request context |
| 98 // getter. chromeos::OnlineAttempt is illegally trying to access this | 98 // getter. chromeos::OnlineAttempt is illegally trying to access this |
| 99 // Profile member from a thread other than the UI thread, so we need to | 99 // Profile member from a thread other than the UI thread, so we need to |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 119 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |
| 120 content::NotificationService::current()->Notify( | 120 content::NotificationService::current()->Notify( |
| 121 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), | 121 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), |
| 122 content::NotificationService::NoDetails()); | 122 content::NotificationService::NoDetails()); |
| 123 | 123 |
| 124 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 124 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
| 125 io_data_.GetResourceContextNoInit()); | 125 io_data_.GetResourceContextNoInit()); |
| 126 | 126 |
| 127 ExtensionService* extension_service = |
| 128 ExtensionSystemFactory::GetForProfile(this)->extension_service(); |
| 129 if (extension_service) { |
| 130 extension_service->extension_prefs()-> |
| 131 ClearIncognitoSessionOnlyContentSettings(); |
| 132 } |
| 133 |
| 127 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 134 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
| 128 | 135 |
| 129 BrowserThread::PostTask( | 136 BrowserThread::PostTask( |
| 130 BrowserThread::IO, FROM_HERE, | 137 BrowserThread::IO, FROM_HERE, |
| 131 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); | 138 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); |
| 132 | 139 |
| 133 BrowserList::RemoveObserver(this); | 140 BrowserList::RemoveObserver(this); |
| 134 | 141 |
| 135 if (host_content_settings_map_) | 142 if (host_content_settings_map_) |
| 136 host_content_settings_map_->ShutdownOnUIThread(); | 143 host_content_settings_map_->ShutdownOnUIThread(); |
| 137 | 144 |
| 138 if (pref_proxy_config_tracker_.get()) | 145 if (pref_proxy_config_tracker_.get()) |
| 139 pref_proxy_config_tracker_->DetachFromPrefService(); | 146 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 140 | 147 |
| 141 ExtensionService* extension_service = GetExtensionService(); | |
| 142 if (extension_service) { | |
| 143 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | |
| 144 extension_prefs->ClearIncognitoSessionOnlyContentSettings(); | |
| 145 } | |
| 146 | |
| 147 // Clears any data the network stack contains that may be related to the | 148 // Clears any data the network stack contains that may be related to the |
| 148 // OTR session. | 149 // OTR session. |
| 149 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 150 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void OffTheRecordProfileImpl::InitHostZoomMap() { | 153 void OffTheRecordProfileImpl::InitHostZoomMap() { |
| 153 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 154 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
| 154 HostZoomMap* parent_host_zoom_map = | 155 HostZoomMap* parent_host_zoom_map = |
| 155 HostZoomMap::GetForBrowserContext(profile_); | 156 HostZoomMap::GetForBrowserContext(profile_); |
| 156 host_zoom_map->CopyFrom(parent_host_zoom_map); | 157 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { | 190 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { |
| 190 return profile_; | 191 return profile_; |
| 191 } | 192 } |
| 192 | 193 |
| 193 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { | 194 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { |
| 194 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord | 195 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord |
| 195 // because we don't want to leak the sites that the user has visited before. | 196 // because we don't want to leak the sites that the user has visited before. |
| 196 return NULL; | 197 return NULL; |
| 197 } | 198 } |
| 198 | 199 |
| 200 ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() { |
| 201 return NULL; |
| 202 } |
| 203 |
| 199 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { | 204 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { |
| 200 return GetOriginalProfile()->GetExtensionService(); | 205 return ExtensionSystemFactory::GetForProfile(this)->extension_service(); |
| 201 } | 206 } |
| 202 | 207 |
| 203 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { | 208 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { |
| 204 return GetOriginalProfile()->GetUserScriptMaster(); | 209 return ExtensionSystemFactory::GetForProfile(this)->user_script_master(); |
| 205 } | |
| 206 | |
| 207 ExtensionDevToolsManager* | |
| 208 OffTheRecordProfileImpl::GetExtensionDevToolsManager() { | |
| 209 // TODO(mpcomplete): figure out whether we should return the original | |
| 210 // profile's version. | |
| 211 return NULL; | |
| 212 } | 210 } |
| 213 | 211 |
| 214 ExtensionProcessManager* | 212 ExtensionProcessManager* |
| 215 OffTheRecordProfileImpl::GetExtensionProcessManager() { | 213 OffTheRecordProfileImpl::GetExtensionProcessManager() { |
| 216 return extension_process_manager_.get(); | 214 return ExtensionSystemFactory::GetForProfile(this)->process_manager(); |
| 217 } | |
| 218 | |
| 219 ExtensionMessageService* | |
| 220 OffTheRecordProfileImpl::GetExtensionMessageService() { | |
| 221 return GetOriginalProfile()->GetExtensionMessageService(); | |
| 222 } | 215 } |
| 223 | 216 |
| 224 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { | 217 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { |
| 225 return GetOriginalProfile()->GetExtensionEventRouter(); | 218 return ExtensionSystemFactory::GetForProfile(this)->event_router(); |
| 226 } | 219 } |
| 227 | 220 |
| 228 ExtensionSpecialStoragePolicy* | 221 ExtensionSpecialStoragePolicy* |
| 229 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { | 222 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { |
| 230 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); | 223 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); |
| 231 } | 224 } |
| 232 | 225 |
| 233 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { | 226 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { |
| 234 return NULL; | 227 return NULL; |
| 235 } | 228 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 return NULL; | 393 return NULL; |
| 401 } | 394 } |
| 402 | 395 |
| 403 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { | 396 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { |
| 404 return NULL; | 397 return NULL; |
| 405 } | 398 } |
| 406 | 399 |
| 407 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { | 400 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { |
| 408 } | 401 } |
| 409 | 402 |
| 410 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) { | |
| 411 NOTREACHED(); | |
| 412 } | |
| 413 | |
| 414 void OffTheRecordProfileImpl::InitPromoResources() { | 403 void OffTheRecordProfileImpl::InitPromoResources() { |
| 415 NOTREACHED(); | 404 NOTREACHED(); |
| 416 } | 405 } |
| 417 | 406 |
| 418 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { | 407 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { |
| 419 NOTREACHED(); | 408 NOTREACHED(); |
| 420 } | 409 } |
| 421 | 410 |
| 422 FilePath OffTheRecordProfileImpl::last_selected_directory() { | 411 FilePath OffTheRecordProfileImpl::last_selected_directory() { |
| 423 const FilePath& directory = last_selected_directory_; | 412 const FilePath& directory = last_selected_directory_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 442 // The preferences are associated with the regular user profile. | 431 // The preferences are associated with the regular user profile. |
| 443 } | 432 } |
| 444 #endif // defined(OS_CHROMEOS) | 433 #endif // defined(OS_CHROMEOS) |
| 445 | 434 |
| 446 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { | 435 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { |
| 447 } | 436 } |
| 448 | 437 |
| 449 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { | 438 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { |
| 450 } | 439 } |
| 451 | 440 |
| 452 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() { | |
| 453 return profile_->GetExtensionInfoMap(); | |
| 454 } | |
| 455 | |
| 456 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { | 441 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { |
| 457 if (!chrome_url_data_manager_.get()) | 442 if (!chrome_url_data_manager_.get()) |
| 458 chrome_url_data_manager_.reset(new ChromeURLDataManager( | 443 chrome_url_data_manager_.reset(new ChromeURLDataManager( |
| 459 io_data_.GetChromeURLDataManagerBackendGetter())); | 444 io_data_.GetChromeURLDataManagerBackendGetter())); |
| 460 return chrome_url_data_manager_.get(); | 445 return chrome_url_data_manager_.get(); |
| 461 } | 446 } |
| 462 | 447 |
| 463 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { | 448 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { |
| 464 return NULL; | 449 return NULL; |
| 465 } | 450 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 OffTheRecordProfileImpl* profile = NULL; | 521 OffTheRecordProfileImpl* profile = NULL; |
| 537 #if defined(OS_CHROMEOS) | 522 #if defined(OS_CHROMEOS) |
| 538 if (Profile::IsGuestSession()) | 523 if (Profile::IsGuestSession()) |
| 539 profile = new GuestSessionProfile(this); | 524 profile = new GuestSessionProfile(this); |
| 540 #endif | 525 #endif |
| 541 if (!profile) | 526 if (!profile) |
| 542 profile = new OffTheRecordProfileImpl(this); | 527 profile = new OffTheRecordProfileImpl(this); |
| 543 profile->Init(); | 528 profile->Init(); |
| 544 return profile; | 529 return profile; |
| 545 } | 530 } |
| OLD | NEW |