#ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
#define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
+#include <map>
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/synchronization/lock.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/io_thread.h"
-#include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/storage_partition_descriptor.h"
-#include "chrome/common/content_settings_types.h"
+#include "components/content_settings/core/common/content_settings_types.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
#include "net/cookies/cookie_monster.h"
+#include "net/http/http_cache.h"
#include "net/http/http_network_session.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_job_factory.h"
class ChromeHttpUserAgentSettings;
class ChromeNetworkDelegate;
+class ChromeURLRequestContextGetter;
class CookieSettings;
-class DesktopNotificationService;
-class ExtensionInfoMap;
+class DevToolsNetworkController;
class HostContentSettingsMap;
-class ManagedModeURLFilter;
-class Profile;
+class MediaDeviceIDSalt;
class ProtocolHandlerRegistry;
class SigninNamesOnIOThread;
-class TransportSecurityPersister;
+class SupervisedUserURLFilter;
-namespace chrome_browser_net {
-class LoadTimeStats;
-class ResourcePrefetchPredictorObserver;
+namespace extensions {
+class InfoMap;
}
namespace net {
-class CertVerifier;
+class ChannelIDService;
class CookieStore;
class FraudulentCertificateReporter;
class FtpTransactionFactory;
class HttpServerProperties;
class HttpTransactionFactory;
-class ServerBoundCertService;
class ProxyConfigService;
class ProxyService;
class SSLConfigService;
+class TransportSecurityPersister;
class TransportSecurityState;
class URLRequestJobFactoryImpl;
} // namespace net
namespace policy {
class PolicyCertVerifier;
+class PolicyHeaderIOHelper;
class URLBlacklistManager;
} // namespace policy
+namespace prerender {
+class PrerenderTracker;
+}
+
// Conceptually speaking, the ProfileIOData represents data that lives on the IO
// thread that is owned by a Profile, such as, but not limited to, network
// objects like CookieMonster, HttpTransactionFactory, etc. Profile owns
// possibly in unit tests where there is no IO thread).
class ProfileIOData {
public:
+ typedef std::vector<scoped_refptr<ChromeURLRequestContextGetter>>
+ ChromeURLRequestContextGetterVector;
+
virtual ~ProfileIOData();
static ProfileIOData* FromResourceContext(content::ResourceContext* rc);
// Initializes the ProfileIOData object and primes the RequestContext
// generation. Must be called prior to any of the Get*() methods other than
// GetResouceContext or GetMetricsEnabledStateOnIOThread.
- void Init(content::ProtocolHandlerMap* protocol_handlers) const;
-
- ChromeURLRequestContext* GetMainRequestContext() const;
- ChromeURLRequestContext* GetMediaRequestContext() const;
- ChromeURLRequestContext* GetExtensionsRequestContext() const;
- ChromeURLRequestContext* GetIsolatedAppRequestContext(
- ChromeURLRequestContext* main_context,
+ void Init(
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors) const;
+
+ net::URLRequestContext* GetMainRequestContext() const;
+ net::URLRequestContext* GetMediaRequestContext() const;
+ net::URLRequestContext* GetExtensionsRequestContext() const;
+ net::URLRequestContext* GetIsolatedAppRequestContext(
+ net::URLRequestContext* main_context,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers) const;
- ChromeURLRequestContext* GetIsolatedMediaRequestContext(
- ChromeURLRequestContext* app_context,
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors) const;
+ net::URLRequestContext* GetIsolatedMediaRequestContext(
+ net::URLRequestContext* app_context,
const StoragePartitionDescriptor& partition_descriptor) const;
// 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 profile.
- ExtensionInfoMap* GetExtensionInfoMap() const;
+ extensions::InfoMap* GetExtensionInfoMap() const;
CookieSettings* GetCookieSettings() const;
HostContentSettingsMap* GetHostContentSettingsMap() const;
-#if defined(ENABLE_NOTIFICATIONS)
- DesktopNotificationService* GetNotificationService() const;
-#endif
-
IntegerPrefMember* session_startup_pref() const {
return &session_startup_pref_;
}
return signin_names_.get();
}
+ StringPrefMember* google_services_account_id() const {
+ return &google_services_user_account_id_;
+ }
+
StringPrefMember* google_services_username() const {
return &google_services_username_;
}
return &one_click_signin_rejected_email_list_;
}
- ChromeURLRequestContext* extensions_request_context() const {
+ net::URLRequestContext* extensions_request_context() const {
return extensions_request_context_.get();
}
return &safe_browsing_enabled_;
}
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ // TODO(feng): move the function to protected area.
+ // IsDataReductionProxyEnabled() should be used as public API.
+ BooleanPrefMember* data_reduction_proxy_enabled() const {
+ return &data_reduction_proxy_enabled_;
+ }
+#endif
+
BooleanPrefMember* printing_enabled() const {
return &printing_enabled_;
}
return &signin_allowed_;
}
+ // TODO(bnc): remove per https://crbug.com/334602.
+ BooleanPrefMember* network_prediction_enabled() const {
+ return &network_prediction_enabled_;
+ }
+
+ IntegerPrefMember* network_prediction_options() const {
+ return &network_prediction_options_;
+ }
+
+ content::ResourceContext::SaltCallback GetMediaDeviceIDSalt() const;
+
+ DevToolsNetworkController* network_controller() const {
+ return network_controller_.get();
+ }
+
net::TransportSecurityState* transport_security_state() const {
return transport_security_state_.get();
}
- bool is_incognito() const {
- return is_incognito_;
+#if defined(OS_CHROMEOS)
+ std::string username_hash() const {
+ return username_hash_;
+ }
+
+ bool use_system_key_slot() const { return use_system_key_slot_; }
+#endif
+
+ Profile::ProfileType profile_type() const {
+ return profile_type_;
+ }
+
+ bool IsOffTheRecord() const;
+
+ IntegerPrefMember* incognito_availibility() const {
+ return &incognito_availibility_pref_;
}
- chrome_browser_net::ResourcePrefetchPredictorObserver*
- resource_prefetch_predictor_observer() const {
- return resource_prefetch_predictor_observer_.get();
+#if defined(ENABLE_CONFIGURATION_POLICY)
+ policy::PolicyHeaderIOHelper* policy_header_helper() const {
+ return policy_header_helper_.get();
}
+#endif
#if defined(ENABLE_MANAGED_USERS)
- const ManagedModeURLFilter* managed_mode_url_filter() const {
- return managed_mode_url_filter_.get();
+ const SupervisedUserURLFilter* supervised_user_url_filter() const {
+ return supervised_user_url_filter_.get();
}
#endif
// should only be called from there.
bool GetMetricsEnabledStateOnIOThread() const;
+#if defined(OS_ANDROID)
+ // Returns whether or not data reduction proxy is enabled in the browser
+ // instance on which this profile resides.
+ bool IsDataReductionProxyEnabled() const;
+#endif
+
+ void set_client_cert_store_factory_for_testing(
+ const base::Callback<scoped_ptr<net::ClientCertStore>()>& factory) {
+ client_cert_store_factory_ = factory;
+ }
+
protected:
// A URLRequestContext for media that owns its HTTP factory, to ensure
// it is deleted.
- class MediaRequestContext : public ChromeURLRequestContext {
+ class MediaRequestContext : public net::URLRequestContext {
public:
- explicit MediaRequestContext(
- chrome_browser_net::LoadTimeStats* load_time_stats);
+ MediaRequestContext();
void SetHttpTransactionFactory(
scoped_ptr<net::HttpTransactionFactory> http_factory);
// A URLRequestContext for apps that owns its cookie store and HTTP factory,
// to ensure they are deleted.
- class AppRequestContext : public ChromeURLRequestContext {
+ class AppRequestContext : public net::URLRequestContext {
public:
- explicit AppRequestContext(
- chrome_browser_net::LoadTimeStats* load_time_stats);
+ AppRequestContext();
void SetCookieStore(net::CookieStore* cookie_store);
void SetHttpTransactionFactory(
scoped_refptr<HostContentSettingsMap> host_content_settings_map;
scoped_refptr<net::SSLConfigService> ssl_config_service;
scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate;
- scoped_refptr<ExtensionInfoMap> extension_info_map;
- scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
- resource_prefetch_predictor_observer_;
-
-#if defined(ENABLE_NOTIFICATIONS)
- DesktopNotificationService* notification_service;
+#if defined(ENABLE_EXTENSIONS)
+ scoped_refptr<extensions::InfoMap> extension_info_map;
#endif
// This pointer exists only as a means of conveying a url job factory
scoped_ptr<net::ProxyConfigService> proxy_config_service;
#if defined(ENABLE_MANAGED_USERS)
- scoped_refptr<const ManagedModeURLFilter> managed_mode_url_filter;
+ scoped_refptr<const SupervisedUserURLFilter> supervised_user_url_filter;
#endif
#if defined(OS_CHROMEOS)
- scoped_ptr<policy::PolicyCertVerifier> cert_verifier;
+ std::string username_hash;
+ bool use_system_key_slot;
#endif
// The profile this struct was populated from. It's passed as a void* to
// ensure it's not accidently used on the IO thread. Before using it on the
// UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
void* profile;
+
+ prerender::PrerenderTracker* prerender_tracker;
};
- explicit ProfileIOData(bool is_incognito);
+ explicit ProfileIOData(Profile::ProfileType profile_type);
static std::string GetSSLSessionCacheShard();
void InitializeOnUIThread(Profile* profile);
- void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const;
+ void ApplyProfileParamsToContext(net::URLRequestContext* context) const;
scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
scoped_ptr<net::URLRequestJobFactoryImpl> job_factory,
+ content::URLRequestInterceptorScopedVector request_interceptors,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
protocol_handler_interceptor,
net::NetworkDelegate* network_delegate,
net::FtpTransactionFactory* ftp_transaction_factory) const;
// Called when the profile is destroyed.
- void ShutdownOnUIThread();
+ void ShutdownOnUIThread(
+ scoped_ptr<ChromeURLRequestContextGetterVector> context_getters);
- // A ServerBoundCertService object is created by a derived class of
+ // A ChannelIDService object is created by a derived class of
// ProfileIOData, and the derived class calls this method to set the
- // server_bound_cert_service_ member and transfers ownership to the base
+ // channel_id_service_ member and transfers ownership to the base
// class.
- void set_server_bound_cert_service(
- net::ServerBoundCertService* server_bound_cert_service) const;
+ void set_channel_id_service(
+ net::ChannelIDService* channel_id_service) const;
ChromeNetworkDelegate* network_delegate() const {
return network_delegate_.get();
void set_http_server_properties(
scoped_ptr<net::HttpServerProperties> http_server_properties) const;
- ChromeURLRequestContext* main_request_context() const {
+ net::URLRequestContext* main_request_context() const {
return main_request_context_.get();
}
- chrome_browser_net::LoadTimeStats* load_time_stats() const {
- return load_time_stats_;
- }
-
bool initialized() const {
return initialized_;
}
// URLRequests may be accessing.
void DestroyResourceContext();
- // Fills in fields of params using values from main_request_context_ and the
- // IOThread associated with profile_params.
- void PopulateNetworkSessionParams(
+ // Creates network session and main network transaction factory.
+ scoped_ptr<net::HttpCache> CreateMainHttpFactory(
const ProfileParams* profile_params,
- net::HttpNetworkSession::Params* params) const;
+ net::HttpCache::BackendFactory* main_backend) const;
+
+ // Creates network transaction factory.
+ scoped_ptr<net::HttpCache> CreateHttpFactory(
+ net::HttpNetworkSession* shared_session,
+ net::HttpCache::BackendFactory* backend) const;
void SetCookieSettingsForTesting(CookieSettings* cookie_settings);
virtual net::HostResolver* GetHostResolver() OVERRIDE;
virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
virtual scoped_ptr<net::ClientCertStore> CreateClientCertStore() OVERRIDE;
+ virtual void CreateKeygenHandler(
+ uint32 key_size_in_bits,
+ const std::string& challenge_string,
+ const GURL& url,
+ const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback)
+ OVERRIDE;
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE;
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE;
+ virtual SaltCallback GetMediaDeviceIDSalt() OVERRIDE;
private:
friend class ProfileIOData;
};
typedef std::map<StoragePartitionDescriptor,
- ChromeURLRequestContext*,
+ net::URLRequestContext*,
StoragePartitionDescriptorLess>
URLRequestContextMap;
// should use the static helper functions above to implement this.
virtual void InitializeInternal(
ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers) const = 0;
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector
+ request_interceptors) const = 0;
// Initializes the RequestContext for extensions.
virtual void InitializeExtensionsRequestContext(
ProfileParams* profile_params) const = 0;
// Does an on-demand initialization of a RequestContext for the given
// isolated app.
- virtual ChromeURLRequestContext* InitializeAppRequestContext(
- ChromeURLRequestContext* main_context,
+ virtual net::URLRequestContext* InitializeAppRequestContext(
+ net::URLRequestContext* main_context,
const StoragePartitionDescriptor& details,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers) const = 0;
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector
+ request_interceptors) const = 0;
// Does an on-demand initialization of a media RequestContext for the given
// isolated app.
- virtual ChromeURLRequestContext* InitializeMediaRequestContext(
- ChromeURLRequestContext* original_context,
+ virtual net::URLRequestContext* InitializeMediaRequestContext(
+ net::URLRequestContext* original_context,
const StoragePartitionDescriptor& details) const = 0;
// These functions are used to transfer ownership of the lazily initialized
// context from ProfileIOData to the URLRequestContextGetter.
- virtual ChromeURLRequestContext*
+ virtual net::URLRequestContext*
AcquireMediaRequestContext() const = 0;
- virtual ChromeURLRequestContext*
- AcquireIsolatedAppRequestContext(
- ChromeURLRequestContext* main_context,
- const StoragePartitionDescriptor& partition_descriptor,
- scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers) const = 0;
- virtual ChromeURLRequestContext*
+ virtual net::URLRequestContext* AcquireIsolatedAppRequestContext(
+ net::URLRequestContext* main_context,
+ const StoragePartitionDescriptor& partition_descriptor,
+ scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
+ protocol_handler_interceptor,
+ content::ProtocolHandlerMap* protocol_handlers,
+ content::URLRequestInterceptorScopedVector
+ request_interceptors) const = 0;
+ virtual net::URLRequestContext*
AcquireIsolatedMediaRequestContext(
- ChromeURLRequestContext* app_context,
+ net::URLRequestContext* app_context,
const StoragePartitionDescriptor& partition_descriptor) const = 0;
- // Returns the LoadTimeStats object to be used for this profile.
- virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats(
- IOThread::Globals* io_thread_globals) const = 0;
-
// The order *DOES* matter for the majority of these member variables, so
// don't move them around unless you know what you're doing!
// General rules:
// Provides access to the email addresses of all signed in profiles.
mutable scoped_ptr<SigninNamesOnIOThread> signin_names_;
+ // Used for testing.
+ mutable base::Callback<scoped_ptr<net::ClientCertStore>()>
+ client_cert_store_factory_;
+
+ mutable StringPrefMember google_services_user_account_id_;
mutable StringPrefMember google_services_username_;
mutable StringPrefMember google_services_username_pattern_;
mutable BooleanPrefMember reverse_autologin_enabled_;
mutable StringListPrefMember one_click_signin_rejected_email_list_;
+ mutable scoped_refptr<MediaDeviceIDSalt> media_device_id_salt_;
+
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember enable_referrers_;
mutable BooleanPrefMember enable_do_not_track_;
mutable BooleanPrefMember force_safesearch_;
mutable BooleanPrefMember safe_browsing_enabled_;
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ mutable BooleanPrefMember data_reduction_proxy_enabled_;
+#endif
mutable BooleanPrefMember printing_enabled_;
mutable BooleanPrefMember sync_disabled_;
mutable BooleanPrefMember signin_allowed_;
+ mutable BooleanPrefMember network_prediction_enabled_;
+ mutable IntegerPrefMember network_prediction_options_;
// TODO(marja): Remove session_startup_pref_ if no longer needed.
mutable IntegerPrefMember session_startup_pref_;
+ mutable BooleanPrefMember quick_check_enabled_;
+ mutable IntegerPrefMember incognito_availibility_pref_;
// The state of metrics reporting in the browser that this profile runs on.
// Unfortunately, since ChromeOS has a separate representation of this state,
BooleanPrefMember enable_metrics_;
#endif
+#if defined(ENABLE_CONFIGURATION_POLICY)
// Pointed to by NetworkDelegate.
mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_;
+ mutable scoped_ptr<policy::PolicyHeaderIOHelper> policy_header_helper_;
+#endif
// Pointed to by URLRequestContext.
- mutable scoped_refptr<ExtensionInfoMap> extension_info_map_;
- mutable scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_;
+#if defined(ENABLE_EXTENSIONS)
+ mutable scoped_refptr<extensions::InfoMap> extension_info_map_;
+#endif
+ mutable scoped_ptr<net::ChannelIDService> channel_id_service_;
mutable scoped_ptr<ChromeNetworkDelegate> network_delegate_;
mutable scoped_ptr<net::FraudulentCertificateReporter>
fraudulent_certificate_reporter_;
mutable scoped_ptr<net::HttpServerProperties>
http_server_properties_;
#if defined(OS_CHROMEOS)
- mutable scoped_ptr<net::CertVerifier> cert_verifier_;
-#endif
-
-#if defined(ENABLE_NOTIFICATIONS)
- mutable DesktopNotificationService* notification_service_;
+ mutable scoped_ptr<policy::PolicyCertVerifier> cert_verifier_;
+ mutable std::string username_hash_;
+ mutable bool use_system_key_slot_;
#endif
- mutable scoped_ptr<TransportSecurityPersister>
+ mutable scoped_ptr<net::TransportSecurityPersister>
transport_security_persister_;
// These are only valid in between LazyInitialize() and their accessor being
// called.
- mutable scoped_ptr<ChromeURLRequestContext> main_request_context_;
- mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_;
+ mutable scoped_ptr<net::URLRequestContext> main_request_context_;
+ mutable scoped_ptr<net::URLRequestContext> extensions_request_context_;
// One URLRequestContext per isolated app for main and media requests.
mutable URLRequestContextMap app_request_context_map_;
mutable URLRequestContextMap isolated_media_request_context_map_;
mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
- mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
- resource_prefetch_predictor_observer_;
-
mutable scoped_ptr<ChromeHttpUserAgentSettings>
chrome_http_user_agent_settings_;
- mutable chrome_browser_net::LoadTimeStats* load_time_stats_;
-
#if defined(ENABLE_MANAGED_USERS)
- mutable scoped_refptr<const ManagedModeURLFilter> managed_mode_url_filter_;
+ mutable scoped_refptr<const SupervisedUserURLFilter>
+ supervised_user_url_filter_;
#endif
+ mutable scoped_ptr<DevToolsNetworkController> network_controller_;
+
// TODO(jhawkins): Remove once crbug.com/102004 is fixed.
bool initialized_on_UI_thread_;
- bool is_incognito_;
+ const Profile::ProfileType profile_type_;
DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
};