blob: 15a4641dd652dae0618feee46bba5ec53c2bc880 [file] [log] [blame]
[email protected]e284e6d82010-01-29 19:49:451// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/profile.h"
6
[email protected]1952c7d2010-03-04 23:48:347#include "app/resource_bundle.h"
initial.commit09911bf2008-07-26 23:55:298#include "base/command_line.h"
[email protected]04fba9a92008-10-28 17:25:259#include "base/file_path.h"
[email protected]405a64b2009-09-16 21:03:4410#include "base/file_util.h"
initial.commit09911bf2008-07-26 23:55:2911#include "base/path_service.h"
12#include "base/scoped_ptr.h"
13#include "base/string_util.h"
[email protected]398206c2010-06-21 01:46:0814#include "chrome/browser/background_contents_service.h"
initial.commit09911bf2008-07-26 23:55:2915#include "chrome/browser/browser_list.h"
[email protected]8a4892d8d2009-11-23 20:40:5716#include "chrome/browser/browser_process.h"
[email protected]6fad2632009-11-02 05:59:3717#include "chrome/browser/chrome_thread.h"
[email protected]b7f05882009-02-22 01:21:5618#include "chrome/browser/download/download_manager.h"
[email protected]e5d2f7132010-04-09 18:13:5319#include "chrome/browser/find_bar_state.h"
[email protected]3bf335a2009-06-26 20:46:0620#include "chrome/browser/in_process_webkit/webkit_context.h"
[email protected]6ab9b202008-12-23 22:34:5021#include "chrome/browser/net/chrome_url_request_context.h"
[email protected]4bb336302009-10-12 05:44:2622#include "chrome/browser/notifications/desktop_notification_service.h"
[email protected]1132436e2009-04-08 20:06:3323#include "chrome/browser/ssl/ssl_host_state.h"
[email protected]48352c12009-08-15 01:19:1124#include "chrome/browser/sync/profile_sync_service.h"
[email protected]b071b6c2010-08-25 20:28:0325#include "chrome/browser/themes/browser_theme_provider.h"
initial.commit09911bf2008-07-26 23:55:2926#include "chrome/common/chrome_constants.h"
27#include "chrome/common/chrome_paths.h"
28#include "chrome/common/chrome_switches.h"
[email protected]ea587b02010-05-21 15:01:3529#include "chrome/common/json_pref_store.h"
initial.commit09911bf2008-07-26 23:55:2930#include "chrome/common/notification_service.h"
31#include "chrome/common/pref_names.h"
[email protected]f7011fcb2009-01-28 21:54:3232#include "chrome/common/render_messages.h"
[email protected]1952c7d2010-03-04 23:48:3433#include "grit/browser_resources.h"
[email protected]f90f5c512009-02-18 19:10:5834#include "grit/locale_settings.h"
[email protected]326e6792009-12-11 21:04:4235#include "net/base/transport_security_state.h"
[email protected]2f351cb2009-11-09 23:43:3436#include "webkit/database/database_tracker.h"
[email protected]753efc42010-03-09 19:52:1637#if defined(TOOLKIT_USES_GTK)
[email protected]a5166af62009-07-03 00:42:2938#include "chrome/browser/gtk/gtk_theme_provider.h"
39#endif
40
[email protected]5a0b42e2010-07-30 23:42:5941#if defined(OS_WIN)
42#include "chrome/browser/password_manager/password_store_win.h"
43#elif defined(OS_MACOSX)
44#include "chrome/browser/keychain_mac.h"
45#include "chrome/browser/password_manager/password_store_mac.h"
46#elif defined(OS_POSIX) && !defined(OS_CHROMEOS)
[email protected]5a0b42e2010-07-30 23:42:5947#include "chrome/browser/password_manager/native_backend_gnome_x.h"
48#include "chrome/browser/password_manager/native_backend_kwallet_x.h"
49#include "chrome/browser/password_manager/password_store_x.h"
50#endif
51
[email protected]e1acf6f2008-10-27 20:43:3352using base::Time;
53using base::TimeDelta;
54
initial.commit09911bf2008-07-26 23:55:2955// A pointer to the request context for the default profile. See comments on
56// Profile::GetDefaultRequestContext.
[email protected]be180c802009-10-23 06:33:3157URLRequestContextGetter* Profile::default_request_context_;
initial.commit09911bf2008-07-26 23:55:2958
[email protected]5a0b42e2010-07-30 23:42:5959namespace {
60
61// FIXME: Duplicated in profile_impl.cc
62void CleanupRequestContext(ChromeURLRequestContextGetter* context) {
[email protected]13c30922009-11-19 03:43:1963 if (context)
[email protected]47accfd62009-05-14 18:46:2164 context->CleanupOnUIThread();
[email protected]47accfd62009-05-14 18:46:2165}
66
[email protected]5a0b42e2010-07-30 23:42:5967} // namespace
68
[email protected]34cc84f2009-02-13 10:04:3569// static
[email protected]4bf6afd2009-10-08 14:00:1170const ProfileId Profile::InvalidProfileId = static_cast<ProfileId>(0);
71
72// static
initial.commit09911bf2008-07-26 23:55:2973void Profile::RegisterUserPrefs(PrefService* prefs) {
[email protected]430d3f72008-10-27 17:56:5574 prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
initial.commit09911bf2008-07-26 23:55:2975 prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true);
76 prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, true);
[email protected]74c8b422009-03-11 00:34:1277 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
[email protected]e7244d82008-10-29 18:13:2678 prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary,
79 IDS_SPELLCHECK_DICTIONARY);
80 prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true);
[email protected]154a4332009-06-03 20:20:5881 prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true);
[email protected]753efc42010-03-09 19:52:1682#if defined(TOOLKIT_USES_GTK)
[email protected]88c50ab2010-03-26 20:04:0683 prefs->RegisterBooleanPref(prefs::kUsesSystemTheme,
84 GtkThemeProvider::DefaultUsesSystemTheme());
[email protected]a5166af62009-07-03 00:42:2985#endif
[email protected]f017cc92009-12-14 20:48:0786 prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath());
[email protected]51c490b2009-08-03 16:34:3487 prefs->RegisterStringPref(prefs::kCurrentThemeID,
[email protected]20ce516d2010-06-18 02:20:0488 BrowserThemeProvider::kDefaultThemeID);
[email protected]4a190632009-05-09 01:07:4289 prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages);
90 prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors);
91 prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints);
[email protected]7895ea22009-06-02 20:53:5092 prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties);
[email protected]6d60703b2009-08-29 01:29:2393 prefs->RegisterBooleanPref(prefs::kDisableExtensions, false);
[email protected]20ce516d2010-06-18 02:20:0494 prefs->RegisterStringPref(prefs::kSelectFileLastDirectory, "");
initial.commit09911bf2008-07-26 23:55:2995}
96
[email protected]34cc84f2009-02-13 10:04:3597// static
[email protected]be180c802009-10-23 06:33:3198URLRequestContextGetter* Profile::GetDefaultRequestContext() {
initial.commit09911bf2008-07-26 23:55:2999 return default_request_context_;
100}
101
[email protected]d3b98c82010-07-14 07:45:59102bool Profile::IsSyncAccessible() {
103 ProfileSyncService* syncService = GetProfileSyncService();
104 return syncService && !syncService->IsManaged();
105}
106
initial.commit09911bf2008-07-26 23:55:29107////////////////////////////////////////////////////////////////////////////////
108//
109// OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
[email protected]4a190632009-05-09 01:07:42110// to make it suitable for the off the record mode.
initial.commit09911bf2008-07-26 23:55:29111//
112////////////////////////////////////////////////////////////////////////////////
113class OffTheRecordProfileImpl : public Profile,
114 public NotificationObserver {
115 public:
116 explicit OffTheRecordProfileImpl(Profile* real_profile)
117 : profile_(real_profile),
118 start_time_(Time::Now()) {
[email protected]be180c802009-10-23 06:33:31119 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
[email protected]481e1a42009-05-06 20:56:05120
initial.commit09911bf2008-07-26 23:55:29121 // Register for browser close notifications so we can detect when the last
122 // off-the-record window is closed, in which case we can clean our states
123 // (cookies, downloads...).
[email protected]88cf3292009-05-22 01:48:43124 registrar_.Add(this, NotificationType::BROWSER_CLOSED,
125 NotificationService::AllSources());
[email protected]398206c2010-06-21 01:46:08126 background_contents_service_.reset(
127 new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
initial.commit09911bf2008-07-26 23:55:29128 }
129
130 virtual ~OffTheRecordProfileImpl() {
[email protected]a04876b92010-06-11 22:53:43131 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
132 Source<Profile>(this),
133 NotificationService::NoDetails());
134 CleanupRequestContext(request_context_);
[email protected]fe615f32010-06-13 09:08:41135
136 // Clean up all DB files/directories
137 ChromeThread::PostTask(
138 ChromeThread::FILE, FROM_HERE,
139 NewRunnableMethod(
140 db_tracker_.get(),
141 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
initial.commit09911bf2008-07-26 23:55:29142 }
143
[email protected]4bf6afd2009-10-08 14:00:11144 virtual ProfileId GetRuntimeId() {
145 return reinterpret_cast<ProfileId>(this);
146 }
147
[email protected]a6d0f182010-01-12 08:01:44148 virtual FilePath GetPath() { return profile_->GetPath(); }
initial.commit09911bf2008-07-26 23:55:29149
150 virtual bool IsOffTheRecord() {
151 return true;
152 }
153
154 virtual Profile* GetOffTheRecordProfile() {
155 return this;
156 }
157
[email protected]860f55492009-03-27 19:50:59158 virtual void DestroyOffTheRecordProfile() {
159 // Suicide is bad!
160 NOTREACHED();
161 }
162
[email protected]6c8909c2010-07-02 07:31:11163 virtual bool HasOffTheRecordProfile() {
164 return true;
165 }
166
initial.commit09911bf2008-07-26 23:55:29167 virtual Profile* GetOriginalProfile() {
168 return profile_;
169 }
170
[email protected]02a5cdb2010-08-11 20:47:32171 virtual ChromeAppCacheService* GetAppCacheService() {
172 if (!appcache_service_) {
173 appcache_service_ = new ChromeAppCacheService;
174 ChromeThread::PostTask(
175 ChromeThread::IO, FROM_HERE,
176 NewRunnableMethod(appcache_service_.get(),
177 &ChromeAppCacheService::InitializeOnIOThread,
178 GetPath(), IsOffTheRecord(),
179 make_scoped_refptr(GetHostContentSettingsMap())));
180 }
181 return appcache_service_;
182 }
183
[email protected]2f351cb2009-11-09 23:43:34184 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() {
[email protected]fe615f32010-06-13 09:08:41185 if (!db_tracker_) {
186 db_tracker_ = new webkit_database::DatabaseTracker(
187 GetPath(), IsOffTheRecord());
188 }
[email protected]2f351cb2009-11-09 23:43:34189 return db_tracker_;
190 }
191
initial.commit09911bf2008-07-26 23:55:29192 virtual VisitedLinkMaster* GetVisitedLinkMaster() {
[email protected]7fb6c862009-03-13 02:51:49193 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord
194 // because we don't want to leak the sites that the user has visited before.
195 return NULL;
initial.commit09911bf2008-07-26 23:55:29196 }
197
[email protected]6014d672008-12-05 00:38:25198 virtual ExtensionsService* GetExtensionsService() {
[email protected]55a35692010-02-11 23:25:21199 return GetOriginalProfile()->GetExtensionsService();
[email protected]6014d672008-12-05 00:38:25200 }
201
[email protected]398206c2010-06-21 01:46:08202 virtual BackgroundContentsService* GetBackgroundContentsService() {
203 return background_contents_service_.get();
204 }
205
[email protected]4c793f02010-08-18 20:55:45206 virtual StatusTray* GetStatusTray() {
207 return GetOriginalProfile()->GetStatusTray();
208 }
209
[email protected]0938d3c2009-01-09 20:37:35210 virtual UserScriptMaster* GetUserScriptMaster() {
[email protected]55a35692010-02-11 23:25:21211 return GetOriginalProfile()->GetUserScriptMaster();
[email protected]04fba9a92008-10-28 17:25:25212 }
213
[email protected]89ebc7e2009-08-24 22:11:07214 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
[email protected]55a35692010-02-11 23:25:21215 // TODO(mpcomplete): figure out whether we should return the original
216 // profile's version.
[email protected]89ebc7e2009-08-24 22:11:07217 return NULL;
218 }
219
[email protected]481e1a42009-05-06 20:56:05220 virtual ExtensionProcessManager* GetExtensionProcessManager() {
[email protected]55a35692010-02-11 23:25:21221 return GetOriginalProfile()->GetExtensionProcessManager();
[email protected]481e1a42009-05-06 20:56:05222 }
223
[email protected]7120f132009-07-20 21:05:37224 virtual ExtensionMessageService* GetExtensionMessageService() {
[email protected]55a35692010-02-11 23:25:21225 return GetOriginalProfile()->GetExtensionMessageService();
[email protected]7120f132009-07-20 21:05:37226 }
227
[email protected]34cc84f2009-02-13 10:04:35228 virtual SSLHostState* GetSSLHostState() {
229 if (!ssl_host_state_.get())
230 ssl_host_state_.reset(new SSLHostState());
231
232 DCHECK(ssl_host_state_->CalledOnValidThread());
233 return ssl_host_state_.get();
234 }
235
[email protected]326e6792009-12-11 21:04:42236 virtual net::TransportSecurityState* GetTransportSecurityState() {
[email protected]7a1251842010-01-30 01:17:54237 if (!transport_security_state_.get())
238 transport_security_state_ = new net::TransportSecurityState();
[email protected]a9cea7542009-05-20 04:30:23239
[email protected]326e6792009-12-11 21:04:42240 return transport_security_state_.get();
[email protected]a9cea7542009-05-20 04:30:23241 }
242
initial.commit09911bf2008-07-26 23:55:29243 virtual HistoryService* GetHistoryService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54244 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29245 return profile_->GetHistoryService(sat);
[email protected]7a1251842010-01-30 01:17:54246
247 NOTREACHED() << "This profile is OffTheRecord";
248 return NULL;
initial.commit09911bf2008-07-26 23:55:29249 }
250
[email protected]0850fa62009-10-08 22:34:29251 virtual HistoryService* GetHistoryServiceWithoutCreating() {
252 return profile_->GetHistoryServiceWithoutCreating();
253 }
254
[email protected]0189bc722009-08-28 21:56:48255 virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54256 if (sat == EXPLICIT_ACCESS)
[email protected]0189bc722009-08-28 21:56:48257 return profile_->GetFaviconService(sat);
[email protected]7a1251842010-01-30 01:17:54258
259 NOTREACHED() << "This profile is OffTheRecord";
260 return NULL;
[email protected]0189bc722009-08-28 21:56:48261 }
262
[email protected]69c579e2010-04-23 20:01:00263 virtual AutocompleteClassifier* GetAutocompleteClassifier() {
264 return profile_->GetAutocompleteClassifier();
[email protected]90085af02009-10-29 17:53:21265 }
266
initial.commit09911bf2008-07-26 23:55:29267 virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54268 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29269 return profile_->GetWebDataService(sat);
[email protected]7a1251842010-01-30 01:17:54270
271 NOTREACHED() << "This profile is OffTheRecord";
272 return NULL;
initial.commit09911bf2008-07-26 23:55:29273 }
274
[email protected]9cddbe372009-10-23 21:23:53275 virtual WebDataService* GetWebDataServiceWithoutCreating() {
276 return profile_->GetWebDataServiceWithoutCreating();
277 }
278
[email protected]e69d33952009-06-03 22:00:41279 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54280 if (sat == EXPLICIT_ACCESS)
[email protected]e69d33952009-06-03 22:00:41281 return profile_->GetPasswordStore(sat);
[email protected]7a1251842010-01-30 01:17:54282
283 NOTREACHED() << "This profile is OffTheRecord";
284 return NULL;
[email protected]e69d33952009-06-03 22:00:41285 }
286
initial.commit09911bf2008-07-26 23:55:29287 virtual PrefService* GetPrefs() {
288 return profile_->GetPrefs();
289 }
290
291 virtual TemplateURLModel* GetTemplateURLModel() {
292 return profile_->GetTemplateURLModel();
293 }
294
295 virtual TemplateURLFetcher* GetTemplateURLFetcher() {
296 return profile_->GetTemplateURLFetcher();
297 }
298
299 virtual DownloadManager* GetDownloadManager() {
300 if (!download_manager_.get()) {
301 scoped_refptr<DownloadManager> dlm(new DownloadManager);
302 dlm->Init(this);
303 download_manager_.swap(dlm);
304 }
305 return download_manager_.get();
306 }
307
308 virtual bool HasCreatedDownloadManager() const {
309 return (download_manager_.get() != NULL);
310 }
311
[email protected]def11712009-11-06 00:42:15312 virtual PersonalDataManager* GetPersonalDataManager() {
313 return NULL;
314 }
315
[email protected]4a190632009-05-09 01:07:42316 virtual void InitThemes() {
[email protected]7a1251842010-01-30 01:17:54317 profile_->InitThemes();
[email protected]4a190632009-05-09 01:07:42318 }
319
320 virtual void SetTheme(Extension* extension) {
[email protected]7a1251842010-01-30 01:17:54321 profile_->SetTheme(extension);
[email protected]4a190632009-05-09 01:07:42322 }
323
[email protected]a5166af62009-07-03 00:42:29324 virtual void SetNativeTheme() {
[email protected]7a1251842010-01-30 01:17:54325 profile_->SetNativeTheme();
[email protected]a5166af62009-07-03 00:42:29326 }
327
[email protected]4a190632009-05-09 01:07:42328 virtual void ClearTheme() {
[email protected]7a1251842010-01-30 01:17:54329 profile_->ClearTheme();
[email protected]4a190632009-05-09 01:07:42330 }
331
[email protected]51c490b2009-08-03 16:34:34332 virtual Extension* GetTheme() {
[email protected]7a1251842010-01-30 01:17:54333 return profile_->GetTheme();
[email protected]51c490b2009-08-03 16:34:34334 }
335
[email protected]5786d3d2009-12-18 00:18:44336 virtual BrowserThemeProvider* GetThemeProvider() {
[email protected]7a1251842010-01-30 01:17:54337 return profile_->GetThemeProvider();
[email protected]4a190632009-05-09 01:07:42338 }
339
[email protected]be180c802009-10-23 06:33:31340 virtual URLRequestContextGetter* GetRequestContext() {
initial.commit09911bf2008-07-26 23:55:29341 return request_context_;
342 }
343
[email protected]be180c802009-10-23 06:33:31344 virtual URLRequestContextGetter* GetRequestContextForMedia() {
[email protected]d14c7ac2009-05-29 20:38:11345 // In OTR mode, media request context is the same as the original one.
346 return request_context_;
[email protected]e7f29642009-03-02 22:53:18347 }
348
[email protected]be180c802009-10-23 06:33:31349 URLRequestContextGetter* GetRequestContextForExtensions() {
[email protected]55a35692010-02-11 23:25:21350 return GetOriginalProfile()->GetRequestContextForExtensions();
[email protected]47accfd62009-05-14 18:46:21351 }
352
[email protected]db36938c2009-08-19 21:48:42353 virtual net::SSLConfigService* GetSSLConfigService() {
[email protected]7a1251842010-01-30 01:17:54354 return profile_->GetSSLConfigService();
[email protected]db36938c2009-08-19 21:48:42355 }
356
[email protected]e284e6d82010-01-29 19:49:45357 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
[email protected]bd147842010-04-09 15:29:17358 // Retrieve the host content settings map of the parent profile in order to
359 // ensure the preferences have been migrated.
360 profile_->GetHostContentSettingsMap();
361 if (!host_content_settings_map_.get())
362 host_content_settings_map_ = new HostContentSettingsMap(this);
363 return host_content_settings_map_.get();
[email protected]e284e6d82010-01-29 19:49:45364 }
365
[email protected]40bd6582009-12-04 23:49:51366 virtual HostZoomMap* GetHostZoomMap() {
[email protected]c18d4f482010-05-18 21:19:50367 if (!host_zoom_map_)
368 host_zoom_map_ = new HostZoomMap(this);
369 return host_zoom_map_.get();
[email protected]40bd6582009-12-04 23:49:51370 }
371
[email protected]aee541e2010-03-19 01:52:45372 virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap() {
373 return profile_->GetGeolocationContentSettingsMap();
374 }
375
[email protected]8b4b84ee2010-05-11 13:08:52376 virtual GeolocationPermissionContext* GetGeolocationPermissionContext() {
377 return profile_->GetGeolocationPermissionContext();
378 }
379
[email protected]6c32ce72010-03-08 05:18:06380 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() {
381 return profile_->GetUserStyleSheetWatcher();
382 }
383
[email protected]e5d2f7132010-04-09 18:13:53384 virtual FindBarState* GetFindBarState() {
385 if (!find_bar_state_.get())
386 find_bar_state_.reset(new FindBarState());
387 return find_bar_state_.get();
388 }
389
initial.commit09911bf2008-07-26 23:55:29390 virtual SessionService* GetSessionService() {
391 // Don't save any sessions when off the record.
392 return NULL;
393 }
394
395 virtual void ShutdownSessionService() {
396 // We don't allow a session service, nothing to do.
397 }
398
399 virtual bool HasSessionService() const {
400 // We never have a session service.
401 return false;
402 }
403
initial.commit09911bf2008-07-26 23:55:29404 virtual bool DidLastSessionExitCleanly() {
405 return profile_->DidLastSessionExitCleanly();
406 }
407
[email protected]d8e41ed2008-09-11 15:22:32408 virtual BookmarkModel* GetBookmarkModel() {
409 return profile_->GetBookmarkModel();
initial.commit09911bf2008-07-26 23:55:29410 }
411
[email protected]4bb336302009-10-12 05:44:26412 virtual DesktopNotificationService* GetDesktopNotificationService() {
[email protected]7d7696c52009-12-01 20:54:58413 if (!desktop_notification_service_.get()) {
414 desktop_notification_service_.reset(new DesktopNotificationService(
415 this, g_browser_process->notification_ui_manager()));
416 }
417 return desktop_notification_service_.get();
[email protected]4bb336302009-10-12 05:44:26418 }
419
[email protected]8e4c29612010-07-14 01:24:45420 virtual TokenService* GetTokenService() {
421 return NULL;
422 }
423
[email protected]48352c12009-08-15 01:19:11424 virtual ProfileSyncService* GetProfileSyncService() {
425 return NULL;
[email protected]3a453fa2008-08-15 18:46:34426 }
[email protected]3a453fa2008-08-15 18:46:34427
[email protected]1bd056e2010-04-20 02:03:48428 virtual CloudPrintProxyService* GetCloudPrintProxyService() {
429 return NULL;
430 }
431
initial.commit09911bf2008-07-26 23:55:29432 virtual bool IsSameProfile(Profile* profile) {
[email protected]7a1251842010-01-30 01:17:54433 return (profile == this) || (profile == profile_);
initial.commit09911bf2008-07-26 23:55:29434 }
435
436 virtual Time GetStartTime() const {
437 return start_time_;
438 }
439
440 virtual TabRestoreService* GetTabRestoreService() {
441 return NULL;
442 }
443
[email protected]e7244d82008-10-29 18:13:26444 virtual void ResetTabRestoreService() {
[email protected]20930852008-10-15 19:30:41445 }
446
[email protected]85c55dc2009-11-06 03:05:46447 virtual SpellCheckHost* GetSpellCheckHost() {
448 return profile_->GetSpellCheckHost();
449 }
450
451 virtual void ReinitializeSpellCheckHost(bool force) {
452 profile_->ReinitializeSpellCheckHost(force);
453 }
[email protected]85c55dc2009-11-06 03:05:46454
[email protected]3bf335a2009-06-26 20:46:06455 virtual WebKitContext* GetWebKitContext() {
[email protected]c27324b2009-11-19 22:44:29456 if (!webkit_context_.get())
[email protected]70c19a932010-05-14 12:59:11457 webkit_context_ = new WebKitContext(this);
[email protected]c27324b2009-11-19 22:44:29458 DCHECK(webkit_context_.get());
459 return webkit_context_.get();
460 }
[email protected]3bf335a2009-06-26 20:46:06461
[email protected]523623c2010-05-19 16:03:42462 virtual history::TopSites* GetTopSites() {
463 return NULL;
464 }
465
initial.commit09911bf2008-07-26 23:55:29466 virtual void MarkAsCleanShutdown() {
467 }
468
[email protected]bdbc87c2009-01-25 05:08:54469 virtual void InitExtensions() {
470 NOTREACHED();
471 }
472
[email protected]9c8dd902009-11-19 17:50:42473 virtual NTPResourceCache* GetNTPResourceCache() {
474 // Just return the real profile resource cache.
475 return profile_->GetNTPResourceCache();
476 }
477
[email protected]35896a32010-06-09 08:42:51478 virtual FilePath last_selected_directory() {
479 const FilePath& directory = last_selected_directory_;
480 if (directory.empty()) {
481 return profile_->last_selected_directory();
482 }
483 return directory;
484 }
485
486 virtual void set_last_selected_directory(const FilePath& path) {
487 last_selected_directory_ = path;
488 }
489
[email protected]f50278cd2010-08-24 17:34:08490#if defined(OS_CHROMEOS)
491 virtual chromeos::ProxyConfigServiceImpl*
492 GetChromeOSProxyConfigServiceImpl() {
493 return profile_->GetChromeOSProxyConfigServiceImpl();
494 }
495#endif // defined(OS_CHROMEOS)
496
initial.commit09911bf2008-07-26 23:55:29497 virtual void ExitedOffTheRecordMode() {
498 // Drop our download manager so we forget about all the downloads made
499 // in off-the-record mode.
500 download_manager_ = NULL;
501 }
502
503 virtual void Observe(NotificationType type,
504 const NotificationSource& source,
505 const NotificationDetails& details) {
[email protected]bfd04a62009-02-01 18:16:56506 DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value);
initial.commit09911bf2008-07-26 23:55:29507 // We are only interested in OTR browser closing.
508 if (Source<Browser>(source)->profile() != this)
509 return;
510
511 // Let's check if we still have an Off The Record window opened.
512 // Note that we check against 1 as this notification is sent before the
513 // browser window is actually removed from the list.
514 if (BrowserList::GetBrowserCount(this) <= 1)
515 ExitedOffTheRecordMode();
516 }
517
518 private:
[email protected]88cf3292009-05-22 01:48:43519 NotificationRegistrar registrar_;
520
initial.commit09911bf2008-07-26 23:55:29521 // The real underlying profile.
522 Profile* profile_;
523
[email protected]6ab9b202008-12-23 22:34:50524 // The context to use for requests made from this OTR session.
[email protected]13c30922009-11-19 03:43:19525 scoped_refptr<ChromeURLRequestContextGetter> request_context_;
initial.commit09911bf2008-07-26 23:55:29526
527 // The download manager that only stores downloaded items in memory.
528 scoped_refptr<DownloadManager> download_manager_;
529
[email protected]7d7696c52009-12-01 20:54:58530 // Use a separate desktop notification service for OTR.
531 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
532
[email protected]bd147842010-04-09 15:29:17533 // We use a non-writable content settings map for OTR.
534 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
535
[email protected]c18d4f482010-05-18 21:19:50536 // Use a separate zoom map for OTR.
537 scoped_refptr<HostZoomMap> host_zoom_map_;
538
[email protected]3bf335a2009-06-26 20:46:06539 // Use a special WebKit context for OTR browsing.
540 scoped_refptr<WebKitContext> webkit_context_;
541
[email protected]34cc84f2009-02-13 10:04:35542 // We don't want SSLHostState from the OTR profile to leak back to the main
543 // profile because then the main profile would learn some of the host names
544 // the user visited while OTR.
545 scoped_ptr<SSLHostState> ssl_host_state_;
546
[email protected]e5d2f7132010-04-09 18:13:53547 // Use a separate FindBarState so search terms do not leak back to the main
548 // profile.
549 scoped_ptr<FindBarState> find_bar_state_;
550
[email protected]326e6792009-12-11 21:04:42551 // The TransportSecurityState that only stores enabled sites in memory.
552 scoped_refptr<net::TransportSecurityState>
553 transport_security_state_;
[email protected]a9cea7542009-05-20 04:30:23554
initial.commit09911bf2008-07-26 23:55:29555 // Time we were started.
556 Time start_time_;
557
[email protected]02a5cdb2010-08-11 20:47:32558 scoped_refptr<ChromeAppCacheService> appcache_service_;
559
[email protected]2f351cb2009-11-09 23:43:34560 // The main database tracker for this profile.
561 // Should be used only on the file thread.
562 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
563
[email protected]35896a32010-06-09 08:42:51564 FilePath last_selected_directory_;
565
[email protected]398206c2010-06-21 01:46:08566 // Tracks all BackgroundContents running under this profile.
567 scoped_ptr<BackgroundContentsService> background_contents_service_;
568
[email protected]90085af02009-10-29 17:53:21569 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
initial.commit09911bf2008-07-26 23:55:29570};
571
[email protected]5a0b42e2010-07-30 23:42:59572Profile *Profile::CreateOffTheRecordProfile() {
573 return new OffTheRecordProfileImpl(this);
[email protected]48352c12009-08-15 01:19:11574}