| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 GetDownloadManagerDelegate(); | 255 GetDownloadManagerDelegate(); |
| 255 } | 256 } |
| 256 | 257 |
| 257 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { | 258 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { |
| 258 return io_data_.GetMainRequestContextGetter(); | 259 return io_data_.GetMainRequestContextGetter(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 net::URLRequestContextGetter* | 262 net::URLRequestContextGetter* |
| 262 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( | 263 OffTheRecordProfileImpl::GetRequestContextForRenderProcess( |
| 263 int renderer_child_id) { | 264 int renderer_child_id) { |
| 264 ExtensionService* extension_service = | |
| 265 extensions::ExtensionSystem::Get(this)->extension_service(); | |
| 266 if (extension_service) { | |
| 267 const extensions::Extension* extension = | |
| 268 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | |
| 269 if (extension) | |
| 270 return GetRequestContextForStoragePartition(extension->id()); | |
| 271 } | |
| 272 | |
| 273 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 265 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 274 renderer_child_id); | 266 renderer_child_id); |
| 275 if (rph && rph->IsGuest()) { | 267 return rph->GetStoragePartition()->GetURLRequestContext(); |
| 276 // For guest processes (used by the browser tag), we need to isolate the | |
| 277 // storage. | |
| 278 // TODO(nasko): Until we have proper storage partitions, create a | |
| 279 // non-persistent context using the RPH's id. | |
| 280 std::string id("guest-"); | |
| 281 id.append(base::IntToString(renderer_child_id)); | |
| 282 return GetRequestContextForStoragePartition(id); | |
| 283 } | |
| 284 | |
| 285 return GetRequestContext(); | |
| 286 } | 268 } |
| 287 | 269 |
| 288 net::URLRequestContextGetter* | 270 net::URLRequestContextGetter* |
| 289 OffTheRecordProfileImpl::GetMediaRequestContext() { | 271 OffTheRecordProfileImpl::GetMediaRequestContext() { |
| 290 // In OTR mode, media request context is the same as the original one. | 272 // In OTR mode, media request context is the same as the original one. |
| 291 return GetRequestContext(); | 273 return GetRequestContext(); |
| 292 } | 274 } |
| 293 | 275 |
| 294 net::URLRequestContextGetter* | 276 net::URLRequestContextGetter* |
| 295 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( | 277 OffTheRecordProfileImpl::GetMediaRequestContextForRenderProcess( |
| 296 int renderer_child_id) { | 278 int renderer_child_id) { |
| 297 // In OTR mode, media request context is the same as the original one. | 279 // In OTR mode, media request context is the same as the original one. |
| 298 return GetRequestContextForRenderProcess(renderer_child_id); | 280 return GetRequestContextForRenderProcess(renderer_child_id); |
| 299 } | 281 } |
| 300 | 282 |
| 301 net::URLRequestContextGetter* | 283 net::URLRequestContextGetter* |
| 302 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( | 284 OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( |
| 303 const std::string& partition_id) { | 285 const FilePath& partition_path, |
| 304 return GetRequestContextForStoragePartition(partition_id); | 286 bool in_memory) { |
| 287 return GetRequestContextForStoragePartition(partition_path, in_memory); |
| 305 } | 288 } |
| 306 | 289 |
| 307 net::URLRequestContextGetter* | 290 net::URLRequestContextGetter* |
| 308 OffTheRecordProfileImpl::GetRequestContextForExtensions() { | 291 OffTheRecordProfileImpl::GetRequestContextForExtensions() { |
| 309 return io_data_.GetExtensionsRequestContextGetter(); | 292 return io_data_.GetExtensionsRequestContextGetter(); |
| 310 } | 293 } |
| 311 | 294 |
| 312 net::URLRequestContextGetter* | 295 net::URLRequestContextGetter* |
| 313 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( | 296 OffTheRecordProfileImpl::GetRequestContextForStoragePartition( |
| 314 const std::string& partition_id) { | 297 const FilePath& partition_path, |
| 315 return io_data_.GetIsolatedAppRequestContextGetter(partition_id); | 298 bool in_memory) { |
| 299 return io_data_.GetIsolatedAppRequestContextGetter(partition_path, in_memory); |
| 316 } | 300 } |
| 317 | 301 |
| 318 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { | 302 content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { |
| 319 return io_data_.GetResourceContext(); | 303 return io_data_.GetResourceContext(); |
| 320 } | 304 } |
| 321 | 305 |
| 322 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { | 306 net::SSLConfigService* OffTheRecordProfileImpl::GetSSLConfigService() { |
| 323 return profile_->GetSSLConfigService(); | 307 return profile_->GetSSLConfigService(); |
| 324 } | 308 } |
| 325 | 309 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (!profile) | 474 if (!profile) |
| 491 profile = new OffTheRecordProfileImpl(this); | 475 profile = new OffTheRecordProfileImpl(this); |
| 492 profile->Init(); | 476 profile->Init(); |
| 493 return profile; | 477 return profile; |
| 494 } | 478 } |
| 495 | 479 |
| 496 base::Callback<ChromeURLDataManagerBackend*(void)> | 480 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 497 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 481 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 498 return io_data_.GetChromeURLDataManagerBackendGetter(); | 482 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 499 } | 483 } |
| OLD | NEW |