blob: f2cd905a2bf72504cf687bd93f519321e4f32210 [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]fee67982010-04-23 17:24:229#include "base/env_var.h"
[email protected]04fba9a92008-10-28 17:25:2510#include "base/file_path.h"
[email protected]405a64b2009-09-16 21:03:4411#include "base/file_util.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/path_service.h"
13#include "base/scoped_ptr.h"
14#include "base/string_util.h"
[email protected]398206c2010-06-21 01:46:0815#include "chrome/browser/background_contents_service.h"
initial.commit09911bf2008-07-26 23:55:2916#include "chrome/browser/browser_list.h"
[email protected]8a4892d8d2009-11-23 20:40:5717#include "chrome/browser/browser_process.h"
[email protected]67a46b7f2009-06-16 21:41:0218#include "chrome/browser/browser_theme_provider.h"
[email protected]6fad2632009-11-02 05:59:3719#include "chrome/browser/chrome_thread.h"
[email protected]b7f05882009-02-22 01:21:5620#include "chrome/browser/download/download_manager.h"
[email protected]e5d2f7132010-04-09 18:13:5321#include "chrome/browser/find_bar_state.h"
[email protected]3bf335a2009-06-26 20:46:0622#include "chrome/browser/in_process_webkit/webkit_context.h"
[email protected]6ab9b202008-12-23 22:34:5023#include "chrome/browser/net/chrome_url_request_context.h"
[email protected]4bb336302009-10-12 05:44:2624#include "chrome/browser/notifications/desktop_notification_service.h"
[email protected]1132436e2009-04-08 20:06:3325#include "chrome/browser/ssl/ssl_host_state.h"
[email protected]48352c12009-08-15 01:19:1126#include "chrome/browser/sync/profile_sync_service.h"
initial.commit09911bf2008-07-26 23:55:2927#include "chrome/common/chrome_constants.h"
28#include "chrome/common/chrome_paths.h"
29#include "chrome/common/chrome_switches.h"
[email protected]ea587b02010-05-21 15:01:3530#include "chrome/common/json_pref_store.h"
initial.commit09911bf2008-07-26 23:55:2931#include "chrome/common/notification_service.h"
32#include "chrome/common/pref_names.h"
[email protected]f7011fcb2009-01-28 21:54:3233#include "chrome/common/render_messages.h"
[email protected]1952c7d2010-03-04 23:48:3434#include "grit/browser_resources.h"
[email protected]f90f5c512009-02-18 19:10:5835#include "grit/locale_settings.h"
[email protected]326e6792009-12-11 21:04:4236#include "net/base/transport_security_state.h"
[email protected]2f351cb2009-11-09 23:43:3437#include "webkit/database/database_tracker.h"
[email protected]753efc42010-03-09 19:52:1638#if defined(TOOLKIT_USES_GTK)
[email protected]a5166af62009-07-03 00:42:2939#include "chrome/browser/gtk/gtk_theme_provider.h"
40#endif
41
[email protected]5a0b42e2010-07-30 23:42:5942#if defined(OS_WIN)
43#include "chrome/browser/password_manager/password_store_win.h"
44#elif defined(OS_MACOSX)
45#include "chrome/browser/keychain_mac.h"
46#include "chrome/browser/password_manager/password_store_mac.h"
47#elif defined(OS_POSIX) && !defined(OS_CHROMEOS)
48#include "base/xdg_util.h"
49#include "chrome/browser/password_manager/native_backend_gnome_x.h"
50#include "chrome/browser/password_manager/native_backend_kwallet_x.h"
51#include "chrome/browser/password_manager/password_store_x.h"
52#endif
53
[email protected]e1acf6f2008-10-27 20:43:3354using base::Time;
55using base::TimeDelta;
56
initial.commit09911bf2008-07-26 23:55:2957// A pointer to the request context for the default profile. See comments on
58// Profile::GetDefaultRequestContext.
[email protected]be180c802009-10-23 06:33:3159URLRequestContextGetter* Profile::default_request_context_;
initial.commit09911bf2008-07-26 23:55:2960
[email protected]5a0b42e2010-07-30 23:42:5961namespace {
62
63// FIXME: Duplicated in profile_impl.cc
64void CleanupRequestContext(ChromeURLRequestContextGetter* context) {
[email protected]13c30922009-11-19 03:43:1965 if (context)
[email protected]47accfd62009-05-14 18:46:2166 context->CleanupOnUIThread();
[email protected]47accfd62009-05-14 18:46:2167}
68
[email protected]5a0b42e2010-07-30 23:42:5969} // namespace
70
[email protected]34cc84f2009-02-13 10:04:3571// static
[email protected]4bf6afd2009-10-08 14:00:1172const ProfileId Profile::InvalidProfileId = static_cast<ProfileId>(0);
73
74// static
initial.commit09911bf2008-07-26 23:55:2975void Profile::RegisterUserPrefs(PrefService* prefs) {
[email protected]430d3f72008-10-27 17:56:5576 prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
initial.commit09911bf2008-07-26 23:55:2977 prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true);
78 prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, true);
[email protected]74c8b422009-03-11 00:34:1279 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
[email protected]e7244d82008-10-29 18:13:2680 prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary,
81 IDS_SPELLCHECK_DICTIONARY);
82 prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true);
[email protected]154a4332009-06-03 20:20:5883 prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true);
[email protected]753efc42010-03-09 19:52:1684#if defined(TOOLKIT_USES_GTK)
[email protected]88c50ab2010-03-26 20:04:0685 prefs->RegisterBooleanPref(prefs::kUsesSystemTheme,
86 GtkThemeProvider::DefaultUsesSystemTheme());
[email protected]a5166af62009-07-03 00:42:2987#endif
[email protected]f017cc92009-12-14 20:48:0788 prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath());
[email protected]51c490b2009-08-03 16:34:3489 prefs->RegisterStringPref(prefs::kCurrentThemeID,
[email protected]20ce516d2010-06-18 02:20:0490 BrowserThemeProvider::kDefaultThemeID);
[email protected]4a190632009-05-09 01:07:4291 prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages);
92 prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors);
93 prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints);
[email protected]7895ea22009-06-02 20:53:5094 prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties);
[email protected]6d60703b2009-08-29 01:29:2395 prefs->RegisterBooleanPref(prefs::kDisableExtensions, false);
[email protected]20ce516d2010-06-18 02:20:0496 prefs->RegisterStringPref(prefs::kSelectFileLastDirectory, "");
initial.commit09911bf2008-07-26 23:55:2997}
98
[email protected]34cc84f2009-02-13 10:04:3599// static
[email protected]be180c802009-10-23 06:33:31100URLRequestContextGetter* Profile::GetDefaultRequestContext() {
initial.commit09911bf2008-07-26 23:55:29101 return default_request_context_;
102}
103
[email protected]d3b98c82010-07-14 07:45:59104bool Profile::IsSyncAccessible() {
105 ProfileSyncService* syncService = GetProfileSyncService();
106 return syncService && !syncService->IsManaged();
107}
108
initial.commit09911bf2008-07-26 23:55:29109////////////////////////////////////////////////////////////////////////////////
110//
111// OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
[email protected]4a190632009-05-09 01:07:42112// to make it suitable for the off the record mode.
initial.commit09911bf2008-07-26 23:55:29113//
114////////////////////////////////////////////////////////////////////////////////
115class OffTheRecordProfileImpl : public Profile,
116 public NotificationObserver {
117 public:
118 explicit OffTheRecordProfileImpl(Profile* real_profile)
119 : profile_(real_profile),
120 start_time_(Time::Now()) {
[email protected]be180c802009-10-23 06:33:31121 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
[email protected]481e1a42009-05-06 20:56:05122
initial.commit09911bf2008-07-26 23:55:29123 // Register for browser close notifications so we can detect when the last
124 // off-the-record window is closed, in which case we can clean our states
125 // (cookies, downloads...).
[email protected]88cf3292009-05-22 01:48:43126 registrar_.Add(this, NotificationType::BROWSER_CLOSED,
127 NotificationService::AllSources());
[email protected]398206c2010-06-21 01:46:08128 background_contents_service_.reset(
129 new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
initial.commit09911bf2008-07-26 23:55:29130 }
131
132 virtual ~OffTheRecordProfileImpl() {
[email protected]a04876b92010-06-11 22:53:43133 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
134 Source<Profile>(this),
135 NotificationService::NoDetails());
136 CleanupRequestContext(request_context_);
[email protected]fe615f32010-06-13 09:08:41137
138 // Clean up all DB files/directories
139 ChromeThread::PostTask(
140 ChromeThread::FILE, FROM_HERE,
141 NewRunnableMethod(
142 db_tracker_.get(),
143 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
initial.commit09911bf2008-07-26 23:55:29144 }
145
[email protected]4bf6afd2009-10-08 14:00:11146 virtual ProfileId GetRuntimeId() {
147 return reinterpret_cast<ProfileId>(this);
148 }
149
[email protected]a6d0f182010-01-12 08:01:44150 virtual FilePath GetPath() { return profile_->GetPath(); }
initial.commit09911bf2008-07-26 23:55:29151
152 virtual bool IsOffTheRecord() {
153 return true;
154 }
155
156 virtual Profile* GetOffTheRecordProfile() {
157 return this;
158 }
159
[email protected]860f55492009-03-27 19:50:59160 virtual void DestroyOffTheRecordProfile() {
161 // Suicide is bad!
162 NOTREACHED();
163 }
164
[email protected]6c8909c2010-07-02 07:31:11165 virtual bool HasOffTheRecordProfile() {
166 return true;
167 }
168
initial.commit09911bf2008-07-26 23:55:29169 virtual Profile* GetOriginalProfile() {
170 return profile_;
171 }
172
[email protected]2f351cb2009-11-09 23:43:34173 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() {
[email protected]fe615f32010-06-13 09:08:41174 if (!db_tracker_) {
175 db_tracker_ = new webkit_database::DatabaseTracker(
176 GetPath(), IsOffTheRecord());
177 }
[email protected]2f351cb2009-11-09 23:43:34178 return db_tracker_;
179 }
180
initial.commit09911bf2008-07-26 23:55:29181 virtual VisitedLinkMaster* GetVisitedLinkMaster() {
[email protected]7fb6c862009-03-13 02:51:49182 // 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 return NULL;
initial.commit09911bf2008-07-26 23:55:29185 }
186
[email protected]6014d672008-12-05 00:38:25187 virtual ExtensionsService* GetExtensionsService() {
[email protected]55a35692010-02-11 23:25:21188 return GetOriginalProfile()->GetExtensionsService();
[email protected]6014d672008-12-05 00:38:25189 }
190
[email protected]398206c2010-06-21 01:46:08191 virtual BackgroundContentsService* GetBackgroundContentsService() {
192 return background_contents_service_.get();
193 }
194
[email protected]0938d3c2009-01-09 20:37:35195 virtual UserScriptMaster* GetUserScriptMaster() {
[email protected]55a35692010-02-11 23:25:21196 return GetOriginalProfile()->GetUserScriptMaster();
[email protected]04fba9a92008-10-28 17:25:25197 }
198
[email protected]89ebc7e2009-08-24 22:11:07199 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
[email protected]55a35692010-02-11 23:25:21200 // TODO(mpcomplete): figure out whether we should return the original
201 // profile's version.
[email protected]89ebc7e2009-08-24 22:11:07202 return NULL;
203 }
204
[email protected]481e1a42009-05-06 20:56:05205 virtual ExtensionProcessManager* GetExtensionProcessManager() {
[email protected]55a35692010-02-11 23:25:21206 return GetOriginalProfile()->GetExtensionProcessManager();
[email protected]481e1a42009-05-06 20:56:05207 }
208
[email protected]7120f132009-07-20 21:05:37209 virtual ExtensionMessageService* GetExtensionMessageService() {
[email protected]55a35692010-02-11 23:25:21210 return GetOriginalProfile()->GetExtensionMessageService();
[email protected]7120f132009-07-20 21:05:37211 }
212
[email protected]34cc84f2009-02-13 10:04:35213 virtual SSLHostState* GetSSLHostState() {
214 if (!ssl_host_state_.get())
215 ssl_host_state_.reset(new SSLHostState());
216
217 DCHECK(ssl_host_state_->CalledOnValidThread());
218 return ssl_host_state_.get();
219 }
220
[email protected]326e6792009-12-11 21:04:42221 virtual net::TransportSecurityState* GetTransportSecurityState() {
[email protected]7a1251842010-01-30 01:17:54222 if (!transport_security_state_.get())
223 transport_security_state_ = new net::TransportSecurityState();
[email protected]a9cea7542009-05-20 04:30:23224
[email protected]326e6792009-12-11 21:04:42225 return transport_security_state_.get();
[email protected]a9cea7542009-05-20 04:30:23226 }
227
initial.commit09911bf2008-07-26 23:55:29228 virtual HistoryService* GetHistoryService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54229 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29230 return profile_->GetHistoryService(sat);
[email protected]7a1251842010-01-30 01:17:54231
232 NOTREACHED() << "This profile is OffTheRecord";
233 return NULL;
initial.commit09911bf2008-07-26 23:55:29234 }
235
[email protected]0850fa62009-10-08 22:34:29236 virtual HistoryService* GetHistoryServiceWithoutCreating() {
237 return profile_->GetHistoryServiceWithoutCreating();
238 }
239
[email protected]0189bc722009-08-28 21:56:48240 virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54241 if (sat == EXPLICIT_ACCESS)
[email protected]0189bc722009-08-28 21:56:48242 return profile_->GetFaviconService(sat);
[email protected]7a1251842010-01-30 01:17:54243
244 NOTREACHED() << "This profile is OffTheRecord";
245 return NULL;
[email protected]0189bc722009-08-28 21:56:48246 }
247
[email protected]69c579e2010-04-23 20:01:00248 virtual AutocompleteClassifier* GetAutocompleteClassifier() {
249 return profile_->GetAutocompleteClassifier();
[email protected]90085af02009-10-29 17:53:21250 }
251
initial.commit09911bf2008-07-26 23:55:29252 virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54253 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29254 return profile_->GetWebDataService(sat);
[email protected]7a1251842010-01-30 01:17:54255
256 NOTREACHED() << "This profile is OffTheRecord";
257 return NULL;
initial.commit09911bf2008-07-26 23:55:29258 }
259
[email protected]9cddbe372009-10-23 21:23:53260 virtual WebDataService* GetWebDataServiceWithoutCreating() {
261 return profile_->GetWebDataServiceWithoutCreating();
262 }
263
[email protected]e69d33952009-06-03 22:00:41264 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54265 if (sat == EXPLICIT_ACCESS)
[email protected]e69d33952009-06-03 22:00:41266 return profile_->GetPasswordStore(sat);
[email protected]7a1251842010-01-30 01:17:54267
268 NOTREACHED() << "This profile is OffTheRecord";
269 return NULL;
[email protected]e69d33952009-06-03 22:00:41270 }
271
initial.commit09911bf2008-07-26 23:55:29272 virtual PrefService* GetPrefs() {
273 return profile_->GetPrefs();
274 }
275
276 virtual TemplateURLModel* GetTemplateURLModel() {
277 return profile_->GetTemplateURLModel();
278 }
279
280 virtual TemplateURLFetcher* GetTemplateURLFetcher() {
281 return profile_->GetTemplateURLFetcher();
282 }
283
284 virtual DownloadManager* GetDownloadManager() {
285 if (!download_manager_.get()) {
286 scoped_refptr<DownloadManager> dlm(new DownloadManager);
287 dlm->Init(this);
288 download_manager_.swap(dlm);
289 }
290 return download_manager_.get();
291 }
292
293 virtual bool HasCreatedDownloadManager() const {
294 return (download_manager_.get() != NULL);
295 }
296
[email protected]def11712009-11-06 00:42:15297 virtual PersonalDataManager* GetPersonalDataManager() {
298 return NULL;
299 }
300
[email protected]4a190632009-05-09 01:07:42301 virtual void InitThemes() {
[email protected]7a1251842010-01-30 01:17:54302 profile_->InitThemes();
[email protected]4a190632009-05-09 01:07:42303 }
304
305 virtual void SetTheme(Extension* extension) {
[email protected]7a1251842010-01-30 01:17:54306 profile_->SetTheme(extension);
[email protected]4a190632009-05-09 01:07:42307 }
308
[email protected]a5166af62009-07-03 00:42:29309 virtual void SetNativeTheme() {
[email protected]7a1251842010-01-30 01:17:54310 profile_->SetNativeTheme();
[email protected]a5166af62009-07-03 00:42:29311 }
312
[email protected]4a190632009-05-09 01:07:42313 virtual void ClearTheme() {
[email protected]7a1251842010-01-30 01:17:54314 profile_->ClearTheme();
[email protected]4a190632009-05-09 01:07:42315 }
316
[email protected]51c490b2009-08-03 16:34:34317 virtual Extension* GetTheme() {
[email protected]7a1251842010-01-30 01:17:54318 return profile_->GetTheme();
[email protected]51c490b2009-08-03 16:34:34319 }
320
[email protected]5786d3d2009-12-18 00:18:44321 virtual BrowserThemeProvider* GetThemeProvider() {
[email protected]7a1251842010-01-30 01:17:54322 return profile_->GetThemeProvider();
[email protected]4a190632009-05-09 01:07:42323 }
324
[email protected]be180c802009-10-23 06:33:31325 virtual URLRequestContextGetter* GetRequestContext() {
initial.commit09911bf2008-07-26 23:55:29326 return request_context_;
327 }
328
[email protected]be180c802009-10-23 06:33:31329 virtual URLRequestContextGetter* GetRequestContextForMedia() {
[email protected]d14c7ac2009-05-29 20:38:11330 // In OTR mode, media request context is the same as the original one.
331 return request_context_;
[email protected]e7f29642009-03-02 22:53:18332 }
333
[email protected]be180c802009-10-23 06:33:31334 URLRequestContextGetter* GetRequestContextForExtensions() {
[email protected]55a35692010-02-11 23:25:21335 return GetOriginalProfile()->GetRequestContextForExtensions();
[email protected]47accfd62009-05-14 18:46:21336 }
337
[email protected]db36938c2009-08-19 21:48:42338 virtual net::SSLConfigService* GetSSLConfigService() {
[email protected]7a1251842010-01-30 01:17:54339 return profile_->GetSSLConfigService();
[email protected]db36938c2009-08-19 21:48:42340 }
341
[email protected]e284e6d82010-01-29 19:49:45342 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
[email protected]bd147842010-04-09 15:29:17343 // Retrieve the host content settings map of the parent profile in order to
344 // ensure the preferences have been migrated.
345 profile_->GetHostContentSettingsMap();
346 if (!host_content_settings_map_.get())
347 host_content_settings_map_ = new HostContentSettingsMap(this);
348 return host_content_settings_map_.get();
[email protected]e284e6d82010-01-29 19:49:45349 }
350
[email protected]40bd6582009-12-04 23:49:51351 virtual HostZoomMap* GetHostZoomMap() {
[email protected]c18d4f482010-05-18 21:19:50352 if (!host_zoom_map_)
353 host_zoom_map_ = new HostZoomMap(this);
354 return host_zoom_map_.get();
[email protected]40bd6582009-12-04 23:49:51355 }
356
[email protected]aee541e2010-03-19 01:52:45357 virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap() {
358 return profile_->GetGeolocationContentSettingsMap();
359 }
360
[email protected]8b4b84ee2010-05-11 13:08:52361 virtual GeolocationPermissionContext* GetGeolocationPermissionContext() {
362 return profile_->GetGeolocationPermissionContext();
363 }
364
[email protected]6c32ce72010-03-08 05:18:06365 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() {
366 return profile_->GetUserStyleSheetWatcher();
367 }
368
[email protected]e5d2f7132010-04-09 18:13:53369 virtual FindBarState* GetFindBarState() {
370 if (!find_bar_state_.get())
371 find_bar_state_.reset(new FindBarState());
372 return find_bar_state_.get();
373 }
374
initial.commit09911bf2008-07-26 23:55:29375 virtual SessionService* GetSessionService() {
376 // Don't save any sessions when off the record.
377 return NULL;
378 }
379
380 virtual void ShutdownSessionService() {
381 // We don't allow a session service, nothing to do.
382 }
383
384 virtual bool HasSessionService() const {
385 // We never have a session service.
386 return false;
387 }
388
initial.commit09911bf2008-07-26 23:55:29389 virtual bool DidLastSessionExitCleanly() {
390 return profile_->DidLastSessionExitCleanly();
391 }
392
[email protected]d8e41ed2008-09-11 15:22:32393 virtual BookmarkModel* GetBookmarkModel() {
394 return profile_->GetBookmarkModel();
initial.commit09911bf2008-07-26 23:55:29395 }
396
[email protected]4bb336302009-10-12 05:44:26397 virtual DesktopNotificationService* GetDesktopNotificationService() {
[email protected]7d7696c52009-12-01 20:54:58398 if (!desktop_notification_service_.get()) {
399 desktop_notification_service_.reset(new DesktopNotificationService(
400 this, g_browser_process->notification_ui_manager()));
401 }
402 return desktop_notification_service_.get();
[email protected]4bb336302009-10-12 05:44:26403 }
404
[email protected]8e4c29612010-07-14 01:24:45405 virtual TokenService* GetTokenService() {
406 return NULL;
407 }
408
[email protected]48352c12009-08-15 01:19:11409 virtual ProfileSyncService* GetProfileSyncService() {
410 return NULL;
[email protected]3a453fa2008-08-15 18:46:34411 }
[email protected]3a453fa2008-08-15 18:46:34412
[email protected]1bd056e2010-04-20 02:03:48413 virtual CloudPrintProxyService* GetCloudPrintProxyService() {
414 return NULL;
415 }
416
initial.commit09911bf2008-07-26 23:55:29417 virtual bool IsSameProfile(Profile* profile) {
[email protected]7a1251842010-01-30 01:17:54418 return (profile == this) || (profile == profile_);
initial.commit09911bf2008-07-26 23:55:29419 }
420
421 virtual Time GetStartTime() const {
422 return start_time_;
423 }
424
425 virtual TabRestoreService* GetTabRestoreService() {
426 return NULL;
427 }
428
[email protected]e7244d82008-10-29 18:13:26429 virtual void ResetTabRestoreService() {
[email protected]20930852008-10-15 19:30:41430 }
431
[email protected]85c55dc2009-11-06 03:05:46432 virtual SpellCheckHost* GetSpellCheckHost() {
433 return profile_->GetSpellCheckHost();
434 }
435
436 virtual void ReinitializeSpellCheckHost(bool force) {
437 profile_->ReinitializeSpellCheckHost(force);
438 }
[email protected]85c55dc2009-11-06 03:05:46439
[email protected]3bf335a2009-06-26 20:46:06440 virtual WebKitContext* GetWebKitContext() {
[email protected]c27324b2009-11-19 22:44:29441 if (!webkit_context_.get())
[email protected]70c19a932010-05-14 12:59:11442 webkit_context_ = new WebKitContext(this);
[email protected]c27324b2009-11-19 22:44:29443 DCHECK(webkit_context_.get());
444 return webkit_context_.get();
445 }
[email protected]3bf335a2009-06-26 20:46:06446
[email protected]523623c2010-05-19 16:03:42447 virtual history::TopSites* GetTopSites() {
448 return NULL;
449 }
450
initial.commit09911bf2008-07-26 23:55:29451 virtual void MarkAsCleanShutdown() {
452 }
453
[email protected]bdbc87c2009-01-25 05:08:54454 virtual void InitExtensions() {
455 NOTREACHED();
456 }
457
[email protected]9c8dd902009-11-19 17:50:42458 virtual NTPResourceCache* GetNTPResourceCache() {
459 // Just return the real profile resource cache.
460 return profile_->GetNTPResourceCache();
461 }
462
[email protected]35896a32010-06-09 08:42:51463 virtual FilePath last_selected_directory() {
464 const FilePath& directory = last_selected_directory_;
465 if (directory.empty()) {
466 return profile_->last_selected_directory();
467 }
468 return directory;
469 }
470
471 virtual void set_last_selected_directory(const FilePath& path) {
472 last_selected_directory_ = path;
473 }
474
initial.commit09911bf2008-07-26 23:55:29475 virtual void ExitedOffTheRecordMode() {
476 // Drop our download manager so we forget about all the downloads made
477 // in off-the-record mode.
478 download_manager_ = NULL;
479 }
480
481 virtual void Observe(NotificationType type,
482 const NotificationSource& source,
483 const NotificationDetails& details) {
[email protected]bfd04a62009-02-01 18:16:56484 DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value);
initial.commit09911bf2008-07-26 23:55:29485 // We are only interested in OTR browser closing.
486 if (Source<Browser>(source)->profile() != this)
487 return;
488
489 // Let's check if we still have an Off The Record window opened.
490 // Note that we check against 1 as this notification is sent before the
491 // browser window is actually removed from the list.
492 if (BrowserList::GetBrowserCount(this) <= 1)
493 ExitedOffTheRecordMode();
494 }
495
496 private:
[email protected]88cf3292009-05-22 01:48:43497 NotificationRegistrar registrar_;
498
initial.commit09911bf2008-07-26 23:55:29499 // The real underlying profile.
500 Profile* profile_;
501
[email protected]6ab9b202008-12-23 22:34:50502 // The context to use for requests made from this OTR session.
[email protected]13c30922009-11-19 03:43:19503 scoped_refptr<ChromeURLRequestContextGetter> request_context_;
initial.commit09911bf2008-07-26 23:55:29504
505 // The download manager that only stores downloaded items in memory.
506 scoped_refptr<DownloadManager> download_manager_;
507
[email protected]7d7696c52009-12-01 20:54:58508 // Use a separate desktop notification service for OTR.
509 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
510
[email protected]bd147842010-04-09 15:29:17511 // We use a non-writable content settings map for OTR.
512 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
513
[email protected]c18d4f482010-05-18 21:19:50514 // Use a separate zoom map for OTR.
515 scoped_refptr<HostZoomMap> host_zoom_map_;
516
[email protected]3bf335a2009-06-26 20:46:06517 // Use a special WebKit context for OTR browsing.
518 scoped_refptr<WebKitContext> webkit_context_;
519
[email protected]34cc84f2009-02-13 10:04:35520 // We don't want SSLHostState from the OTR profile to leak back to the main
521 // profile because then the main profile would learn some of the host names
522 // the user visited while OTR.
523 scoped_ptr<SSLHostState> ssl_host_state_;
524
[email protected]e5d2f7132010-04-09 18:13:53525 // Use a separate FindBarState so search terms do not leak back to the main
526 // profile.
527 scoped_ptr<FindBarState> find_bar_state_;
528
[email protected]326e6792009-12-11 21:04:42529 // The TransportSecurityState that only stores enabled sites in memory.
530 scoped_refptr<net::TransportSecurityState>
531 transport_security_state_;
[email protected]a9cea7542009-05-20 04:30:23532
initial.commit09911bf2008-07-26 23:55:29533 // Time we were started.
534 Time start_time_;
535
[email protected]2f351cb2009-11-09 23:43:34536 // The main database tracker for this profile.
537 // Should be used only on the file thread.
538 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
539
[email protected]35896a32010-06-09 08:42:51540 FilePath last_selected_directory_;
541
[email protected]398206c2010-06-21 01:46:08542 // Tracks all BackgroundContents running under this profile.
543 scoped_ptr<BackgroundContentsService> background_contents_service_;
544
[email protected]90085af02009-10-29 17:53:21545 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
initial.commit09911bf2008-07-26 23:55:29546};
547
[email protected]5a0b42e2010-07-30 23:42:59548Profile *Profile::CreateOffTheRecordProfile() {
549 return new OffTheRecordProfileImpl(this);
[email protected]48352c12009-08-15 01:19:11550}
[email protected]1bd056e2010-04-20 02:03:48551