profile.cc revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/profiles/profile.h"
6
7#include <string>
8
9#include "base/command_line.h"
10#include "base/file_path.h"
11#include "base/file_util.h"
12#include "base/path_service.h"
13#include "base/scoped_ptr.h"
14#include "base/string_util.h"
15#include "chrome/browser/background_contents_service.h"
16#include "chrome/browser/browser_list.h"
17#include "chrome/browser/browser_process.h"
18#include "chrome/browser/browser_thread.h"
19#include "chrome/browser/chrome_blob_storage_context.h"
20#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
21#include "chrome/browser/download/download_manager.h"
22#include "chrome/browser/extensions/extension_message_service.h"
23#include "chrome/browser/extensions/extension_pref_store.h"
24#include "chrome/browser/extensions/extension_process_manager.h"
25#include "chrome/browser/file_system/browser_file_system_helper.h"
26#include "chrome/browser/in_process_webkit/webkit_context.h"
27#include "chrome/browser/net/chrome_url_request_context.h"
28#include "chrome/browser/net/pref_proxy_config_service.h"
29#include "chrome/browser/notifications/desktop_notification_service.h"
30#include "chrome/browser/ssl/ssl_host_state.h"
31#include "chrome/browser/sync/profile_sync_service.h"
32#include "chrome/browser/themes/browser_theme_provider.h"
33#include "chrome/browser/ui/find_bar/find_bar_state.h"
34#include "chrome/common/chrome_constants.h"
35#include "chrome/common/chrome_paths.h"
36#include "chrome/common/chrome_switches.h"
37#include "chrome/common/json_pref_store.h"
38#include "chrome/common/notification_service.h"
39#include "chrome/common/pref_names.h"
40#include "chrome/common/render_messages.h"
41#include "grit/browser_resources.h"
42#include "grit/locale_settings.h"
43#include "net/base/transport_security_state.h"
44#include "ui/base/resource/resource_bundle.h"
45#include "webkit/database/database_tracker.h"
46
47#if defined(TOOLKIT_USES_GTK)
48#include "chrome/browser/ui/gtk/gtk_theme_provider.h"
49#endif
50
51#if defined(OS_WIN)
52#include "chrome/browser/password_manager/password_store_win.h"
53#elif defined(OS_MACOSX)
54#include "chrome/browser/keychain_mac.h"
55#include "chrome/browser/password_manager/password_store_mac.h"
56#elif defined(OS_POSIX) && !defined(OS_CHROMEOS)
57#include "chrome/browser/password_manager/native_backend_gnome_x.h"
58#include "chrome/browser/password_manager/native_backend_kwallet_x.h"
59#include "chrome/browser/password_manager/password_store_x.h"
60#endif
61
62using base::Time;
63using base::TimeDelta;
64
65// A pointer to the request context for the default profile.  See comments on
66// Profile::GetDefaultRequestContext.
67URLRequestContextGetter* Profile::default_request_context_;
68
69namespace {
70
71// TODO(pathorn): Duplicated in profile_impl.cc
72void CleanupRequestContext(ChromeURLRequestContextGetter* context) {
73  if (context)
74    context->CleanupOnUIThread();
75}
76
77}  // namespace
78
79#ifdef ANDROID
80// Android moved this to profile_android.cc to avoid compiling this file.
81#endif
82Profile::Profile()
83    : restored_last_session_(false),
84      accessibility_pause_level_(0) {
85}
86
87// static
88const char* Profile::kProfileKey = "__PROFILE__";
89
90// static
91const ProfileId Profile::InvalidProfileId = static_cast<ProfileId>(0);
92
93// static
94void Profile::RegisterUserPrefs(PrefService* prefs) {
95  prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
96  prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true);
97  prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, true);
98  prefs->RegisterBooleanPref(prefs::kSafeBrowsingReportingEnabled, false);
99  // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
100  prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary,
101      IDS_SPELLCHECK_DICTIONARY);
102  prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true);
103  prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true);
104#if defined(TOOLKIT_USES_GTK)
105  prefs->RegisterBooleanPref(prefs::kUsesSystemTheme,
106                             GtkThemeProvider::DefaultUsesSystemTheme());
107#endif
108  prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath());
109  prefs->RegisterStringPref(prefs::kCurrentThemeID,
110                            BrowserThemeProvider::kDefaultThemeID);
111  prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages);
112  prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors);
113  prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints);
114  prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties);
115  prefs->RegisterBooleanPref(prefs::kDisableExtensions, false);
116  prefs->RegisterStringPref(prefs::kSelectFileLastDirectory, "");
117#if defined(OS_CHROMEOS)
118  // TODO(dilmah): For OS_CHROMEOS we maintain kApplicationLocale in both
119  // local state and user's profile.  For other platforms we maintain
120  // kApplicationLocale only in local state.
121  // In the future we may want to maintain kApplicationLocale
122  // in user's profile for other platforms as well.
123  prefs->RegisterStringPref(prefs::kApplicationLocale, "");
124  prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, "");
125  prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, "");
126#endif
127}
128
129// static
130URLRequestContextGetter* Profile::GetDefaultRequestContext() {
131  return default_request_context_;
132}
133
134bool Profile::IsGuestSession() {
135#if defined(OS_CHROMEOS)
136  static bool is_guest_session =
137      CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession);
138  return is_guest_session;
139#else
140  return false;
141#endif
142}
143
144bool Profile::IsSyncAccessible() {
145  ProfileSyncService* syncService = GetProfileSyncService();
146  return syncService && !syncService->IsManaged();
147}
148
149////////////////////////////////////////////////////////////////////////////////
150//
151// OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
152// to make it suitable for the off the record mode.
153//
154////////////////////////////////////////////////////////////////////////////////
155class OffTheRecordProfileImpl : public Profile,
156                                public BrowserList::Observer {
157 public:
158  explicit OffTheRecordProfileImpl(Profile* real_profile)
159      : profile_(real_profile),
160        prefs_(real_profile->GetOffTheRecordPrefs()),
161        start_time_(Time::Now()) {
162    request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
163    extension_process_manager_.reset(ExtensionProcessManager::Create(this));
164
165    BrowserList::AddObserver(this);
166
167    background_contents_service_.reset(
168        new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
169
170    DCHECK(real_profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled));
171  }
172
173  virtual ~OffTheRecordProfileImpl() {
174    NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
175                                           Source<Profile>(this),
176                                           NotificationService::NoDetails());
177    CleanupRequestContext(request_context_);
178    CleanupRequestContext(extensions_request_context_);
179
180    // Clean up all DB files/directories
181    BrowserThread::PostTask(
182        BrowserThread::FILE, FROM_HERE,
183        NewRunnableMethod(
184            db_tracker_.get(),
185            &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
186
187    BrowserList::RemoveObserver(this);
188
189    if (pref_proxy_config_tracker_)
190      pref_proxy_config_tracker_->DetachFromPrefService();
191  }
192
193  virtual ProfileId GetRuntimeId() {
194    return reinterpret_cast<ProfileId>(this);
195  }
196
197  virtual FilePath GetPath() { return profile_->GetPath(); }
198
199  virtual bool IsOffTheRecord() {
200    return true;
201  }
202
203  virtual Profile* GetOffTheRecordProfile() {
204    return this;
205  }
206
207  virtual void DestroyOffTheRecordProfile() {
208    // Suicide is bad!
209    NOTREACHED();
210  }
211
212  virtual bool HasOffTheRecordProfile() {
213    return true;
214  }
215
216  virtual Profile* GetOriginalProfile() {
217    return profile_;
218  }
219
220  virtual ChromeAppCacheService* GetAppCacheService() {
221    if (!appcache_service_) {
222      appcache_service_ = new ChromeAppCacheService;
223      BrowserThread::PostTask(
224          BrowserThread::IO, FROM_HERE,
225          NewRunnableMethod(appcache_service_.get(),
226                            &ChromeAppCacheService::InitializeOnIOThread,
227                            GetPath(), IsOffTheRecord(),
228                            make_scoped_refptr(GetHostContentSettingsMap()),
229                            false));
230    }
231    return appcache_service_;
232  }
233
234  virtual webkit_database::DatabaseTracker* GetDatabaseTracker() {
235    if (!db_tracker_) {
236      db_tracker_ = new webkit_database::DatabaseTracker(
237          GetPath(), IsOffTheRecord());
238    }
239    return db_tracker_;
240  }
241
242  virtual VisitedLinkMaster* GetVisitedLinkMaster() {
243    // We don't provide access to the VisitedLinkMaster when we're OffTheRecord
244    // because we don't want to leak the sites that the user has visited before.
245    return NULL;
246  }
247
248  virtual ExtensionService* GetExtensionService() {
249    return GetOriginalProfile()->GetExtensionService();
250  }
251
252  virtual BackgroundContentsService* GetBackgroundContentsService() const {
253    return background_contents_service_.get();
254  }
255
256  virtual StatusTray* GetStatusTray() {
257    return GetOriginalProfile()->GetStatusTray();
258  }
259
260  virtual UserScriptMaster* GetUserScriptMaster() {
261    return GetOriginalProfile()->GetUserScriptMaster();
262  }
263
264  virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
265    // TODO(mpcomplete): figure out whether we should return the original
266    // profile's version.
267    return NULL;
268  }
269
270  virtual ExtensionProcessManager* GetExtensionProcessManager() {
271    return extension_process_manager_.get();
272  }
273
274  virtual ExtensionMessageService* GetExtensionMessageService() {
275    return GetOriginalProfile()->GetExtensionMessageService();
276  }
277
278  virtual ExtensionEventRouter* GetExtensionEventRouter() {
279    return GetOriginalProfile()->GetExtensionEventRouter();
280  }
281
282  virtual ExtensionIOEventRouter* GetExtensionIOEventRouter() {
283    return GetOriginalProfile()->GetExtensionIOEventRouter();
284  }
285
286  virtual SSLHostState* GetSSLHostState() {
287    if (!ssl_host_state_.get())
288      ssl_host_state_.reset(new SSLHostState());
289
290    DCHECK(ssl_host_state_->CalledOnValidThread());
291    return ssl_host_state_.get();
292  }
293
294  virtual net::TransportSecurityState* GetTransportSecurityState() {
295    if (!transport_security_state_.get())
296      transport_security_state_ = new net::TransportSecurityState();
297
298    return transport_security_state_.get();
299  }
300
301  virtual HistoryService* GetHistoryService(ServiceAccessType sat) {
302    if (sat == EXPLICIT_ACCESS)
303      return profile_->GetHistoryService(sat);
304
305    NOTREACHED() << "This profile is OffTheRecord";
306    return NULL;
307  }
308
309  virtual HistoryService* GetHistoryServiceWithoutCreating() {
310    return profile_->GetHistoryServiceWithoutCreating();
311  }
312
313  virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
314    if (sat == EXPLICIT_ACCESS)
315      return profile_->GetFaviconService(sat);
316
317    NOTREACHED() << "This profile is OffTheRecord";
318    return NULL;
319  }
320
321  virtual AutocompleteClassifier* GetAutocompleteClassifier() {
322    return profile_->GetAutocompleteClassifier();
323  }
324
325  virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
326    if (sat == EXPLICIT_ACCESS)
327      return profile_->GetWebDataService(sat);
328
329    NOTREACHED() << "This profile is OffTheRecord";
330    return NULL;
331  }
332
333  virtual WebDataService* GetWebDataServiceWithoutCreating() {
334    return profile_->GetWebDataServiceWithoutCreating();
335  }
336
337  virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) {
338    if (sat == EXPLICIT_ACCESS)
339      return profile_->GetPasswordStore(sat);
340
341    NOTREACHED() << "This profile is OffTheRecord";
342    return NULL;
343  }
344
345  virtual PrefService* GetPrefs() {
346    return prefs_;
347  }
348
349  virtual PrefService* GetOffTheRecordPrefs() {
350    return prefs_;
351  }
352
353  virtual TemplateURLModel* GetTemplateURLModel() {
354    return profile_->GetTemplateURLModel();
355  }
356
357  virtual TemplateURLFetcher* GetTemplateURLFetcher() {
358    return profile_->GetTemplateURLFetcher();
359  }
360
361  virtual DownloadManager* GetDownloadManager() {
362    if (!download_manager_.get()) {
363      scoped_refptr<DownloadManager> dlm(
364          new DownloadManager(g_browser_process->download_status_updater()));
365      dlm->Init(this);
366      download_manager_.swap(dlm);
367    }
368    return download_manager_.get();
369  }
370
371  virtual bool HasCreatedDownloadManager() const {
372    return (download_manager_.get() != NULL);
373  }
374
375  virtual PersonalDataManager* GetPersonalDataManager() {
376    return NULL;
377  }
378
379  virtual fileapi::FileSystemContext* GetFileSystemContext() {
380    if (!file_system_context_)
381      file_system_context_ = CreateFileSystemContext(
382          GetPath(), IsOffTheRecord());
383    DCHECK(file_system_context_.get());
384    return file_system_context_.get();
385  }
386
387  virtual void InitThemes() {
388    profile_->InitThemes();
389  }
390
391  virtual void SetTheme(const Extension* extension) {
392    profile_->SetTheme(extension);
393  }
394
395  virtual void SetNativeTheme() {
396    profile_->SetNativeTheme();
397  }
398
399  virtual void ClearTheme() {
400    profile_->ClearTheme();
401  }
402
403  virtual const Extension* GetTheme() {
404    return profile_->GetTheme();
405  }
406
407  virtual BrowserThemeProvider* GetThemeProvider() {
408    return profile_->GetThemeProvider();
409  }
410
411  virtual URLRequestContextGetter* GetRequestContext() {
412    return request_context_;
413  }
414
415  virtual URLRequestContextGetter* GetRequestContextForMedia() {
416    // In OTR mode, media request context is the same as the original one.
417    return request_context_;
418  }
419
420  URLRequestContextGetter* GetRequestContextForExtensions() {
421    if (!extensions_request_context_) {
422      extensions_request_context_ =
423          ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this);
424    }
425
426    return extensions_request_context_;
427  }
428
429  virtual net::SSLConfigService* GetSSLConfigService() {
430    return profile_->GetSSLConfigService();
431  }
432
433  virtual HostContentSettingsMap* GetHostContentSettingsMap() {
434    // Retrieve the host content settings map of the parent profile in order to
435    // ensure the preferences have been migrated.
436    profile_->GetHostContentSettingsMap();
437    if (!host_content_settings_map_.get())
438      host_content_settings_map_ = new HostContentSettingsMap(this);
439    return host_content_settings_map_.get();
440  }
441
442  virtual HostZoomMap* GetHostZoomMap() {
443    if (!host_zoom_map_)
444      host_zoom_map_ = new HostZoomMap(this);
445    return host_zoom_map_.get();
446  }
447
448  virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap() {
449    return profile_->GetGeolocationContentSettingsMap();
450  }
451
452  virtual GeolocationPermissionContext* GetGeolocationPermissionContext() {
453    return profile_->GetGeolocationPermissionContext();
454  }
455
456  virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() {
457    return profile_->GetUserStyleSheetWatcher();
458  }
459
460  virtual FindBarState* GetFindBarState() {
461    if (!find_bar_state_.get())
462      find_bar_state_.reset(new FindBarState());
463    return find_bar_state_.get();
464  }
465
466  virtual SessionService* GetSessionService() {
467    // Don't save any sessions when off the record.
468    return NULL;
469  }
470
471  virtual void ShutdownSessionService() {
472    // We don't allow a session service, nothing to do.
473  }
474
475  virtual bool HasSessionService() const {
476    // We never have a session service.
477    return false;
478  }
479
480  virtual bool HasProfileSyncService() const {
481    // We never have a profile sync service.
482    return false;
483  }
484
485  virtual bool DidLastSessionExitCleanly() {
486    return profile_->DidLastSessionExitCleanly();
487  }
488
489  virtual BookmarkModel* GetBookmarkModel() {
490    return profile_->GetBookmarkModel();
491  }
492
493  virtual DesktopNotificationService* GetDesktopNotificationService() {
494    if (!desktop_notification_service_.get()) {
495      desktop_notification_service_.reset(new DesktopNotificationService(
496          this, g_browser_process->notification_ui_manager()));
497    }
498    return desktop_notification_service_.get();
499  }
500
501  virtual TokenService* GetTokenService() {
502    return NULL;
503  }
504
505  virtual ProfileSyncService* GetProfileSyncService() {
506    return NULL;
507  }
508
509  virtual ProfileSyncService* GetProfileSyncService(
510      const std::string& cros_user) {
511    return NULL;
512  }
513
514  virtual BrowserSignin* GetBrowserSignin() {
515    return profile_->GetBrowserSignin();
516  }
517
518  virtual CloudPrintProxyService* GetCloudPrintProxyService() {
519    return NULL;
520  }
521
522  virtual bool IsSameProfile(Profile* profile) {
523    return (profile == this) || (profile == profile_);
524  }
525
526  virtual Time GetStartTime() const {
527    return start_time_;
528  }
529
530  virtual TabRestoreService* GetTabRestoreService() {
531    return NULL;
532  }
533
534  virtual void ResetTabRestoreService() {
535  }
536
537  virtual SpellCheckHost* GetSpellCheckHost() {
538    return profile_->GetSpellCheckHost();
539  }
540
541  virtual void ReinitializeSpellCheckHost(bool force) {
542    profile_->ReinitializeSpellCheckHost(force);
543  }
544
545  virtual WebKitContext* GetWebKitContext() {
546    if (!webkit_context_.get())
547      webkit_context_ = new WebKitContext(this, false);
548    DCHECK(webkit_context_.get());
549    return webkit_context_.get();
550  }
551
552  virtual history::TopSites* GetTopSitesWithoutCreating() {
553    return NULL;
554  }
555
556  virtual history::TopSites* GetTopSites() {
557    return NULL;
558  }
559
560  virtual void MarkAsCleanShutdown() {
561  }
562
563  virtual void InitExtensions() {
564    NOTREACHED();
565  }
566
567  virtual void InitWebResources() {
568    NOTREACHED();
569  }
570
571  virtual NTPResourceCache* GetNTPResourceCache() {
572    // Just return the real profile resource cache.
573    return profile_->GetNTPResourceCache();
574  }
575
576  virtual FilePath last_selected_directory() {
577    const FilePath& directory = last_selected_directory_;
578    if (directory.empty()) {
579      return profile_->last_selected_directory();
580    }
581    return directory;
582  }
583
584  virtual void set_last_selected_directory(const FilePath& path) {
585    last_selected_directory_ = path;
586  }
587
588#if defined(OS_CHROMEOS)
589  virtual chromeos::ProxyConfigServiceImpl*
590      GetChromeOSProxyConfigServiceImpl() {
591    return profile_->GetChromeOSProxyConfigServiceImpl();
592  }
593
594  virtual void SetupChromeOSEnterpriseExtensionObserver() {
595    profile_->SetupChromeOSEnterpriseExtensionObserver();
596  }
597#endif  // defined(OS_CHROMEOS)
598
599  virtual void ExitedOffTheRecordMode() {
600    // DownloadManager is lazily created, so check before accessing it.
601    if (download_manager_.get()) {
602      // Drop our download manager so we forget about all the downloads made
603      // in off-the-record mode.
604      download_manager_->Shutdown();
605      download_manager_ = NULL;
606    }
607  }
608
609  virtual void OnBrowserAdded(const Browser* browser) {
610  }
611
612  virtual void OnBrowserRemoved(const Browser* browser) {
613    if (BrowserList::GetBrowserCount(this) == 0)
614      ExitedOffTheRecordMode();
615  }
616
617  virtual ChromeBlobStorageContext* GetBlobStorageContext() {
618    if (!blob_storage_context_) {
619      blob_storage_context_ = new ChromeBlobStorageContext();
620      BrowserThread::PostTask(
621          BrowserThread::IO, FROM_HERE,
622          NewRunnableMethod(
623              blob_storage_context_.get(),
624              &ChromeBlobStorageContext::InitializeOnIOThread));
625    }
626    return blob_storage_context_;
627  }
628
629  virtual ExtensionInfoMap* GetExtensionInfoMap() {
630    return profile_->GetExtensionInfoMap();
631  }
632
633  virtual policy::ProfilePolicyContext* GetPolicyContext() {
634    return NULL;
635  }
636
637  virtual ChromeURLDataManager* GetChromeURLDataManager() {
638    if (!chrome_url_data_manager_.get())
639      chrome_url_data_manager_.reset(new ChromeURLDataManager(this));
640    return chrome_url_data_manager_.get();
641  }
642
643  virtual PromoCounter* GetInstantPromoCounter() {
644    return NULL;
645  }
646
647#if defined(OS_CHROMEOS)
648  virtual void ChangeAppLocale(const std::string& locale, AppLocaleChangedVia) {
649  }
650#endif  // defined(OS_CHROMEOS)
651
652  virtual PrefProxyConfigTracker* GetProxyConfigTracker() {
653    if (!pref_proxy_config_tracker_)
654      pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs());
655
656    return pref_proxy_config_tracker_;
657  }
658
659  virtual PrerenderManager* GetPrerenderManager() {
660    // We do not allow prerendering in OTR profiles at this point.
661    // TODO(tburkard): Figure out if we want to support this, and how, at some
662    // point in the future.
663    return NULL;
664  }
665
666 private:
667  NotificationRegistrar registrar_;
668
669  // The real underlying profile.
670  Profile* profile_;
671
672  // Weak pointer owned by |profile_|.
673  PrefService* prefs_;
674
675  scoped_ptr<ExtensionProcessManager> extension_process_manager_;
676
677  // The context to use for requests made from this OTR session.
678  scoped_refptr<ChromeURLRequestContextGetter> request_context_;
679
680  // The context to use for requests made by an extension while in OTR mode.
681  scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_;
682
683  // The download manager that only stores downloaded items in memory.
684  scoped_refptr<DownloadManager> download_manager_;
685
686  // Use a separate desktop notification service for OTR.
687  scoped_ptr<DesktopNotificationService> desktop_notification_service_;
688
689  // We use a non-writable content settings map for OTR.
690  scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
691
692  // Use a separate zoom map for OTR.
693  scoped_refptr<HostZoomMap> host_zoom_map_;
694
695  // Use a special WebKit context for OTR browsing.
696  scoped_refptr<WebKitContext> webkit_context_;
697
698  // We don't want SSLHostState from the OTR profile to leak back to the main
699  // profile because then the main profile would learn some of the host names
700  // the user visited while OTR.
701  scoped_ptr<SSLHostState> ssl_host_state_;
702
703  // Use a separate FindBarState so search terms do not leak back to the main
704  // profile.
705  scoped_ptr<FindBarState> find_bar_state_;
706
707  // The TransportSecurityState that only stores enabled sites in memory.
708  scoped_refptr<net::TransportSecurityState>
709      transport_security_state_;
710
711  // Time we were started.
712  Time start_time_;
713
714  scoped_refptr<ChromeAppCacheService> appcache_service_;
715
716  // The main database tracker for this profile.
717  // Should be used only on the file thread.
718  scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
719
720  FilePath last_selected_directory_;
721
722  // Tracks all BackgroundContents running under this profile.
723  scoped_ptr<BackgroundContentsService> background_contents_service_;
724
725  scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
726
727  // The file_system context for this profile.
728  scoped_refptr<fileapi::FileSystemContext> file_system_context_;
729
730  scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
731
732  scoped_ptr<ChromeURLDataManager> chrome_url_data_manager_;
733
734  DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
735};
736
737#if defined(OS_CHROMEOS)
738// Special case of the OffTheRecordProfileImpl which is used while Guest
739// session in CrOS.
740class GuestSessionProfile : public OffTheRecordProfileImpl {
741 public:
742  explicit GuestSessionProfile(Profile* real_profile)
743      : OffTheRecordProfileImpl(real_profile) {
744  }
745
746  virtual PersonalDataManager* GetPersonalDataManager() {
747    return GetOriginalProfile()->GetPersonalDataManager();
748  }
749};
750#endif
751
752Profile* Profile::CreateOffTheRecordProfile() {
753#if defined(OS_CHROMEOS)
754  if (Profile::IsGuestSession())
755    return new GuestSessionProfile(this);
756#endif
757  return new OffTheRecordProfileImpl(this);
758}
759