Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1431)

Unified Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix automation_util and thread issue. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2b2a40ea8c1b701d8eb324e810cda5654bd352fe..59e4586c04f1fda0c6e24e07f6588241019a38c8 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,
+ const Extension* installed_app,
+ ChromeURLRequestContextGetter* main_context)
+ : profile_io_data_(profile_io_data),
+ installed_app_(installed_app),
+ 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(), installed_app_);
+ }
+
+ private:
+ const scoped_refptr<const ProfileIOData> profile_io_data_;
+ const scoped_refptr<const Extension> installed_app_;
+ 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,
+ const Extension* installed_app) {
+ DCHECK(!profile->IsOffTheRecord());
+ ChromeURLRequestContextGetter* main_context =
+ static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
+ return new ChromeURLRequestContextGetter(
+ profile,
+ new FactoryForIsolatedApp(profile_io_data, installed_app, 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,
+ const Extension* installed_app) {
+ DCHECK(profile->IsOffTheRecord());
+ ChromeURLRequestContextGetter* main_context =
+ static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
+ return new ChromeURLRequestContextGetter(
+ profile,
+ new FactoryForIsolatedApp(profile_io_data, installed_app, main_context));
+}
+
void ChromeURLRequestContextGetter::CleanupOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Unregister for pref notifications.
@@ -324,6 +375,43 @@ ChromeURLRequestContext::ChromeURLRequestContext()
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
+void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* 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_protocol_handler_registry(other->protocol_handler_registry_);
+ set_is_off_the_record(other->is_off_the_record());
+
+ // Copy URLRequestContext parameters.
+ set_net_log(other->net_log());
+ set_host_resolver(other->host_resolver());
+ set_cert_verifier(other->cert_verifier());
+ set_dnsrr_resolver(other->dnsrr_resolver());
+ set_dns_cert_checker(other->dns_cert_checker());
+ set_http_auth_handler_factory(other->http_auth_handler_factory());
+ set_proxy_service(other->proxy_service());
+ set_ssl_config_service(other->ssl_config_service());
+ set_network_delegate(other->network_delegate());
+ set_cookie_store(other->cookie_store());
+ // Cookie policy is set above, via set_chrome_cookie_policy.
+ set_transport_security_state(other->transport_security_state());
+ // FTPAuthCache is unique per context.
+ set_accept_language(other->accept_language());
+ set_accept_charset(other->accept_charset());
+ set_referrer_charset(other->referrer_charset());
+ set_http_transaction_factory(other->http_transaction_factory());
+ set_ftp_transaction_factory(other->ftp_transaction_factory());
+}
+
void ChromeURLRequestContext::set_chrome_cookie_policy(
ChromeCookiePolicy* cookie_policy) {
chrome_cookie_policy_ = cookie_policy; // Take a strong reference.

Powered by Google App Engine
This is Rietveld 408576698