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 "components/domain_reliability/clear_mode.h"
15 #include "content/public/browser/content_browser_client.h"
16 #include "content/public/browser/host_zoom_map.h"
19 using base::TimeDelta
;
21 class PrefServiceSyncable
;
23 ////////////////////////////////////////////////////////////////////////////////
25 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
26 // to make it suitable for the incognito mode.
28 // Note: This class is a leaf class and is not intended for subclassing.
29 // Providing this header file is for unit testing.
31 ////////////////////////////////////////////////////////////////////////////////
32 class OffTheRecordProfileImpl
: public Profile
{
34 explicit OffTheRecordProfileImpl(Profile
* real_profile
);
35 virtual ~OffTheRecordProfileImpl();
38 // Profile implementation.
39 virtual std::string
GetProfileName() override
;
40 virtual ProfileType
GetProfileType() const override
;
41 virtual Profile
* GetOffTheRecordProfile() override
;
42 virtual void DestroyOffTheRecordProfile() override
;
43 virtual bool HasOffTheRecordProfile() override
;
44 virtual Profile
* GetOriginalProfile() override
;
45 virtual bool IsSupervised() override
;
46 virtual ExtensionSpecialStoragePolicy
*
47 GetExtensionSpecialStoragePolicy() override
;
48 virtual PrefService
* GetPrefs() override
;
49 virtual PrefService
* GetOffTheRecordPrefs() override
;
50 virtual net::URLRequestContextGetter
*
51 GetRequestContextForExtensions() override
;
52 virtual net::URLRequestContextGetter
* CreateRequestContext(
53 content::ProtocolHandlerMap
* protocol_handlers
,
54 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
55 virtual net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
56 const base::FilePath
& partition_path
,
58 content::ProtocolHandlerMap
* protocol_handlers
,
59 content::URLRequestInterceptorScopedVector request_interceptors
) override
;
60 virtual net::SSLConfigService
* GetSSLConfigService() override
;
61 virtual HostContentSettingsMap
* GetHostContentSettingsMap() override
;
62 virtual bool IsSameProfile(Profile
* profile
) override
;
63 virtual Time
GetStartTime() const override
;
64 virtual history::TopSites
* GetTopSitesWithoutCreating() override
;
65 virtual history::TopSites
* GetTopSites() override
;
66 virtual base::FilePath
last_selected_directory() override
;
67 virtual void set_last_selected_directory(const base::FilePath
& path
) override
;
68 virtual bool WasCreatedByVersionOrLater(const std::string
& version
) override
;
69 virtual void SetExitType(ExitType exit_type
) override
;
70 virtual ExitType
GetLastSessionExitType() override
;
72 #if defined(OS_CHROMEOS)
73 virtual void ChangeAppLocale(const std::string
& locale
,
74 AppLocaleChangedVia
) override
;
75 virtual void OnLogin() override
;
76 virtual void InitChromeOSPreferences() override
;
77 #endif // defined(OS_CHROMEOS)
79 virtual PrefProxyConfigTracker
* GetProxyConfigTracker() override
;
81 virtual chrome_browser_net::Predictor
* GetNetworkPredictor() override
;
82 virtual DevToolsNetworkController
* GetDevToolsNetworkController() 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() const 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::BrowserPluginGuestManager
* GetGuestManager() override
;
106 virtual storage::SpecialStoragePolicy
* GetSpecialStoragePolicy() override
;
107 virtual content::PushMessagingService
* GetPushMessagingService() override
;
108 virtual content::SSLHostStateDelegate
* GetSSLHostStateDelegate() override
;
111 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
);
120 PrefProxyConfigTracker
* CreateProxyConfigTracker();
122 // The real underlying profile.
125 // Weak pointer owned by |profile_|.
126 PrefServiceSyncable
* prefs_
;
128 scoped_ptr
<OffTheRecordProfileIOData::Handle
> io_data_
;
130 // We use a non-persistent content settings map for OTR.
131 scoped_refptr
<HostContentSettingsMap
> host_content_settings_map_
;
133 // Time we were started.
136 base::FilePath last_selected_directory_
;
138 scoped_ptr
<PrefProxyConfigTracker
> pref_proxy_config_tracker_
;
140 scoped_ptr
<content::HostZoomMap::Subscription
> zoom_subscription_
;
142 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl
);
145 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_