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/dom_distiller/profile_utils.h" | 19 #include "chrome/browser/dom_distiller/profile_utils.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/io_thread.h" | 23 #include "chrome/browser/io_thread.h" |
24 #include "chrome/browser/net/chrome_url_request_context_getter.h" | 24 #include "chrome/browser/net/chrome_url_request_context_getter.h" |
25 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 25 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
26 #include "chrome/browser/net/proxy_service_factory.h" | 26 #include "chrome/browser/net/proxy_service_factory.h" |
27 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator. h" | |
27 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 28 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
28 #include "chrome/browser/plugins/plugin_prefs.h" | 29 #include "chrome/browser/plugins/plugin_prefs.h" |
29 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
30 #include "chrome/browser/prefs/pref_service_syncable.h" | 31 #include "chrome/browser/prefs/pref_service_syncable.h" |
31 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 32 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
32 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | 33 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
33 #include "chrome/browser/themes/theme_service.h" | 34 #include "chrome/browser/themes/theme_service.h" |
34 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 35 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
35 #include "chrome/common/chrome_constants.h" | 36 #include "chrome/common/chrome_constants.h" |
36 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 #endif | 125 #endif |
125 | 126 |
126 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 127 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
127 this); | 128 this); |
128 | 129 |
129 // Guest profiles may always be OTR. Check IncognitoModePrefs otherwise. | 130 // Guest profiles may always be OTR. Check IncognitoModePrefs otherwise. |
130 DCHECK(profile_->IsGuestSession() || | 131 DCHECK(profile_->IsGuestSession() || |
131 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) != | 132 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) != |
132 IncognitoModePrefs::DISABLED); | 133 IncognitoModePrefs::DISABLED); |
133 | 134 |
134 #if defined(OS_ANDROID) || defined(OS_IOS) | 135 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); |
bengr
2014/10/29 20:58:46
Add a comment to explain what this does.
Not at Google. Contact bengr
2014/10/29 22:30:14
Done.
| |
135 UseSystemProxy(); | |
136 #endif // defined(OS_ANDROID) || defined(OS_IOS) | |
137 | 136 |
138 // TODO(oshima): Remove the need to eagerly initialize the request context | 137 // TODO(oshima): Remove the need to eagerly initialize the request context |
139 // getter. chromeos::OnlineAttempt is illegally trying to access this | 138 // getter. chromeos::OnlineAttempt is illegally trying to access this |
140 // Profile member from a thread other than the UI thread, so we need to | 139 // Profile member from a thread other than the UI thread, so we need to |
141 // prevent a race. | 140 // prevent a race. |
142 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
143 GetRequestContext(); | 142 GetRequestContext(); |
144 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
145 | 144 |
146 InitHostZoomMap(); | 145 InitHostZoomMap(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 HostZoomMap* parent_host_zoom_map = | 203 HostZoomMap* parent_host_zoom_map = |
205 HostZoomMap::GetDefaultForBrowserContext(profile_); | 204 HostZoomMap::GetDefaultForBrowserContext(profile_); |
206 host_zoom_map->CopyFrom(parent_host_zoom_map); | 205 host_zoom_map->CopyFrom(parent_host_zoom_map); |
207 // Observe parent's HZM change for propagating change of parent's | 206 // Observe parent's HZM change for propagating change of parent's |
208 // change to this HZM. | 207 // change to this HZM. |
209 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | 208 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
210 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | 209 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, |
211 base::Unretained(this))); | 210 base::Unretained(this))); |
212 } | 211 } |
213 | 212 |
214 #if defined(OS_ANDROID) || defined(OS_IOS) | |
215 void OffTheRecordProfileImpl::UseSystemProxy() { | |
216 // Force the use of the system-assigned proxy when off the record. | |
217 const char kProxyMode[] = "mode"; | |
218 const char kProxyServer[] = "server"; | |
219 const char kProxyBypassList[] = "bypass_list"; | |
220 const char kProxyPacUrl[] = "pac_url"; | |
221 DictionaryPrefUpdate update(prefs_, prefs::kProxy); | |
222 base::DictionaryValue* dict = update.Get(); | |
223 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); | |
224 dict->SetString(kProxyPacUrl, ""); | |
225 dict->SetString(kProxyServer, ""); | |
226 dict->SetString(kProxyBypassList, ""); | |
227 } | |
228 #endif // defined(OS_ANDROID) || defined(OS_IOS) | |
229 | |
230 std::string OffTheRecordProfileImpl::GetProfileName() { | 213 std::string OffTheRecordProfileImpl::GetProfileName() { |
231 // Incognito profile should not return the profile name. | 214 // Incognito profile should not return the profile name. |
232 return std::string(); | 215 return std::string(); |
233 } | 216 } |
234 | 217 |
235 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { | 218 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { |
236 return INCOGNITO_PROFILE; | 219 return INCOGNITO_PROFILE; |
237 } | 220 } |
238 | 221 |
239 base::FilePath OffTheRecordProfileImpl::GetPath() const { | 222 base::FilePath OffTheRecordProfileImpl::GetPath() const { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 529 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
547 #if defined(OS_CHROMEOS) | 530 #if defined(OS_CHROMEOS) |
548 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 531 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
549 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 532 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
550 g_browser_process->local_state()); | 533 g_browser_process->local_state()); |
551 } | 534 } |
552 #endif // defined(OS_CHROMEOS) | 535 #endif // defined(OS_CHROMEOS) |
553 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 536 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
554 GetPrefs(), g_browser_process->local_state()); | 537 GetPrefs(), g_browser_process->local_state()); |
555 } | 538 } |
OLD | NEW |