Chromium Code Reviews| Index: chrome/browser/net/chrome_url_request_context.cc |
| diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc |
| index e4c9794e80c4009972cf6d516cb869b5b0fff472..1009de07d70f6de13ec29fc7905eb76b87d5bdc7 100644 |
| --- a/chrome/browser/net/chrome_url_request_context.cc |
| +++ b/chrome/browser/net/chrome_url_request_context.cc |
| @@ -77,6 +77,29 @@ class FactoryForExtensions : public ChromeURLRequestContextFactory { |
| const scoped_refptr<const ProfileIOData> profile_io_data_; |
| }; |
| +// Factory that creates the ChromeURLRequestContext for a given isolated app. |
| +class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { |
| + public: |
| + FactoryForIsolatedApp(const ProfileIOData* profile_io_data, |
| + std::string app_id, |
|
Matt Perry
2011/03/15 00:40:56
const std::string&
Charlie Reis
2011/03/15 06:23:42
Done.
|
| + ChromeURLRequestContextGetter* main_context) |
| + : profile_io_data_(profile_io_data), |
| + app_id_(app_id), |
| + main_request_context_getter_(main_context) {} |
| + |
| + virtual scoped_refptr<ChromeURLRequestContext> Create() { |
| + // We will copy most of the state from the main request context. |
| + return profile_io_data_->GetIsolatedAppRequestContext( |
| + main_request_context_getter_->GetIOContext(), app_id_); |
| + } |
| + |
| + private: |
| + const scoped_refptr<const ProfileIOData> profile_io_data_; |
| + std::string app_id_; |
| + scoped_refptr<ChromeURLRequestContextGetter> |
| + main_request_context_getter_; |
| +}; |
| + |
| // Factory that creates the ChromeURLRequestContext for media. |
| class FactoryForMedia : public ChromeURLRequestContextFactory { |
| public: |
| @@ -215,6 +238,20 @@ ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
| // static |
| ChromeURLRequestContextGetter* |
| +ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| + Profile* profile, |
| + const ProfileIOData* profile_io_data, |
| + std::string app_id) { |
| + DCHECK(!profile->IsOffTheRecord()); |
| + ChromeURLRequestContextGetter* main_context = |
| + static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
| + return new ChromeURLRequestContextGetter( |
| + profile, |
| + new FactoryForIsolatedApp(profile_io_data, app_id, main_context)); |
| +} |
| + |
| +// static |
| +ChromeURLRequestContextGetter* |
| ChromeURLRequestContextGetter::CreateOffTheRecord( |
| Profile* profile, const ProfileIOData* profile_io_data) { |
| DCHECK(profile->IsOffTheRecord()); |
| @@ -231,6 +268,20 @@ ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( |
| profile, new FactoryForExtensions(profile_io_data)); |
| } |
| +// static |
| +ChromeURLRequestContextGetter* |
| +ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( |
| + Profile* profile, |
| + const ProfileIOData* profile_io_data, |
| + std::string app_id) { |
| + DCHECK(profile->IsOffTheRecord()); |
| + ChromeURLRequestContextGetter* main_context = |
| + static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
| + return new ChromeURLRequestContextGetter( |
| + profile, |
| + new FactoryForIsolatedApp(profile_io_data, app_id, main_context)); |
| +} |
| + |
| void ChromeURLRequestContextGetter::CleanupOnUIThread() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| // Unregister for pref notifications. |
| @@ -324,6 +375,24 @@ ChromeURLRequestContext::ChromeURLRequestContext() |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| } |
| +void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { |
| + URLRequestContext::CopyFrom(other); |
| + |
| + // Copy ChromeURLRequestContext parameters. |
| + set_user_script_dir_path(other->user_script_dir_path()); |
| + set_appcache_service(other->appcache_service()); |
| + set_database_tracker(other->database_tracker()); |
| + set_chrome_cookie_policy(other->chrome_cookie_policy_); |
| + set_host_content_settings_map(other->host_content_settings_map()); |
| + set_host_zoom_map(other->host_zoom_map_); |
| + set_blob_storage_context(other->blob_storage_context()); |
| + set_file_system_context(other->file_system_context()); |
| + set_extension_info_map(other->extension_info_map_); |
| + set_prerender_manager(other->prerender_manager()); |
| + // ChromeURLDataManagerBackend is unique per context. |
| + set_is_off_the_record(other->is_off_the_record()); |
| +} |
| + |
| void ChromeURLRequestContext::set_chrome_cookie_policy( |
| ChromeCookiePolicy* cookie_policy) { |
| chrome_cookie_policy_ = cookie_policy; // Take a strong reference. |