Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / profiles / off_the_record_profile_impl.h
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.
4
5 #ifndef CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_
6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_
7
8 #include <string>
9
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"
17
18 using base::Time;
19 using base::TimeDelta;
20
21 class PrefServiceSyncable;
22
23 ////////////////////////////////////////////////////////////////////////////////
24 //
25 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
26 // to make it suitable for the incognito mode.
27 //
28 // Note: This class is a leaf class and is not intended for subclassing.
29 // Providing this header file is for unit testing.
30 //
31 ////////////////////////////////////////////////////////////////////////////////
32 class OffTheRecordProfileImpl : public Profile {
33  public:
34   explicit OffTheRecordProfileImpl(Profile* real_profile);
35   ~OffTheRecordProfileImpl() override;
36   void Init();
37
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,
55       bool in_memory,
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;
69
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)
76
77   PrefProxyConfigTracker* GetProxyConfigTracker() override;
78
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;
84
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;
104
105  private:
106   FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest, GetHostZoomMap);
107   void InitIoData();
108   void InitHostZoomMap();
109
110 #if defined(OS_ANDROID) || defined(OS_IOS)
111   void UseSystemProxy();
112 #endif  // defined(OS_ANDROID) || defined(OS_IOS)
113
114   void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
115   PrefProxyConfigTracker* CreateProxyConfigTracker();
116
117   // The real underlying profile.
118   Profile* profile_;
119
120   // Weak pointer owned by |profile_|.
121   PrefServiceSyncable* prefs_;
122
123   scoped_ptr<OffTheRecordProfileIOData::Handle> io_data_;
124
125   // We use a non-persistent content settings map for OTR.
126   scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
127
128   // Time we were started.
129   Time start_time_;
130
131   base::FilePath last_selected_directory_;
132
133   scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
134
135   scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
136
137   DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
138 };
139
140 #endif  // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_