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() override
;
47 bool IsChild() override
;
48 bool IsLegacySupervised() 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 DevToolsNetworkController
* GetDevToolsNetworkController() override
;
82 void ClearNetworkingHistorySince(base::Time time
,
83 const base::Closure
& completion
) override
;
84 GURL
GetHomePage() override
;
86 // content::BrowserContext implementation:
87 base::FilePath
GetPath() const override
;
88 scoped_ptr
<content::ZoomLevelDelegate
> CreateZoomLevelDelegate(
89 const base::FilePath
& partition_path
) override
;
90 scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() override
;
91 bool IsOffTheRecord() const override
;
92 content::DownloadManagerDelegate
* GetDownloadManagerDelegate() override
;
93 net::URLRequestContextGetter
* GetRequestContext() override
;
94 net::URLRequestContextGetter
* GetRequestContextForRenderProcess(
95 int renderer_child_id
) override
;
96 net::URLRequestContextGetter
* GetMediaRequestContext() override
;
97 net::URLRequestContextGetter
* GetMediaRequestContextForRenderProcess(
98 int renderer_child_id
) override
;
99 net::URLRequestContextGetter
* GetMediaRequestContextForStoragePartition(
100 const base::FilePath
& partition_path
,
101 bool in_memory
) override
;
102 content::ResourceContext
* GetResourceContext() override
;
103 content::BrowserPluginGuestManager
* GetGuestManager() override
;
104 storage::SpecialStoragePolicy
* GetSpecialStoragePolicy() override
;
105 content::PushMessagingService
* GetPushMessagingService() override
;
106 content::SSLHostStateDelegate
* GetSSLHostStateDelegate() override
;
107 content::PermissionManager
* GetPermissionManager() override
;
112 // Allows a profile to track changes in zoom levels in its parent profile.
113 void TrackZoomLevelsFromParent();
115 #if defined(OS_ANDROID) || defined(OS_IOS)
116 void UseSystemProxy();
117 #endif // defined(OS_ANDROID) || defined(OS_IOS)
119 PrefProxyConfigTracker
* CreateProxyConfigTracker();
120 // Callback function for tracking parent's zoom level changes.
121 void OnParentZoomLevelChanged(
122 const content::HostZoomMap::ZoomLevelChange
& change
);
123 void UpdateDefaultZoomLevel();
125 // The real underlying profile.
128 // Weak pointer owned by |profile_|.
129 PrefServiceSyncable
* prefs_
;
131 scoped_ptr
<content::HostZoomMap::Subscription
> track_zoom_subscription_
;
132 scoped_ptr
<chrome::ChromeZoomLevelPrefs::DefaultZoomLevelSubscription
>
133 parent_default_zoom_level_subscription_
;
134 scoped_ptr
<OffTheRecordProfileIOData::Handle
> io_data_
;
136 // We use a non-persistent content settings map for OTR.
137 scoped_refptr
<HostContentSettingsMap
> host_content_settings_map_
;
139 // Time we were started.
142 base::FilePath last_selected_directory_
;
144 scoped_ptr
<PrefProxyConfigTracker
> pref_proxy_config_tracker_
;
146 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl
);
149 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_