Chromium Code Reviews| 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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "content/public/browser/browser_thread.h" | 47 #include "content/public/browser/browser_thread.h" |
| 48 #include "content/public/browser/host_zoom_map.h" | 48 #include "content/public/browser/host_zoom_map.h" |
| 49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/notification_types.h" | 50 #include "content/public/browser/notification_types.h" |
| 51 #include "content/public/browser/render_process_host.h" | 51 #include "content/public/browser/render_process_host.h" |
| 52 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 53 #include "net/base/transport_security_state.h" | 53 #include "net/base/transport_security_state.h" |
| 54 #include "net/http/http_server_properties.h" | 54 #include "net/http/http_server_properties.h" |
| 55 #include "webkit/database/database_tracker.h" | 55 #include "webkit/database/database_tracker.h" |
| 56 | 56 |
| 57 #if defined(OS_ANDROID) | |
| 58 #include "chrome/browser/prefs/scoped_user_pref_update.h" | |
| 59 #endif | |
| 60 | |
| 57 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| 58 #include "chrome/browser/chromeos/preferences.h" | 62 #include "chrome/browser/chromeos/preferences.h" |
| 59 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 63 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 60 #endif | 64 #endif |
| 61 | 65 |
| 62 using content::BrowserThread; | 66 using content::BrowserThread; |
| 63 using content::DownloadManagerDelegate; | 67 using content::DownloadManagerDelegate; |
| 64 using content::HostZoomMap; | 68 using content::HostZoomMap; |
| 65 | 69 |
| 66 namespace { | 70 namespace { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 77 original_profile, otr_profile); | 81 original_profile, otr_profile); |
| 78 } | 82 } |
| 79 | 83 |
| 80 } // namespace | 84 } // namespace |
| 81 | 85 |
| 82 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 86 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
| 83 : profile_(real_profile), | 87 : profile_(real_profile), |
| 84 prefs_(real_profile->GetOffTheRecordPrefs()), | 88 prefs_(real_profile->GetOffTheRecordPrefs()), |
| 85 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 89 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 86 start_time_(Time::Now()) { | 90 start_time_(Time::Now()) { |
| 91 #if defined(OS_ANDROID) | |
| 92 UseSystemProxy(); | |
|
Lei Zhang
2012/10/02 00:25:14
I'm not that familiar with OTR profiles. Does this
bengr (incorrect)
2012/10/02 18:19:01
Done.
| |
| 93 #endif | |
| 87 } | 94 } |
| 88 | 95 |
| 89 void OffTheRecordProfileImpl::Init() { | 96 void OffTheRecordProfileImpl::Init() { |
| 90 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 97 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
| 91 | 98 |
| 92 extensions::ExtensionSystem::Get(this)->InitForOTRProfile(); | 99 extensions::ExtensionSystem::Get(this)->InitForOTRProfile(); |
| 93 | 100 |
| 94 DCHECK_NE(IncognitoModePrefs::DISABLED, | 101 DCHECK_NE(IncognitoModePrefs::DISABLED, |
| 95 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 102 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |
| 96 | 103 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 157 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
| 151 HostZoomMap* parent_host_zoom_map = | 158 HostZoomMap* parent_host_zoom_map = |
| 152 HostZoomMap::GetForBrowserContext(profile_); | 159 HostZoomMap::GetForBrowserContext(profile_); |
| 153 host_zoom_map->CopyFrom(parent_host_zoom_map); | 160 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 154 // Observe parent's HZM change for propagating change of parent's | 161 // Observe parent's HZM change for propagating change of parent's |
| 155 // change to this HZM. | 162 // change to this HZM. |
| 156 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 163 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 157 content::Source<HostZoomMap>(parent_host_zoom_map)); | 164 content::Source<HostZoomMap>(parent_host_zoom_map)); |
| 158 } | 165 } |
| 159 | 166 |
| 167 #if defined(OS_ANDROID) | |
| 168 void OffTheRecordProfileImpl::UseSystemProxy() { | |
|
rpetterson
2012/10/01 20:40:15
I like this better, but I think it should be defin
| |
| 169 // Force the use of the system-assigned proxy when off the record. | |
| 170 const char kProxyMode[] = "mode"; | |
| 171 const char kProxyServer[] = "server"; | |
| 172 const char kProxyBypassList[] = "bypass_list"; | |
| 173 const char kProxyPacUrl[] = "pac_url"; | |
| 174 DictionaryPrefUpdate update(prefs_, prefs::kProxy); | |
| 175 DictionaryValue* dict = update.Get(); | |
| 176 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); | |
| 177 dict->SetString(kProxyPacUrl, ""); | |
| 178 dict->SetString(kProxyServer, ""); | |
| 179 dict->SetString(kProxyBypassList, ""); | |
| 180 } | |
| 181 #endif // defined(OS_ANDROID) | |
| 182 | |
| 160 std::string OffTheRecordProfileImpl::GetProfileName() { | 183 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 161 // Incognito profile should not return the profile name. | 184 // Incognito profile should not return the profile name. |
| 162 return std::string(); | 185 return std::string(); |
| 163 } | 186 } |
| 164 | 187 |
| 165 FilePath OffTheRecordProfileImpl::GetPath() { | 188 FilePath OffTheRecordProfileImpl::GetPath() { |
| 166 return profile_->GetPath(); | 189 return profile_->GetPath(); |
| 167 } | 190 } |
| 168 | 191 |
| 169 bool OffTheRecordProfileImpl::IsOffTheRecord() const { | 192 bool OffTheRecordProfileImpl::IsOffTheRecord() const { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 if (!profile) | 499 if (!profile) |
| 477 profile = new OffTheRecordProfileImpl(this); | 500 profile = new OffTheRecordProfileImpl(this); |
| 478 profile->Init(); | 501 profile->Init(); |
| 479 return profile; | 502 return profile; |
| 480 } | 503 } |
| 481 | 504 |
| 482 base::Callback<ChromeURLDataManagerBackend*(void)> | 505 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 483 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 506 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 484 return io_data_.GetChromeURLDataManagerBackendGetter(); | 507 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 485 } | 508 } |
| OLD | NEW |