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 "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
15 #include "components/domain_reliability/clear_mode.h"
16 #include "content/public/browser/content_browser_client.h"
17 #include "content/public/browser/host_zoom_map.h"
20 using base::TimeDelta
;
22 class PrefServiceSyncable
;
24 ////////////////////////////////////////////////////////////////////////////////
26 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
27 // to make it suitable for the incognito mode.
29 // Note: This class is a leaf class and is not intended for subclassing.
30 // Providing this header file is for unit testing.
32 ////////////////////////////////////////////////////////////////////////////////
33 class OffTheRecordProfileImpl
: public Profile
{
35 explicit OffTheRecordProfileImpl(Profile
* real_profile
);
36 ~OffTheRecordProfileImpl() override
;
39 // Profile implementation.
40 std::string
GetProfileUserName() const override
;
41 ProfileType
GetProfileType() const override
;
42 Profile
* GetOffTheRecordProfile() override
;
43 void DestroyOffTheRecordProfile() override
;
44 bool HasOffTheRecordProfile() override
;
45 Profile
* GetOriginalProfile() override
;
46 bool IsSupervised() const override
;
47 bool IsChild() const override
;
48 bool IsLegacySupervised() const override
;
49 ExtensionSpecialStoragePolicy
* GetExtensionSpecialStoragePolicy() override
;
50 PrefService
* GetPrefs() override
;
51 const PrefService
* GetPrefs() const override
;
52 PrefService
* GetOffTheRecordPrefs() override
;
53 net::URLRequestContextGetter
* GetRequestContextForExtensions() override
;
54 net::URLRequestContextGetter
* CreateRequestContext(
55 content::ProtocolHandlerMap
* protocol_handlers
,
56 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
57 net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
58 const base::FilePath
& partition_path
,
60 content::ProtocolHandlerMap
* protocol_handlers
,
61 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
62 net::SSLConfigService
* GetSSLConfigService() override
;
63 HostContentSettingsMap
* GetHostContentSettingsMap() override
;
64 bool IsSameProfile(Profile
* profile
) override
;
65 Time
GetStartTime() const override
;
66 base::FilePath
last_selected_directory() override
;
67 void set_last_selected_directory(const base::FilePath
& path
) override
;
68 bool WasCreatedByVersionOrLater(const std::string
& version
) override
;
69 void SetExitType(ExitType exit_type
) override
;
70 ExitType
GetLastSessionExitType() override
;
72 #if defined(OS_CHROMEOS)
73 void ChangeAppLocale(const std::string
& locale
, AppLocaleChangedVia
) override
;
74 void OnLogin() override
;
75 void InitChromeOSPreferences() override
;
76 #endif // defined(OS_CHROMEOS)
78 PrefProxyConfigTracker
* GetProxyConfigTracker() override
;
80 chrome_browser_net::Predictor
* GetNetworkPredictor() override
;
81 DevToolsNetworkControllerHandle
* GetDevToolsNetworkControllerHandle()
83 void ClearNetworkingHistorySince(base::Time time
,
84 const base::Closure
& completion
) override
;
85 GURL
GetHomePage() override
;
87 // content::BrowserContext implementation:
88 base::FilePath
GetPath() const override
;
89 scoped_ptr
<content::ZoomLevelDelegate
> CreateZoomLevelDelegate(
90 const base::FilePath
& partition_path
) override
;
91 scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() override
;
92 bool IsOffTheRecord() const override
;
93 content::DownloadManagerDelegate
* GetDownloadManagerDelegate() override
;
94 net::URLRequestContextGetter
* GetRequestContext() override
;
95 net::URLRequestContextGetter
* GetRequestContextForRenderProcess(
96 int renderer_child_id
) override
;
97 net::URLRequestContextGetter
* GetMediaRequestContext() override
;
98 net::URLRequestContextGetter
* GetMediaRequestContextForRenderProcess(
99 int renderer_child_id
) override
;
100 net::URLRequestContextGetter
* GetMediaRequestContextForStoragePartition(
101 const base::FilePath
& partition_path
,
102 bool in_memory
) override
;
103 content::ResourceContext
* GetResourceContext() override
;
104 content::BrowserPluginGuestManager
* GetGuestManager() override
;
105 storage::SpecialStoragePolicy
* GetSpecialStoragePolicy() override
;
106 content::PushMessagingService
* GetPushMessagingService() override
;
107 content::SSLHostStateDelegate
* GetSSLHostStateDelegate() override
;
108 content::PermissionManager
* GetPermissionManager() override
;
113 // Allows a profile to track changes in zoom levels in its parent profile.
114 void TrackZoomLevelsFromParent();
116 #if defined(OS_ANDROID) || defined(OS_IOS)
117 void UseSystemProxy();
118 #endif // defined(OS_ANDROID) || defined(OS_IOS)
120 PrefProxyConfigTracker
* CreateProxyConfigTracker();
121 // Callback function for tracking parent's zoom level changes.
122 void OnParentZoomLevelChanged(
123 const content::HostZoomMap::ZoomLevelChange
& change
);
124 void UpdateDefaultZoomLevel();
126 // The real underlying profile.
129 // Weak pointer owned by |profile_|.
130 PrefServiceSyncable
* prefs_
;
132 scoped_ptr
<content::HostZoomMap::Subscription
> track_zoom_subscription_
;
133 scoped_ptr
<chrome::ChromeZoomLevelPrefs::DefaultZoomLevelSubscription
>
134 parent_default_zoom_level_subscription_
;
135 scoped_ptr
<OffTheRecordProfileIOData::Handle
> io_data_
;
137 // We use a non-persistent content settings map for OTR.
138 scoped_refptr
<HostContentSettingsMap
> host_content_settings_map_
;
140 // Time we were started.
143 base::FilePath last_selected_directory_
;
145 scoped_ptr
<PrefProxyConfigTracker
> pref_proxy_config_tracker_
;
147 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl
);
150 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_