Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / profiles / off_the_record_profile_impl.h
blobdb8650774632da0b33a2bfc7270fb15d5b6711f1
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_
8 #include <string>
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"
19 using base::Time;
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 {
34 public:
35 explicit OffTheRecordProfileImpl(Profile* real_profile);
36 ~OffTheRecordProfileImpl() override;
37 void Init();
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,
59 bool in_memory,
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;
108 private:
109 void InitIoData();
111 // Allows a profile to track changes in zoom levels in its parent profile.
112 void TrackZoomLevelsFromParent();
114 #if defined(OS_ANDROID) || defined(OS_IOS)
115 void UseSystemProxy();
116 #endif // defined(OS_ANDROID) || defined(OS_IOS)
118 PrefProxyConfigTracker* CreateProxyConfigTracker();
119 // Callback function for tracking parent's zoom level changes.
120 void OnParentZoomLevelChanged(
121 const content::HostZoomMap::ZoomLevelChange& change);
122 void UpdateDefaultZoomLevel();
124 // The real underlying profile.
125 Profile* profile_;
127 // Weak pointer owned by |profile_|.
128 PrefServiceSyncable* prefs_;
130 scoped_ptr<content::HostZoomMap::Subscription> track_zoom_subscription_;
131 scoped_ptr<chrome::ChromeZoomLevelPrefs::DefaultZoomLevelSubscription>
132 parent_default_zoom_level_subscription_;
133 scoped_ptr<OffTheRecordProfileIOData::Handle> io_data_;
135 // We use a non-persistent content settings map for OTR.
136 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
138 // Time we were started.
139 Time start_time_;
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_