OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" | 5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/prefs/json_pref_store.h" | 13 #include "base/prefs/json_pref_store.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/browser/background/background_contents_service_factory.h" | 17 #include "chrome/browser/background/background_contents_service_factory.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/content_settings/host_content_settings_map.h" | 19 #include "chrome/browser/content_settings/host_content_settings_map.h" |
20 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 20 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
21 #include "chrome/browser/download/download_service.h" | 21 #include "chrome/browser/download/download_service.h" |
22 #include "chrome/browser/download/download_service_factory.h" | 22 #include "chrome/browser/download/download_service_factory.h" |
23 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | |
24 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
26 #include "chrome/browser/io_thread.h" | 25 #include "chrome/browser/io_thread.h" |
27 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 26 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
28 #include "chrome/browser/net/proxy_service_factory.h" | 27 #include "chrome/browser/net/proxy_service_factory.h" |
29 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 28 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
30 #include "chrome/browser/plugins/plugin_prefs.h" | 29 #include "chrome/browser/plugins/plugin_prefs.h" |
31 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
32 #include "chrome/browser/prefs/pref_service_syncable.h" | 31 #include "chrome/browser/prefs/pref_service_syncable.h" |
33 #include "chrome/browser/themes/theme_service.h" | 32 #include "chrome/browser/themes/theme_service.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #endif | 66 #endif |
68 | 67 |
69 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) | 68 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) |
70 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 69 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
71 #endif | 70 #endif |
72 | 71 |
73 #if defined(ENABLE_EXTENSIONS) | 72 #if defined(ENABLE_EXTENSIONS) |
74 #include "chrome/browser/guest_view/guest_view_manager.h" | 73 #include "chrome/browser/guest_view/guest_view_manager.h" |
75 #endif | 74 #endif |
76 | 75 |
| 76 #if defined(ENABLE_EXTENSIONS) |
| 77 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 78 #endif |
| 79 |
77 using content::BrowserThread; | 80 using content::BrowserThread; |
78 using content::DownloadManagerDelegate; | 81 using content::DownloadManagerDelegate; |
79 using content::HostZoomMap; | 82 using content::HostZoomMap; |
80 | 83 |
| 84 #if defined(ENABLE_EXTENSIONS) |
81 namespace { | 85 namespace { |
82 | 86 |
83 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, | 87 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, |
84 void* otr_profile) { | 88 void* otr_profile) { |
85 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileCreated( | 89 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileCreated( |
86 original_profile, otr_profile); | 90 original_profile, otr_profile); |
87 } | 91 } |
88 | 92 |
89 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, | 93 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, |
90 void* otr_profile) { | 94 void* otr_profile) { |
91 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( | 95 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( |
92 original_profile, otr_profile); | 96 original_profile, otr_profile); |
93 } | 97 } |
94 | 98 |
95 } // namespace | 99 } // namespace |
| 100 #endif |
96 | 101 |
97 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 102 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
98 : profile_(real_profile), | 103 : profile_(real_profile), |
99 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), | 104 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), |
100 start_time_(Time::Now()) { | 105 start_time_(Time::Now()) { |
101 // Register on BrowserContext. | 106 // Register on BrowserContext. |
102 user_prefs::UserPrefs::Set(this, prefs_); | 107 user_prefs::UserPrefs::Set(this, prefs_); |
103 } | 108 } |
104 | 109 |
105 void OffTheRecordProfileImpl::Init() { | 110 void OffTheRecordProfileImpl::Init() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 extensions::ExtensionIconSource* icon_source = | 146 extensions::ExtensionIconSource* icon_source = |
142 new extensions::ExtensionIconSource(profile_); | 147 new extensions::ExtensionIconSource(profile_); |
143 content::URLDataSource::Add(this, icon_source); | 148 content::URLDataSource::Add(this, icon_source); |
144 | 149 |
145 #if defined(ENABLE_PLUGINS) | 150 #if defined(ENABLE_PLUGINS) |
146 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 151 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
147 PluginPrefs::GetForProfile(this).get(), | 152 PluginPrefs::GetForProfile(this).get(), |
148 io_data_->GetResourceContextNoInit()); | 153 io_data_->GetResourceContextNoInit()); |
149 #endif | 154 #endif |
150 | 155 |
| 156 #if defined(ENABLE_EXTENSIONS) |
151 BrowserThread::PostTask( | 157 BrowserThread::PostTask( |
152 BrowserThread::IO, FROM_HERE, | 158 BrowserThread::IO, FROM_HERE, |
153 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); | 159 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); |
| 160 #endif |
154 } | 161 } |
155 | 162 |
156 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 163 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |
157 MaybeSendDestroyedNotification(); | 164 MaybeSendDestroyedNotification(); |
158 | 165 |
159 #if defined(ENABLE_PLUGINS) | 166 #if defined(ENABLE_PLUGINS) |
160 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 167 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
161 io_data_->GetResourceContextNoInit()); | 168 io_data_->GetResourceContextNoInit()); |
162 #endif | 169 #endif |
163 | 170 |
164 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( | 171 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( |
165 this); | 172 this); |
166 | 173 |
| 174 #if defined(ENABLE_EXTENSIONS) |
167 BrowserThread::PostTask( | 175 BrowserThread::PostTask( |
168 BrowserThread::IO, FROM_HERE, | 176 BrowserThread::IO, FROM_HERE, |
169 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); | 177 base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); |
| 178 #endif |
170 | 179 |
171 if (host_content_settings_map_.get()) | 180 if (host_content_settings_map_.get()) |
172 host_content_settings_map_->ShutdownOnUIThread(); | 181 host_content_settings_map_->ShutdownOnUIThread(); |
173 | 182 |
174 if (pref_proxy_config_tracker_) | 183 if (pref_proxy_config_tracker_) |
175 pref_proxy_config_tracker_->DetachFromPrefService(); | 184 pref_proxy_config_tracker_->DetachFromPrefService(); |
176 | 185 |
177 // Clears any data the network stack contains that may be related to the | 186 // Clears any data the network stack contains that may be related to the |
178 // OTR session. | 187 // OTR session. |
179 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 188 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 541 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
533 #if defined(OS_CHROMEOS) | 542 #if defined(OS_CHROMEOS) |
534 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 543 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
535 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 544 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
536 g_browser_process->local_state()); | 545 g_browser_process->local_state()); |
537 } | 546 } |
538 #endif // defined(OS_CHROMEOS) | 547 #endif // defined(OS_CHROMEOS) |
539 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 548 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
540 GetPrefs(), g_browser_process->local_state()); | 549 GetPrefs(), g_browser_process->local_state()); |
541 } | 550 } |
OLD | NEW |