| 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 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 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/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/render_messages.h" | 45 #include "chrome/common/render_messages.h" |
| 46 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
| 47 #include "content/public/browser/host_zoom_map.h" | 47 #include "content/public/browser/host_zoom_map.h" |
| 48 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/notification_types.h" | 49 #include "content/public/browser/notification_types.h" |
| 50 #include "content/public/browser/render_process_host.h" | 50 #include "content/public/browser/render_process_host.h" |
| 51 #include "content/public/browser/storage_partition.h" |
| 51 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 52 #include "net/base/transport_security_state.h" | 53 #include "net/base/transport_security_state.h" |
| 53 #include "net/http/http_server_properties.h" | 54 #include "net/http/http_server_properties.h" |
| 54 #include "webkit/database/database_tracker.h" | 55 #include "webkit/database/database_tracker.h" |
| 55 | 56 |
| 56 #if defined(OS_ANDROID) | 57 #if defined(OS_ANDROID) |
| 57 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 58 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 GetDownloadManagerDelegate(); | 251 GetDownloadManagerDelegate(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { | 254 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { |
| 254 return io_data_.GetMainRequestContextGetter(); | 255 return io_data_.GetMainRequestContextGetter(); |
| 255 } | 256 } |
| 256 | 257 |
| 257 net::URLRequestContextGetter* | 258 net::URLRequestContextGetter* |
| 258 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( | 259 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( |
| 259 int renderer_child_id) { | 260 int renderer_child_id) { |
| 260 ExtensionService* extension_service = | |
| 261 extensions::ExtensionSystem::Get(this)->extension_service(); | |
| 262 if (extension_service) { | |
| 263 const extensions::Extension* extension = | |
| 264 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | |
| 265 if (extension) | |
| 266 return GetRequestContextForStoragePartition(extension->id()); | |
| 267 } | |
| 268 | |
| 269 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 261 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 270 renderer_child_id); | 262 renderer_child_id); |
| 271 if (rph && rph->IsGuest()) { | 263 return rph->GetStoragePartition()->GetURLRequestContext(); |
| 272 // For guest processes (used by the browser tag), we need to isolate the | |
| 273 // storage. | |
| 274 // TODO(nasko): Until we have proper storage partitions, create a | |
| 275 // non-persistent context using the RPH's id. | |
| 276 std::string id("guest-"); | |
| 277 id.append(base::IntToString(renderer_child_id)); | |
| 278 return GetRequestContextForStoragePartition(id); | |
| 279 } | |
| 280 | |
| 281 return GetRequestContext(); | |
| 282 } | 264 } |
| 283 | 265 |
| 284 net::URLRequestContextGetter* | 266 net::URLRequestContextGetter* |
| 285 OffTheRecordProfileImpl::GetMediaRequestContext() { | 267 OffTheRecordProfileImpl::GetMediaRequestContext() { |
| 286 // In OTR mode, media request context is the same as the original one. | 268 // In OTR mode, media request context is the same as the original one. |
| 287 return GetRequestContext(); | 269 return GetRequestContext(); |
| 288 } | 270 } |
| 289 | 271 |
| 290 net::URLRequestContextGetter* | 272 net::URLRequestContextGetter* |
| 291 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( | 273 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( |
| 292 int renderer_child_id) { | 274 int renderer_child_id) { |
| 293 // In OTR mode, media request context is the same as the original one. | 275 // In OTR mode, media request context is the same as the original one. |
| 294 return GetRequestContextForRenderProcess(renderer_child_id); | 276 return GetRequestContextForRenderProcess(renderer_child_id); |
| 295 } | 277 } |
| 296 | 278 |
| 297 net::URLRequestContextGetter* | 279 net::URLRequestContextGetter* |
| 298 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( | 280 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( |
| 299 const std::string& partition_id) { | 281 const FilePath& partition_path, |
| 300 return GetRequestContextForStoragePartition(partition_id); | 282 bool in_memory) { |
| 283 return GetRequestContextForStoragePartition(partition_path, in_memory); |
| 301 } | 284 } |
| 302 | 285 |
| 303 net::URLRequestContextGetter* | 286 net::URLRequestContextGetter* |
| 304 OffTheRecordProfileImpl::GetRequestContextForExtensions() { | 287 OffTheRecordProfileImpl::GetRequestContextForExtensions() { |
| 305 return io_data_.GetExtensionsRequestContextGetter(); | 288 return io_data_.GetExtensionsRequestContextGetter(); |
| 306 } | 289 } |
| 307 | 290 |
| 308 net::URLRequestContextGetter* | 291 net::URLRequestContextGetter* |
| 309 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( | 292 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( |
| 310 const std::string& partition_id) { | 293 const FilePath& partition_path, |
| 311 return io_data_.GetIsolatedAppRequestContextGetter(partition_id); | 294 bool in_memory) { |
| 295 return io_data_.GetIsolatedAppRequestContextGetter(partition_path, in_memory); |
| 312 } | 296 } |
| 313 | 297 |
| 314 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { | 298 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { |
| 315 return io_data_.GetResourceContext(); | 299 return io_data_.GetResourceContext(); |
| 316 } | 300 } |
| 317 | 301 |
| 318 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { | 302 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { |
| 319 return profile_->GetSSLConfigService(); | 303 return profile_->GetSSLConfigService(); |
| 320 } | 304 } |
| 321 | 305 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 if (!profile) | 470 if (!profile) |
| 487 profile = new OffTheRecordProfileImpl(this); | 471 profile = new OffTheRecordProfileImpl(this); |
| 488 profile->Init(); | 472 profile->Init(); |
| 489 return profile; | 473 return profile; |
| 490 } | 474 } |
| 491 | 475 |
| 492 base::Callback<ChromeURLDataManagerBackend*(void)> | 476 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 493 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 477 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 494 return io_data_.GetChromeURLDataManagerBackendGetter(); | 478 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 495 } | 479 } |
| OLD | NEW |