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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/extensions/extension.h" | 43 #include "chrome/common/extensions/extension.h" |
| 44 #include "chrome/common/json_pref_store.h" | 44 #include "chrome/common/json_pref_store.h" |
| 45 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/render_messages.h" | 46 #include "chrome/common/render_messages.h" |
| 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/storage_partition.h" | |
| 52 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
| 53 #include "net/base/transport_security_state.h" | 54 #include "net/base/transport_security_state.h" |
| 54 #include "net/http/http_server_properties.h" | 55 #include "net/http/http_server_properties.h" |
| 55 #include "webkit/database/database_tracker.h" | 56 #include "webkit/database/database_tracker.h" |
| 56 | 57 |
| 57 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
| 58 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 59 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 GetDownloadManagerDelegate(); | 271 GetDownloadManagerDelegate(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { | 274 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { |
| 274 return io_data_.GetMainRequestContextGetter(); | 275 return io_data_.GetMainRequestContextGetter(); |
| 275 } | 276 } |
| 276 | 277 |
| 277 net::URLRequestContextGetter* | 278 net::URLRequestContextGetter* |
| 278 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( | 279 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( |
| 279 int renderer_child_id) { | 280 int renderer_child_id) { |
| 280 ExtensionService* extension_service = | |
| 281 extensions::ExtensionSystem::Get(this)->extension_service(); | |
| 282 if (extension_service) { | |
| 283 const extensions::Extension* extension = | |
| 284 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | |
| 285 if (extension) | |
| 286 return GetRequestContextForStoragePartition(extension->id()); | |
| 287 } | |
| 288 | |
| 289 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 281 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 290 renderer_child_id); | 282 renderer_child_id); |
| 291 if (rph && rph->IsGuest()) { | 283 CHECK(rph); |
| 292 // For guest processes (used by the browser tag), we need to isolate the | 284 content::StoragePartition* storage_partition = rph->GetStoragePartition(); |
| 293 // storage. | 285 return storage_partition->GetURLRequestContext(); |
|
awong
2012/10/19 21:20:24
return rpn->GetStoragePartition()->GetURLRequestCo
nasko
2012/10/19 22:09:00
Done.
| |
| 294 // TODO(nasko): Until we have proper storage partitions, create a | |
| 295 // non-persistent context using the RPH's id. | |
| 296 std::string id("guest-"); | |
| 297 id.append(base::IntToString(renderer_child_id)); | |
| 298 return GetRequestContextForStoragePartition(id); | |
| 299 } | |
| 300 | |
| 301 return GetRequestContext(); | |
| 302 } | 286 } |
| 303 | 287 |
| 304 net::URLRequestContextGetter* | 288 net::URLRequestContextGetter* |
| 305 OffTheRecordProfileImpl::GetMediaRequestContext() { | 289 OffTheRecordProfileImpl::GetMediaRequestContext() { |
| 306 // In OTR mode, media request context is the same as the original one. | 290 // In OTR mode, media request context is the same as the original one. |
| 307 return GetRequestContext(); | 291 return GetRequestContext(); |
| 308 } | 292 } |
| 309 | 293 |
| 310 net::URLRequestContextGetter* | 294 net::URLRequestContextGetter* |
| 311 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( | 295 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( |
| 312 int renderer_child_id) { | 296 int renderer_child_id) { |
| 313 // In OTR mode, media request context is the same as the original one. | 297 // In OTR mode, media request context is the same as the original one. |
| 314 return GetRequestContextForRenderProcess(renderer_child_id); | 298 return GetRequestContextForRenderProcess(renderer_child_id); |
| 315 } | 299 } |
| 316 | 300 |
| 317 net::URLRequestContextGetter* | 301 net::URLRequestContextGetter* |
| 318 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( | 302 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( |
| 319 const std::string& partition_id) { | 303 const FilePath& partition_path, |
| 320 return GetRequestContextForStoragePartition(partition_id); | 304 bool in_memory) { |
| 305 return GetRequestContextForStoragePartition(partition_path, in_memory); | |
| 321 } | 306 } |
| 322 | 307 |
| 323 net::URLRequestContextGetter* | 308 net::URLRequestContextGetter* |
| 324 OffTheRecordProfileImpl::GetRequestContextForExtensions() { | 309 OffTheRecordProfileImpl::GetRequestContextForExtensions() { |
| 325 return io_data_.GetExtensionsRequestContextGetter(); | 310 return io_data_.GetExtensionsRequestContextGetter(); |
| 326 } | 311 } |
| 327 | 312 |
| 328 net::URLRequestContextGetter* | 313 net::URLRequestContextGetter* |
| 329 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( | 314 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( |
| 330 const std::string& partition_id) { | 315 const FilePath& partition_path, |
| 331 return io_data_.GetIsolatedAppRequestContextGetter(partition_id); | 316 bool in_memory) { |
| 317 return io_data_.GetIsolatedAppRequestContextGetter(partition_path, in_memory); | |
| 332 } | 318 } |
| 333 | 319 |
| 334 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { | 320 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { |
| 335 return io_data_.GetResourceContext(); | 321 return io_data_.GetResourceContext(); |
| 336 } | 322 } |
| 337 | 323 |
| 338 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { | 324 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { |
| 339 return profile_->GetSSLConfigService(); | 325 return profile_->GetSSLConfigService(); |
| 340 } | 326 } |
| 341 | 327 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 if (!profile) | 492 if (!profile) |
| 507 profile = new OffTheRecordProfileImpl(this); | 493 profile = new OffTheRecordProfileImpl(this); |
| 508 profile->Init(); | 494 profile->Init(); |
| 509 return profile; | 495 return profile; |
| 510 } | 496 } |
| 511 | 497 |
| 512 base::Callback<ChromeURLDataManagerBackend*(void)> | 498 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 513 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 499 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 514 return io_data_.GetChromeURLDataManagerBackendGetter(); | 500 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 515 } | 501 } |
| OLD | NEW |