summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_url_request_context.cc
diff options
context:
space:
mode:
authorcreis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 22:45:09 +0000
committercreis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 22:45:09 +0000
commitd969667a1e558d2ba53e556233598cdc75d24678 (patch)
tree5b848ba7627e1240c0ef2855bf5780db83a027b7 /chrome/browser/net/chrome_url_request_context.cc
parent71e2f0a1ba62594c2cb555dd291810aaa7775779 (diff)
downloadchromium_src-d969667a1e558d2ba53e556233598cdc75d24678.zip
chromium_src-d969667a1e558d2ba53e556233598cdc75d24678.tar.gz
chromium_src-d969667a1e558d2ba53e556233598cdc75d24678.tar.bz2
Initial support for partitioning cookies for isolated apps.
This CL adds experimental support for letting installed apps request isolated storage in their manifest. An isolated app will have its own cookie store that is not shared with other apps or normal pages, even if they share an origin. The feature is currently behind a --enable-experimental-app-manifests flag. BUG=69335 TEST=ExtensionManifestTest.IsolatedApps TEST=IsolatedAppApiTest.CookieIsolation* Review URL: http://codereview.chromium.org/6201005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_url_request_context.cc')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 32066a1..e8b68be 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 std::string& app_id,
+ 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_;
+ const 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,
+ const 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,
+ const 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_incognito(other->is_incognito());
+}
+
void ChromeURLRequestContext::set_chrome_cookie_policy(
ChromeCookiePolicy* cookie_policy) {
chrome_cookie_policy_ = cookie_policy; // Take a strong reference.