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 ~OffTheRecordProfileImpl() override;
38 // Profile implementation.
39 std::string GetProfileName() override;
40 ProfileType GetProfileType() const override;
41 Profile* GetOffTheRecordProfile() override;
42 void DestroyOffTheRecordProfile() override;
43 bool HasOffTheRecordProfile() override;
44 Profile* GetOriginalProfile() override;
45 bool IsSupervised() override;
46 ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
47 PrefService* GetPrefs() override;
48 PrefService* GetOffTheRecordPrefs() override;
49 net::URLRequestContextGetter* GetRequestContextForExtensions() override;
50 net::URLRequestContextGetter* CreateRequestContext(
51 content::ProtocolHandlerMap* protocol_handlers,
52 content::URLRequestInterceptorScopedVector request_interceptors) override;
53 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
54 const base::FilePath& partition_path,
56 content::ProtocolHandlerMap* protocol_handlers,
57 content::URLRequestInterceptorScopedVector request_interceptors) override;
58 net::SSLConfigService* GetSSLConfigService() override;
59 HostContentSettingsMap* GetHostContentSettingsMap() override;
60 bool IsSameProfile(Profile* profile) override;
61 Time GetStartTime() const override;
62 history::TopSites* GetTopSitesWithoutCreating() override;
63 history::TopSites* GetTopSites() override;
64 base::FilePath last_selected_directory() override;
65 void set_last_selected_directory(const base::FilePath& path) override;
66 bool WasCreatedByVersionOrLater(const std::string& version) override;
67 void SetExitType(ExitType exit_type) override;
68 ExitType GetLastSessionExitType() override;
70 #if defined(OS_CHROMEOS)
71 virtual void ChangeAppLocale(const std::string& locale,
72 AppLocaleChangedVia) override;
73 virtual void OnLogin() override;
74 virtual void InitChromeOSPreferences() override;
75 #endif // defined(OS_CHROMEOS)
77 PrefProxyConfigTracker* GetProxyConfigTracker() override;
79 chrome_browser_net::Predictor* GetNetworkPredictor() override;
80 DevToolsNetworkController* GetDevToolsNetworkController() override;
81 void ClearNetworkingHistorySince(base::Time time,
82 const base::Closure& completion) override;
83 GURL GetHomePage() override;
85 // content::BrowserContext implementation:
86 base::FilePath GetPath() const override;
87 scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
88 bool IsOffTheRecord() const override;
89 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
90 net::URLRequestContextGetter* GetRequestContext() override;
91 net::URLRequestContextGetter* GetRequestContextForRenderProcess(
92 int renderer_child_id) override;
93 net::URLRequestContextGetter* GetMediaRequestContext() override;
94 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
95 int renderer_child_id) override;
96 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
97 const base::FilePath& partition_path,
98 bool in_memory) override;
99 content::ResourceContext* GetResourceContext() override;
100 content::BrowserPluginGuestManager* GetGuestManager() override;
101 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
102 content::PushMessagingService* GetPushMessagingService() override;
103 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
106 FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest, GetHostZoomMap);
108 void InitHostZoomMap();
110 #if defined(OS_ANDROID) || defined(OS_IOS)
111 void UseSystemProxy();
112 #endif // defined(OS_ANDROID) || defined(OS_IOS)
114 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
115 PrefProxyConfigTracker* CreateProxyConfigTracker();
117 // The real underlying profile.
120 // Weak pointer owned by |profile_|.
121 PrefServiceSyncable* prefs_;
123 scoped_ptr<OffTheRecordProfileIOData::Handle> io_data_;
125 // We use a non-persistent content settings map for OTR.
126 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
128 // Time we were started.
131 base::FilePath last_selected_directory_;
133 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
135 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
137 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
140 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_