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