Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/profiles/off_the_record_profile_impl.cc

Issue 9583036: Revert 124817 - Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
24 #include "chrome/browser/extensions/extension_pref_store.h" 25 #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"
31 #include "chrome/browser/io_thread.h" 29 #include "chrome/browser/io_thread.h"
32 #include "chrome/browser/net/proxy_service_factory.h" 30 #include "chrome/browser/net/proxy_service_factory.h"
33 #include "chrome/browser/plugin_prefs.h" 31 #include "chrome/browser/plugin_prefs.h"
34 #include "chrome/browser/prefs/incognito_mode_prefs.h" 32 #include "chrome/browser/prefs/incognito_mode_prefs.h"
35 #include "chrome/browser/prefs/pref_service.h" 33 #include "chrome/browser/prefs/pref_service.h"
36 #include "chrome/browser/profiles/profile_dependency_manager.h" 34 #include "chrome/browser/profiles/profile_dependency_manager.h"
37 #include "chrome/browser/themes/theme_service.h" 35 #include "chrome/browser/themes/theme_service.h"
38 #include "chrome/browser/transport_security_persister.h" 36 #include "chrome/browser/transport_security_persister.h"
39 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 37 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } // namespace 78 } // namespace
81 79
82 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) 80 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
83 : profile_(real_profile), 81 : profile_(real_profile),
84 prefs_(real_profile->GetOffTheRecordPrefs()), 82 prefs_(real_profile->GetOffTheRecordPrefs()),
85 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 83 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
86 start_time_(Time::Now()) { 84 start_time_(Time::Now()) {
87 } 85 }
88 86
89 void OffTheRecordProfileImpl::Init() { 87 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
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
134 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 127 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
135 128
136 BrowserThread::PostTask( 129 BrowserThread::PostTask(
137 BrowserThread::IO, FROM_HERE, 130 BrowserThread::IO, FROM_HERE,
138 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); 131 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this));
139 132
140 BrowserList::RemoveObserver(this); 133 BrowserList::RemoveObserver(this);
141 134
142 if (host_content_settings_map_) 135 if (host_content_settings_map_)
143 host_content_settings_map_->ShutdownOnUIThread(); 136 host_content_settings_map_->ShutdownOnUIThread();
144 137
145 if (pref_proxy_config_tracker_.get()) 138 if (pref_proxy_config_tracker_.get())
146 pref_proxy_config_tracker_->DetachFromPrefService(); 139 pref_proxy_config_tracker_->DetachFromPrefService();
147 140
141 ExtensionService* extension_service = GetExtensionService();
142 if (extension_service) {
143 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
144 extension_prefs->ClearIncognitoSessionOnlyContentSettings();
145 }
146
148 // Clears any data the network stack contains that may be related to the 147 // Clears any data the network stack contains that may be related to the
149 // OTR session. 148 // OTR session.
150 g_browser_process->io_thread()->ChangedToOnTheRecord(); 149 g_browser_process->io_thread()->ChangedToOnTheRecord();
151 } 150 }
152 151
153 void OffTheRecordProfileImpl::InitHostZoomMap() { 152 void OffTheRecordProfileImpl::InitHostZoomMap() {
154 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); 153 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
155 HostZoomMap* parent_host_zoom_map = 154 HostZoomMap* parent_host_zoom_map =
156 HostZoomMap::GetForBrowserContext(profile_); 155 HostZoomMap::GetForBrowserContext(profile_);
157 host_zoom_map->CopyFrom(parent_host_zoom_map); 156 host_zoom_map->CopyFrom(parent_host_zoom_map);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { 189 Profile* OffTheRecordProfileImpl::GetOriginalProfile() {
191 return profile_; 190 return profile_;
192 } 191 }
193 192
194 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { 193 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() {
195 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord 194 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord
196 // because we don't want to leak the sites that the user has visited before. 195 // because we don't want to leak the sites that the user has visited before.
197 return NULL; 196 return NULL;
198 } 197 }
199 198
200 ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() {
201 return NULL;
202 }
203
204 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { 199 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() {
205 return ExtensionSystemFactory::GetForProfile(this)->extension_service(); 200 return GetOriginalProfile()->GetExtensionService();
206 } 201 }
207 202
208 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { 203 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() {
209 return ExtensionSystemFactory::GetForProfile(this)->user_script_master(); 204 return GetOriginalProfile()->GetUserScriptMaster();
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;
210 } 212 }
211 213
212 ExtensionProcessManager* 214 ExtensionProcessManager*
213 OffTheRecordProfileImpl::GetExtensionProcessManager() { 215 OffTheRecordProfileImpl::GetExtensionProcessManager() {
214 return ExtensionSystemFactory::GetForProfile(this)->process_manager(); 216 return extension_process_manager_.get();
217 }
218
219 ExtensionMessageService*
220 OffTheRecordProfileImpl::GetExtensionMessageService() {
221 return GetOriginalProfile()->GetExtensionMessageService();
215 } 222 }
216 223
217 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { 224 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() {
218 return ExtensionSystemFactory::GetForProfile(this)->event_router(); 225 return GetOriginalProfile()->GetExtensionEventRouter();
219 } 226 }
220 227
221 ExtensionSpecialStoragePolicy* 228 ExtensionSpecialStoragePolicy*
222 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { 229 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() {
223 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); 230 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy();
224 } 231 }
225 232
226 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { 233 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() {
227 return NULL; 234 return NULL;
228 } 235 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return NULL; 404 return NULL;
398 } 405 }
399 406
400 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { 407 history::TopSites* OffTheRecordProfileImpl::GetTopSites() {
401 return NULL; 408 return NULL;
402 } 409 }
403 410
404 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { 411 void OffTheRecordProfileImpl::MarkAsCleanShutdown() {
405 } 412 }
406 413
414 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) {
415 NOTREACHED();
416 }
417
407 void OffTheRecordProfileImpl::InitPromoResources() { 418 void OffTheRecordProfileImpl::InitPromoResources() {
408 NOTREACHED(); 419 NOTREACHED();
409 } 420 }
410 421
411 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { 422 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() {
412 NOTREACHED(); 423 NOTREACHED();
413 } 424 }
414 425
415 FilePath OffTheRecordProfileImpl::last_selected_directory() { 426 FilePath OffTheRecordProfileImpl::last_selected_directory() {
416 const FilePath& directory = last_selected_directory_; 427 const FilePath& directory = last_selected_directory_;
(...skipping 18 matching lines...) Expand all
435 // The preferences are associated with the regular user profile. 446 // The preferences are associated with the regular user profile.
436 } 447 }
437 #endif // defined(OS_CHROMEOS) 448 #endif // defined(OS_CHROMEOS)
438 449
439 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { 450 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) {
440 } 451 }
441 452
442 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { 453 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) {
443 } 454 }
444 455
456 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() {
457 return profile_->GetExtensionInfoMap();
458 }
459
445 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { 460 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() {
446 if (!chrome_url_data_manager_.get()) 461 if (!chrome_url_data_manager_.get())
447 chrome_url_data_manager_.reset(new ChromeURLDataManager( 462 chrome_url_data_manager_.reset(new ChromeURLDataManager(
448 io_data_.GetChromeURLDataManagerBackendGetter())); 463 io_data_.GetChromeURLDataManagerBackendGetter()));
449 return chrome_url_data_manager_.get(); 464 return chrome_url_data_manager_.get();
450 } 465 }
451 466
452 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { 467 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() {
453 return NULL; 468 return NULL;
454 } 469 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 OffTheRecordProfileImpl* profile = NULL; 540 OffTheRecordProfileImpl* profile = NULL;
526 #if defined(OS_CHROMEOS) 541 #if defined(OS_CHROMEOS)
527 if (Profile::IsGuestSession()) 542 if (Profile::IsGuestSession())
528 profile = new GuestSessionProfile(this); 543 profile = new GuestSessionProfile(this);
529 #endif 544 #endif
530 if (!profile) 545 if (!profile)
531 profile = new OffTheRecordProfileImpl(this); 546 profile = new OffTheRecordProfileImpl(this);
532 profile->Init(); 547 profile->Init();
533 return profile; 548 return profile;
534 } 549 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/off_the_record_profile_impl.h ('k') | chrome/browser/profiles/off_the_record_profile_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698