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

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

Issue 9369013: Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no crashy Created 8 years, 10 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"
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } // namespace 81 } // namespace
80 82
81 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) 83 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
82 : profile_(real_profile), 84 : profile_(real_profile),
83 prefs_(real_profile->GetOffTheRecordPrefs()), 85 prefs_(real_profile->GetOffTheRecordPrefs()),
84 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 86 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
85 start_time_(Time::Now()) { 87 start_time_(Time::Now()) {
86 } 88 }
87 89
88 void OffTheRecordProfileImpl::Init() { 90 void OffTheRecordProfileImpl::Init() {
89 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
90
91 BrowserList::AddObserver(this); 91 BrowserList::AddObserver(this);
92 92
93 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); 93 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
94 94
95 DCHECK_NE(IncognitoModePrefs::DISABLED, 95 DCHECK_NE(IncognitoModePrefs::DISABLED,
96 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); 96 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()));
97 97
98 // TODO(oshima): Remove the need to eagerly initialize the request context 98 // TODO(oshima): Remove the need to eagerly initialize the request context
99 // getter. chromeos::OnlineAttempt is illegally trying to access this 99 // getter. chromeos::OnlineAttempt is illegally trying to access this
100 // Profile member from a thread other than the UI thread, so we need to 100 // Profile member from a thread other than the UI thread, so we need to
(...skipping 15 matching lines...) Expand all
116 } 116 }
117 117
118 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { 118 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
119 content::NotificationService::current()->Notify( 119 content::NotificationService::current()->Notify(
120 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), 120 chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this),
121 content::NotificationService::NoDetails()); 121 content::NotificationService::NoDetails());
122 122
123 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 123 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
124 io_data_.GetResourceContextNoInit()); 124 io_data_.GetResourceContextNoInit());
125 125
126 ExtensionService* extension_service =
127 ExtensionSystemFactory::GetForProfile(this)->extension_service();
128 if (extension_service) {
129 extension_service->extension_prefs()->
130 ClearIncognitoSessionOnlyContentSettings();
131 }
132
126 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 133 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
127 134
128 BrowserThread::PostTask( 135 BrowserThread::PostTask(
129 BrowserThread::IO, FROM_HERE, 136 BrowserThread::IO, FROM_HERE,
130 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); 137 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this));
131 138
132 BrowserList::RemoveObserver(this); 139 BrowserList::RemoveObserver(this);
133 140
134 if (host_content_settings_map_) 141 if (host_content_settings_map_)
135 host_content_settings_map_->ShutdownOnUIThread(); 142 host_content_settings_map_->ShutdownOnUIThread();
136 143
137 if (pref_proxy_config_tracker_.get()) 144 if (pref_proxy_config_tracker_.get())
138 pref_proxy_config_tracker_->DetachFromPrefService(); 145 pref_proxy_config_tracker_->DetachFromPrefService();
139 146
140 ExtensionService* extension_service = GetExtensionService();
141 if (extension_service) {
142 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
143 extension_prefs->ClearIncognitoSessionOnlyContentSettings();
144 }
145
146 // 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
147 // OTR session. 148 // OTR session.
148 g_browser_process->io_thread()->ChangedToOnTheRecord(); 149 g_browser_process->io_thread()->ChangedToOnTheRecord();
149 } 150 }
150 151
151 std::string OffTheRecordProfileImpl::GetProfileName() { 152 std::string OffTheRecordProfileImpl::GetProfileName() {
152 // Incognito profile should not return the profile name. 153 // Incognito profile should not return the profile name.
153 return std::string(); 154 return std::string();
154 } 155 }
155 156
(...skipping 21 matching lines...) Expand all
177 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { 178 Profile* OffTheRecordProfileImpl::GetOriginalProfile() {
178 return profile_; 179 return profile_;
179 } 180 }
180 181
181 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { 182 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() {
182 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord 183 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord
183 // because we don't want to leak the sites that the user has visited before. 184 // because we don't want to leak the sites that the user has visited before.
184 return NULL; 185 return NULL;
185 } 186 }
186 187
188 ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() {
189 return NULL;
190 }
191
187 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { 192 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() {
188 return GetOriginalProfile()->GetExtensionService(); 193 return ExtensionSystemFactory::GetForProfile(this)->extension_service();
189 } 194 }
190 195
191 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { 196 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() {
192 return GetOriginalProfile()->GetUserScriptMaster(); 197 return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
193 }
194
195 ExtensionDevToolsManager*
196 OffTheRecordProfileImpl::GetExtensionDevToolsManager() {
197 // TODO(mpcomplete): figure out whether we should return the original
198 // profile's version.
199 return NULL;
200 } 198 }
201 199
202 ExtensionProcessManager* 200 ExtensionProcessManager*
203 OffTheRecordProfileImpl::GetExtensionProcessManager() { 201 OffTheRecordProfileImpl::GetExtensionProcessManager() {
204 return extension_process_manager_.get(); 202 return ExtensionSystemFactory::GetForProfile(this)->process_manager();
205 }
206
207 ExtensionMessageService*
208 OffTheRecordProfileImpl::GetExtensionMessageService() {
209 return GetOriginalProfile()->GetExtensionMessageService();
210 } 203 }
211 204
212 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { 205 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() {
213 return GetOriginalProfile()->GetExtensionEventRouter(); 206 return ExtensionSystemFactory::GetForProfile(this)->event_router();
214 } 207 }
215 208
216 ExtensionSpecialStoragePolicy* 209 ExtensionSpecialStoragePolicy*
217 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { 210 OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() {
218 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); 211 return GetOriginalProfile()->GetExtensionSpecialStoragePolicy();
219 } 212 }
220 213
221 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { 214 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() {
222 return NULL; 215 return NULL;
223 } 216 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return NULL; 398 return NULL;
406 } 399 }
407 400
408 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { 401 history::TopSites* OffTheRecordProfileImpl::GetTopSites() {
409 return NULL; 402 return NULL;
410 } 403 }
411 404
412 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { 405 void OffTheRecordProfileImpl::MarkAsCleanShutdown() {
413 } 406 }
414 407
415 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) {
416 NOTREACHED();
417 }
418
419 void OffTheRecordProfileImpl::InitPromoResources() { 408 void OffTheRecordProfileImpl::InitPromoResources() {
420 NOTREACHED(); 409 NOTREACHED();
421 } 410 }
422 411
423 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { 412 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() {
424 NOTREACHED(); 413 NOTREACHED();
425 } 414 }
426 415
427 FilePath OffTheRecordProfileImpl::last_selected_directory() { 416 FilePath OffTheRecordProfileImpl::last_selected_directory() {
428 const FilePath& directory = last_selected_directory_; 417 const FilePath& directory = last_selected_directory_;
(...skipping 18 matching lines...) Expand all
447 // The preferences are associated with the regular user profile. 436 // The preferences are associated with the regular user profile.
448 } 437 }
449 #endif // defined(OS_CHROMEOS) 438 #endif // defined(OS_CHROMEOS)
450 439
451 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) { 440 void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) {
452 } 441 }
453 442
454 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) { 443 void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) {
455 } 444 }
456 445
457 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() {
458 return profile_->GetExtensionInfoMap();
459 }
460
461 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { 446 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() {
462 if (!chrome_url_data_manager_.get()) 447 if (!chrome_url_data_manager_.get())
463 chrome_url_data_manager_.reset(new ChromeURLDataManager( 448 chrome_url_data_manager_.reset(new ChromeURLDataManager(
464 io_data_.GetChromeURLDataManagerBackendGetter())); 449 io_data_.GetChromeURLDataManagerBackendGetter()));
465 return chrome_url_data_manager_.get(); 450 return chrome_url_data_manager_.get();
466 } 451 }
467 452
468 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { 453 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() {
469 return NULL; 454 return NULL;
470 } 455 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 OffTheRecordProfileImpl* profile = NULL; 522 OffTheRecordProfileImpl* profile = NULL;
538 #if defined(OS_CHROMEOS) 523 #if defined(OS_CHROMEOS)
539 if (Profile::IsGuestSession()) 524 if (Profile::IsGuestSession())
540 profile = new GuestSessionProfile(this); 525 profile = new GuestSessionProfile(this);
541 #endif 526 #endif
542 if (!profile) 527 if (!profile)
543 profile = new OffTheRecordProfileImpl(this); 528 profile = new OffTheRecordProfileImpl(this);
544 profile->Init(); 529 profile->Init();
545 return profile; 530 return profile;
546 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698