diff options
author | droger <droger@chromium.org> | 2016-03-08 06:09:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 14:10:17 +0000 |
commit | 9f1ec3dc5a80c904142140bc7a7164750dba5096 (patch) | |
tree | 1fc22ba3413306eb731f6188e3e5b619d81dce79 /ios | |
parent | c3385cc179280dd4b09733b2954be7e9ae3b5112 (diff) | |
download | chromium_src-9f1ec3dc5a80c904142140bc7a7164750dba5096.zip chromium_src-9f1ec3dc5a80c904142140bc7a7164750dba5096.tar.gz chromium_src-9f1ec3dc5a80c904142140bc7a7164750dba5096.tar.bz2 |
RequestContext no longer owns the cookie store
As a result of https://codereview.chromium.org/1701063002/,
the request context no longer owns the cookie store.
In order to roll this CL in iOS, we need to expose a clean way
to change the cookie store without breaking the ownership.
Allow overriding the Cookie Store for a URLRequestContextGetter
obtained from ChromeBrowserState::CreateIsolatedRequestContext.
BUG=None
Review URL: https://codereview.chromium.org/1771333002
Cr-Commit-Position: refs/heads/master@{#379822}
Diffstat (limited to 'ios')
6 files changed, 27 insertions, 15 deletions
diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h b/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h index 77f75bc..8da2ba4 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h +++ b/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h @@ -116,9 +116,9 @@ class ChromeBrowserStateImplIOData : public ChromeBrowserStateIOData { scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, ProfileParams* profile_params, ProtocolHandlerMap* protocol_handlers) const override; - net::URLRequestContext* InitializeAppRequestContext( + AppRequestContext* InitializeAppRequestContext( net::URLRequestContext* main_context) const override; - net::URLRequestContext* AcquireIsolatedAppRequestContext( + AppRequestContext* AcquireIsolatedAppRequestContext( net::URLRequestContext* main_context) const override; // Deletes all network related data since |time|. It deletes transport diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.mm b/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.mm index 91aedf8..a530e22 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.mm +++ b/ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.mm @@ -410,7 +410,7 @@ void ChromeBrowserStateImplIOData::InitializeInternal( lazy_params_.reset(); } -net::URLRequestContext* +ChromeBrowserStateIOData::AppRequestContext* ChromeBrowserStateImplIOData::InitializeAppRequestContext( net::URLRequestContext* main_context) const { // Copy most state from the main context. @@ -447,11 +447,11 @@ ChromeBrowserStateImplIOData::InitializeAppRequestContext( return context; } -net::URLRequestContext* +ChromeBrowserStateIOData::AppRequestContext* ChromeBrowserStateImplIOData::AcquireIsolatedAppRequestContext( net::URLRequestContext* main_context) const { // We create per-app contexts on demand, unlike the others above. - net::URLRequestContext* app_request_context = + AppRequestContext* app_request_context = InitializeAppRequestContext(main_context); DCHECK(app_request_context); return app_request_context; diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc index f29cd00..d5819c1 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc +++ b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.cc @@ -257,7 +257,7 @@ net::URLRequestContext* ChromeBrowserStateIOData::GetIsolatedAppRequestContext( net::URLRequestContext* main_context, const base::FilePath& partition_path) const { DCHECK(initialized_); - net::URLRequestContext* context = nullptr; + AppRequestContext* context = nullptr; if (ContainsKey(app_request_context_map_, partition_path)) { context = app_request_context_map_[partition_path]; } else { @@ -268,6 +268,14 @@ net::URLRequestContext* ChromeBrowserStateIOData::GetIsolatedAppRequestContext( return context; } +void ChromeBrowserStateIOData::SetCookieStoreForPartitionPath( + scoped_ptr<net::CookieStore> cookie_store, + const base::FilePath& partition_path) { + DCHECK(ContainsKey(app_request_context_map_, partition_path)); + app_request_context_map_[partition_path]->SetCookieStore( + std::move(cookie_store)); +} + content_settings::CookieSettings* ChromeBrowserStateIOData::GetCookieSettings() const { DCHECK(initialized_); diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.h b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.h index 038f288..7e806d0 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_io_data.h +++ b/ios/chrome/browser/browser_state/chrome_browser_state_io_data.h @@ -91,6 +91,11 @@ class ChromeBrowserStateIOData { net::URLRequestContext* main_context, const base::FilePath& partition_path) const; + // Sets the cookie store associated with a partition path. + // The path must exist. If there is already a cookie store, it is deleted. + void SetCookieStoreForPartitionPath(scoped_ptr<net::CookieStore> cookie_store, + const base::FilePath& partition_path); + // These are useful when the Chrome layer is called from the content layer // with a content::ResourceContext, and they want access to Chrome data for // that browser state. @@ -136,9 +141,9 @@ class ChromeBrowserStateIOData { scoped_ptr<net::HttpTransactionFactory> http_factory); void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory); - private: ~AppRequestContext() override; + private: scoped_ptr<net::CookieStore> cookie_store_; scoped_ptr<net::HttpTransactionFactory> http_factory_; scoped_ptr<net::URLRequestJobFactory> job_factory_; @@ -220,8 +225,7 @@ class ChromeBrowserStateIOData { scoped_ptr<net::HttpCache::BackendFactory> backend) const; private: - typedef std::map<base::FilePath, net::URLRequestContext*> - URLRequestContextMap; + typedef std::map<base::FilePath, AppRequestContext*> URLRequestContextMap; // -------------------------------------------- // Virtual interface for subtypes to implement: @@ -236,12 +240,12 @@ class ChromeBrowserStateIOData { // Does an on-demand initialization of a RequestContext for the given // isolated app. - virtual net::URLRequestContext* InitializeAppRequestContext( + virtual AppRequestContext* InitializeAppRequestContext( net::URLRequestContext* main_context) const = 0; // These functions are used to transfer ownership of the lazily initialized // context from ChromeBrowserStateIOData to the URLRequestContextGetter. - virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( + virtual AppRequestContext* AcquireIsolatedAppRequestContext( net::URLRequestContext* main_context) const = 0; // The order *DOES* matter for the majority of these member variables, so diff --git a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.h b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.h index 65995f0..4848d55 100644 --- a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.h +++ b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.h @@ -95,9 +95,9 @@ class OffTheRecordChromeBrowserStateIOData : public ChromeBrowserStateIOData { scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, ProfileParams* profile_params, ProtocolHandlerMap* protocol_handlers) const override; - net::URLRequestContext* InitializeAppRequestContext( + AppRequestContext* InitializeAppRequestContext( net::URLRequestContext* main_context) const override; - net::URLRequestContext* AcquireIsolatedAppRequestContext( + AppRequestContext* AcquireIsolatedAppRequestContext( net::URLRequestContext* main_context) const override; mutable scoped_ptr<IOSChromeNetworkDelegate> network_delegate_; diff --git a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.mm b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.mm index 26b3d2b..8156acd 100644 --- a/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.mm +++ b/ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_io_data.mm @@ -226,14 +226,14 @@ void OffTheRecordChromeBrowserStateIOData::InitializeInternal( main_context->set_sdch_manager(sdch_manager_.get()); } -net::URLRequestContext* +ChromeBrowserStateIOData::AppRequestContext* OffTheRecordChromeBrowserStateIOData::InitializeAppRequestContext( net::URLRequestContext* main_context) const { NOTREACHED(); return nullptr; } -net::URLRequestContext* +ChromeBrowserStateIOData::AppRequestContext* OffTheRecordChromeBrowserStateIOData::AcquireIsolatedAppRequestContext( net::URLRequestContext* main_context) const { NOTREACHED(); |