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 namespace syncable_prefs
{
23 class PrefServiceSyncable
;
26 ////////////////////////////////////////////////////////////////////////////////
28 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
29 // to make it suitable for the incognito mode.
31 // Note: This class is a leaf class and is not intended for subclassing.
32 // Providing this header file is for unit testing.
34 ////////////////////////////////////////////////////////////////////////////////
35 class OffTheRecordProfileImpl
: public Profile
{
37 explicit OffTheRecordProfileImpl(Profile
* real_profile
);
38 ~OffTheRecordProfileImpl() override
;
41 // Profile implementation.
42 std::string
GetProfileUserName() const override
;
43 ProfileType
GetProfileType() const override
;
44 Profile
* GetOffTheRecordProfile() override
;
45 void DestroyOffTheRecordProfile() override
;
46 bool HasOffTheRecordProfile() override
;
47 Profile
* GetOriginalProfile() override
;
48 bool IsSupervised() const override
;
49 bool IsChild() const override
;
50 bool IsLegacySupervised() const override
;
51 ExtensionSpecialStoragePolicy
* GetExtensionSpecialStoragePolicy() override
;
52 PrefService
* GetPrefs() override
;
53 const PrefService
* GetPrefs() const override
;
54 PrefService
* GetOffTheRecordPrefs() override
;
55 net::URLRequestContextGetter
* GetRequestContextForExtensions() override
;
56 net::URLRequestContextGetter
* CreateRequestContext(
57 content::ProtocolHandlerMap
* protocol_handlers
,
58 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
59 net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
60 const base::FilePath
& partition_path
,
62 content::ProtocolHandlerMap
* protocol_handlers
,
63 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
64 net::SSLConfigService
* GetSSLConfigService() override
;
65 bool IsSameProfile(Profile
* profile
) override
;
66 Time
GetStartTime() const override
;
67 base::FilePath
last_selected_directory() override
;
68 void set_last_selected_directory(const base::FilePath
& path
) override
;
69 bool WasCreatedByVersionOrLater(const std::string
& version
) override
;
70 void SetExitType(ExitType exit_type
) override
;
71 ExitType
GetLastSessionExitType() override
;
73 #if defined(OS_CHROMEOS)
74 void ChangeAppLocale(const std::string
& locale
, AppLocaleChangedVia
) override
;
75 void OnLogin() override
;
76 void InitChromeOSPreferences() override
;
77 #endif // defined(OS_CHROMEOS)
79 PrefProxyConfigTracker
* GetProxyConfigTracker() override
;
81 chrome_browser_net::Predictor
* GetNetworkPredictor() override
;
82 DevToolsNetworkControllerHandle
* GetDevToolsNetworkControllerHandle()
84 void ClearNetworkingHistorySince(base::Time time
,
85 const base::Closure
& completion
) override
;
86 GURL
GetHomePage() override
;
88 // content::BrowserContext implementation:
89 base::FilePath
GetPath() const override
;
90 scoped_ptr
<content::ZoomLevelDelegate
> CreateZoomLevelDelegate(
91 const base::FilePath
& partition_path
) override
;
92 scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() override
;
93 bool IsOffTheRecord() const override
;
94 content::DownloadManagerDelegate
* GetDownloadManagerDelegate() override
;
95 net::URLRequestContextGetter
* GetRequestContext() override
;
96 net::URLRequestContextGetter
* GetRequestContextForRenderProcess(
97 int renderer_child_id
) override
;
98 net::URLRequestContextGetter
* GetMediaRequestContext() override
;
99 net::URLRequestContextGetter
* GetMediaRequestContextForRenderProcess(
100 int renderer_child_id
) override
;
101 net::URLRequestContextGetter
* GetMediaRequestContextForStoragePartition(
102 const base::FilePath
& partition_path
,
103 bool in_memory
) override
;
104 content::ResourceContext
* GetResourceContext() override
;
105 content::BrowserPluginGuestManager
* GetGuestManager() override
;
106 storage::SpecialStoragePolicy
* GetSpecialStoragePolicy() override
;
107 content::PushMessagingService
* GetPushMessagingService() override
;
108 content::SSLHostStateDelegate
* GetSSLHostStateDelegate() override
;
109 content::PermissionManager
* GetPermissionManager() override
;
114 // Allows a profile to track changes in zoom levels in its parent profile.
115 void TrackZoomLevelsFromParent();
117 #if defined(OS_ANDROID) || defined(OS_IOS)
118 void UseSystemProxy();
119 #endif // defined(OS_ANDROID) || defined(OS_IOS)
121 PrefProxyConfigTracker
* CreateProxyConfigTracker();
122 // Callback function for tracking parent's zoom level changes.
123 void OnParentZoomLevelChanged(
124 const content::HostZoomMap::ZoomLevelChange
& change
);
125 void UpdateDefaultZoomLevel();
127 // The real underlying profile.
130 // Weak pointer owned by |profile_|.
131 syncable_prefs::PrefServiceSyncable
* prefs_
;
133 scoped_ptr
<content::HostZoomMap::Subscription
> track_zoom_subscription_
;
134 scoped_ptr
<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription
>
135 parent_default_zoom_level_subscription_
;
136 scoped_ptr
<OffTheRecordProfileIOData::Handle
> io_data_
;
138 // Time we were started.
141 base::FilePath last_selected_directory_
;
143 scoped_ptr
<PrefProxyConfigTracker
> pref_proxy_config_tracker_
;
145 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl
);
148 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_