1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_
6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_
10 #include "base/gtest_prod_util.h"
11 #include "chrome/browser/profiles/off_the_record_profile_io_data.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_list.h"
14 #include "content/public/browser/content_browser_client.h"
15 #include "content/public/browser/host_zoom_map.h"
18 using base::TimeDelta
;
20 class PrefServiceSyncable
;
22 ////////////////////////////////////////////////////////////////////////////////
24 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
25 // to make it suitable for the incognito mode.
27 // Note: This class is a leaf class and is not intended for subclassing.
28 // Providing this header file is for unit testing.
30 ////////////////////////////////////////////////////////////////////////////////
31 class OffTheRecordProfileImpl
: public Profile
{
33 explicit OffTheRecordProfileImpl(Profile
* real_profile
);
34 virtual ~OffTheRecordProfileImpl();
37 // Profile implementation.
38 virtual std::string
GetProfileName() OVERRIDE
;
39 virtual Profile
* GetOffTheRecordProfile() OVERRIDE
;
40 virtual void DestroyOffTheRecordProfile() OVERRIDE
;
41 virtual bool HasOffTheRecordProfile() OVERRIDE
;
42 virtual Profile
* GetOriginalProfile() OVERRIDE
;
43 virtual ExtensionService
* GetExtensionService() OVERRIDE
;
44 virtual ExtensionSpecialStoragePolicy
*
45 GetExtensionSpecialStoragePolicy() OVERRIDE
;
46 virtual policy::ManagedModePolicyProvider
*
47 GetManagedModePolicyProvider() OVERRIDE
;
48 virtual policy::PolicyService
* GetPolicyService() OVERRIDE
;
49 virtual PrefService
* GetPrefs() OVERRIDE
;
50 virtual PrefService
* GetOffTheRecordPrefs() OVERRIDE
;
51 virtual net::URLRequestContextGetter
*
52 GetRequestContextForExtensions() OVERRIDE
;
53 virtual net::URLRequestContextGetter
* CreateRequestContext(
54 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
55 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
56 const base::FilePath
& partition_path
,
58 content::ProtocolHandlerMap
* protocol_handlers
) OVERRIDE
;
59 virtual net::SSLConfigService
* GetSSLConfigService() OVERRIDE
;
60 virtual HostContentSettingsMap
* GetHostContentSettingsMap() OVERRIDE
;
61 virtual bool IsSameProfile(Profile
* profile
) OVERRIDE
;
62 virtual Time
GetStartTime() const OVERRIDE
;
63 virtual history::TopSites
* GetTopSitesWithoutCreating() OVERRIDE
;
64 virtual history::TopSites
* GetTopSites() OVERRIDE
;
65 virtual base::FilePath
last_selected_directory() OVERRIDE
;
66 virtual void set_last_selected_directory(const base::FilePath
& path
) OVERRIDE
;
67 virtual bool WasCreatedByVersionOrLater(const std::string
& version
) OVERRIDE
;
68 virtual void SetExitType(ExitType exit_type
) OVERRIDE
;
69 virtual ExitType
GetLastSessionExitType() OVERRIDE
;
71 #if defined(OS_CHROMEOS)
72 virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE
;
73 virtual void InitChromeOSPreferences() OVERRIDE
;
75 virtual void ChangeAppLocale(const std::string
& locale
,
76 AppLocaleChangedVia
) OVERRIDE
;
77 virtual void OnLogin() OVERRIDE
;
78 #endif // defined(OS_CHROMEOS)
80 virtual PrefProxyConfigTracker
* GetProxyConfigTracker() OVERRIDE
;
82 virtual chrome_browser_net::Predictor
* GetNetworkPredictor() OVERRIDE
;
83 virtual void ClearNetworkingHistorySince(
85 const base::Closure
& completion
) OVERRIDE
;
86 virtual GURL
GetHomePage() OVERRIDE
;
88 // content::BrowserContext implementation:
89 virtual base::FilePath
GetPath() OVERRIDE
;
90 virtual scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() OVERRIDE
;
91 virtual bool IsOffTheRecord() const OVERRIDE
;
92 virtual content::DownloadManagerDelegate
*
93 GetDownloadManagerDelegate() OVERRIDE
;
94 virtual net::URLRequestContextGetter
* GetRequestContext() OVERRIDE
;
95 virtual net::URLRequestContextGetter
* GetRequestContextForRenderProcess(
96 int renderer_child_id
) OVERRIDE
;
97 virtual net::URLRequestContextGetter
* GetMediaRequestContext() OVERRIDE
;
98 virtual net::URLRequestContextGetter
* GetMediaRequestContextForRenderProcess(
99 int renderer_child_id
) OVERRIDE
;
100 virtual net::URLRequestContextGetter
*
101 GetMediaRequestContextForStoragePartition(
102 const base::FilePath
& partition_path
,
103 bool in_memory
) OVERRIDE
;
104 virtual content::ResourceContext
* GetResourceContext() OVERRIDE
;
105 virtual content::GeolocationPermissionContext
*
106 GetGeolocationPermissionContext() OVERRIDE
;
107 virtual content::SpeechRecognitionPreferences
*
108 GetSpeechRecognitionPreferences() OVERRIDE
;
109 virtual quota::SpecialStoragePolicy
* GetSpecialStoragePolicy() OVERRIDE
;
112 FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest
, GetHostZoomMap
);
113 void InitHostZoomMap();
115 #if defined(OS_ANDROID) || defined(OS_IOS)
116 void UseSystemProxy();
117 #endif // defined(OS_ANDROID) || defined(OS_IOS)
119 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange
& change
);
121 // The real underlying profile.
124 // Weak pointer owned by |profile_|.
125 PrefServiceSyncable
* prefs_
;
127 OffTheRecordProfileIOData::Handle io_data_
;
129 // We use a non-persistent content settings map for OTR.
130 scoped_refptr
<HostContentSettingsMap
> host_content_settings_map_
;
132 // Time we were started.
135 base::FilePath last_selected_directory_
;
137 scoped_ptr
<PrefProxyConfigTracker
> pref_proxy_config_tracker_
;
139 content::HostZoomMap::ZoomLevelChangedCallback zoom_callback_
;
141 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl
);
144 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_