Upstream version 7.36.149.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 "content/public/browser/content_browser_client.h"
15 #include "content/public/browser/host_zoom_map.h"
16
17 using base::Time;
18 using base::TimeDelta;
19
20 class PrefServiceSyncable;
21
22 ////////////////////////////////////////////////////////////////////////////////
23 //
24 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
25 // to make it suitable for the incognito mode.
26 //
27 // Note: This class is a leaf class and is not intended for subclassing.
28 // Providing this header file is for unit testing.
29 //
30 ////////////////////////////////////////////////////////////////////////////////
31 class OffTheRecordProfileImpl : public Profile {
32  public:
33   explicit OffTheRecordProfileImpl(Profile* real_profile);
34   virtual ~OffTheRecordProfileImpl();
35   void Init();
36
37   // Profile implementation.
38   virtual std::string GetProfileName() OVERRIDE;
39   virtual ProfileType GetProfileType() const OVERRIDE;
40   virtual Profile* GetOffTheRecordProfile() OVERRIDE;
41   virtual void DestroyOffTheRecordProfile() OVERRIDE;
42   virtual bool HasOffTheRecordProfile() OVERRIDE;
43   virtual Profile* GetOriginalProfile() OVERRIDE;
44   virtual bool IsManaged() OVERRIDE;
45   virtual ExtensionService* GetExtensionService() 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::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
55   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
56       const base::FilePath& partition_path,
57       bool in_memory,
58       content::ProtocolHandlerMap* protocol_handlers,
59       content::ProtocolHandlerScopedVector protocol_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;
71
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)
78
79   virtual PrefProxyConfigTracker* GetProxyConfigTracker() OVERRIDE;
80
81   virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
82   virtual void ClearNetworkingHistorySince(
83       base::Time time,
84       const base::Closure& completion) OVERRIDE;
85   virtual GURL GetHomePage() OVERRIDE;
86
87   // content::BrowserContext implementation:
88   virtual base::FilePath GetPath() const OVERRIDE;
89   virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE;
90   virtual bool IsOffTheRecord() const OVERRIDE;
91   virtual content::DownloadManagerDelegate*
92       GetDownloadManagerDelegate() OVERRIDE;
93   virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
94   virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
95       int renderer_child_id) OVERRIDE;
96   virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
97   virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
98       int renderer_child_id) OVERRIDE;
99   virtual net::URLRequestContextGetter*
100       GetMediaRequestContextForStoragePartition(
101           const base::FilePath& partition_path,
102           bool in_memory) OVERRIDE;
103   virtual void RequestMidiSysExPermission(
104       int render_process_id,
105       int render_view_id,
106       int bridge_id,
107       const GURL& requesting_frame,
108       bool user_gesture,
109       const MidiSysExPermissionCallback& callback) OVERRIDE;
110   virtual void CancelMidiSysExPermissionRequest(
111       int render_process_id,
112       int render_view_id,
113       int bridge_id,
114       const GURL& requesting_frame) OVERRIDE;
115   virtual void RequestProtectedMediaIdentifierPermission(
116       int render_process_id,
117       int render_view_id,
118       int bridge_id,
119       int group_id,
120       const GURL& requesting_frame,
121       const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
122   virtual void CancelProtectedMediaIdentifierPermissionRequests(
123       int group_id) OVERRIDE;
124   virtual content::ResourceContext* GetResourceContext() OVERRIDE;
125   virtual content::GeolocationPermissionContext*
126       GetGeolocationPermissionContext() OVERRIDE;
127   virtual content::BrowserPluginGuestManagerDelegate*
128       GetGuestManagerDelegate() OVERRIDE;
129   virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
130
131  private:
132   FRIEND_TEST_ALL_PREFIXES(OffTheRecordProfileImplTest, GetHostZoomMap);
133   void InitIoData();
134   void InitHostZoomMap();
135
136 #if defined(OS_ANDROID) || defined(OS_IOS)
137   void UseSystemProxy();
138 #endif  // defined(OS_ANDROID) || defined(OS_IOS)
139
140   void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
141   PrefProxyConfigTracker* CreateProxyConfigTracker();
142
143   // The real underlying profile.
144   Profile* profile_;
145
146   // Weak pointer owned by |profile_|.
147   PrefServiceSyncable* prefs_;
148
149   scoped_ptr<OffTheRecordProfileIOData::Handle> io_data_;
150
151   // We use a non-persistent content settings map for OTR.
152   scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
153
154   // Time we were started.
155   Time start_time_;
156
157   base::FilePath last_selected_directory_;
158
159   scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
160
161   scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
162
163   DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
164 };
165
166 #endif  // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_