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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 return NULL; | 397 return NULL; |
405 } | 398 } |
406 | 399 |
407 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { | 400 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { |
408 return NULL; | 401 return NULL; |
409 } | 402 } |
410 | 403 |
411 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { | 404 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { |
412 } | 405 } |
413 | 406 |
414 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) { | |
415 NOTREACHED(); | |
416 } | |
417 | |
418 void OffTheRecordProfileImpl::InitPromoResources() { | 407 void OffTheRecordProfileImpl::InitPromoResources() { |
419 NOTREACHED(); | 408 NOTREACHED(); |
420 } | 409 } |
421 | 410 |
422 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { | 411 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { |
423 NOTREACHED(); | 412 NOTREACHED(); |
424 } | 413 } |
425 | 414 |
426 FilePath OffTheRecordProfileImpl::last_selected_directory() { | 415 FilePath OffTheRecordProfileImpl::last_selected_directory() { |
427 const FilePath& directory = last_selected_directory_; | 416 const FilePath& directory = last_selected_directory_; |
(...skipping 18 matching lines...) Expand all Loading... |
446 // The preferences are associated with the regular user profile. | 435 // The preferences are associated with the regular user profile. |
447 } | 436 } |
448 #endif // defined(OS_CHROMEOS) | 437 #endif // defined(OS_CHROMEOS) |
449 | 438 |
450 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { | 439 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { |
451 } | 440 } |
452 | 441 |
453 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { | 442 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { |
454 } | 443 } |
455 | 444 |
456 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() { | |
457 return profile_->GetExtensionInfoMap(); | |
458 } | |
459 | |
460 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { | 445 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { |
461 if (!chrome_url_data_manager_.get()) | 446 if (!chrome_url_data_manager_.get()) |
462 chrome_url_data_manager_.reset(new ChromeURLDataManager( | 447 chrome_url_data_manager_.reset(new ChromeURLDataManager( |
463 io_data_.GetChromeURLDataManagerBackendGetter())); | 448 io_data_.GetChromeURLDataManagerBackendGetter())); |
464 return chrome_url_data_manager_.get(); | 449 return chrome_url_data_manager_.get(); |
465 } | 450 } |
466 | 451 |
467 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { | 452 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { |
468 return NULL; | 453 return NULL; |
469 } | 454 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 OffTheRecordProfileImpl* profile = NULL; | 525 OffTheRecordProfileImpl* profile = NULL; |
541 #if defined(OS_CHROMEOS) | 526 #if defined(OS_CHROMEOS) |
542 if (Profile::IsGuestSession()) | 527 if (Profile::IsGuestSession()) |
543 profile = new GuestSessionProfile(this); | 528 profile = new GuestSessionProfile(this); |
544 #endif | 529 #endif |
545 if (!profile) | 530 if (!profile) |
546 profile = new OffTheRecordProfileImpl(this); | 531 profile = new OffTheRecordProfileImpl(this); |
547 profile->Init(); | 532 profile->Init(); |
548 return profile; | 533 return profile; |
549 } | 534 } |
OLD | NEW |