1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
6#define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
7
8#include <map>
9#include <string>
10#include <vector>
11
12#include "base/basictypes.h"
13#include "base/callback_forward.h"
14#include "base/files/file_path.h"
15#include "base/memory/ref_counted.h"
16#include "base/memory/scoped_ptr.h"
17#include "base/memory/weak_ptr.h"
18#include "base/prefs/pref_member.h"
19#include "base/synchronization/lock.h"
20#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
21#include "chrome/browser/io_thread.h"
22#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
23#include "chrome/browser/profiles/profile.h"
24#include "chrome/browser/profiles/storage_partition_descriptor.h"
25#include "components/content_settings/core/common/content_settings_types.h"
26#include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h"
27#include "components/data_reduction_proxy/browser/data_reduction_proxy_statistics_prefs.h"
28#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
29#include "content/public/browser/content_browser_client.h"
30#include "content/public/browser/resource_context.h"
31#include "net/cookies/cookie_monster.h"
32#include "net/http/http_cache.h"
33#include "net/http/http_network_session.h"
34#include "net/url_request/url_request_context.h"
35#include "net/url_request/url_request_job_factory.h"
36
37class ChromeHttpUserAgentSettings;
38class ChromeNetworkDelegate;
39class ChromeURLRequestContextGetter;
40class CookieSettings;
41class DevToolsNetworkController;
42class HostContentSettingsMap;
43class MediaDeviceIDSalt;
44class ProtocolHandlerRegistry;
45class SigninNamesOnIOThread;
46class SupervisedUserURLFilter;
47
48namespace chrome_browser_net {
49class ResourcePrefetchPredictorObserver;
50}
51
52namespace extensions {
53class InfoMap;
54}
55
56namespace net {
57class CertVerifier;
58class ChannelIDService;
59class CookieStore;
60class FraudulentCertificateReporter;
61class FtpTransactionFactory;
62class HttpServerProperties;
63class HttpTransactionFactory;
64class ProxyConfigService;
65class ProxyService;
66class SSLConfigService;
67class TransportSecurityPersister;
68class TransportSecurityState;
69class URLRequestJobFactoryImpl;
70}  // namespace net
71
72namespace policy {
73class PolicyCertVerifier;
74class PolicyHeaderIOHelper;
75class URLBlacklistManager;
76}  // namespace policy
77
78namespace prerender {
79class PrerenderTracker;
80}
81
82// Conceptually speaking, the ProfileIOData represents data that lives on the IO
83// thread that is owned by a Profile, such as, but not limited to, network
84// objects like CookieMonster, HttpTransactionFactory, etc.  Profile owns
85// ProfileIOData, but will make sure to delete it on the IO thread (except
86// possibly in unit tests where there is no IO thread).
87class ProfileIOData {
88 public:
89  typedef std::vector<scoped_refptr<ChromeURLRequestContextGetter>>
90      ChromeURLRequestContextGetterVector;
91
92  virtual ~ProfileIOData();
93
94  static ProfileIOData* FromResourceContext(content::ResourceContext* rc);
95
96  // Returns true if |scheme| is handled in Chrome, or by default handlers in
97  // net::URLRequest.
98  static bool IsHandledProtocol(const std::string& scheme);
99
100  // Returns true if |url| is handled in Chrome, or by default handlers in
101  // net::URLRequest.
102  static bool IsHandledURL(const GURL& url);
103
104  // Utility to install additional WebUI handlers into the |job_factory|.
105  // Ownership of the handlers is transfered from |protocol_handlers|
106  // to the |job_factory|.
107  static void InstallProtocolHandlers(
108      net::URLRequestJobFactoryImpl* job_factory,
109      content::ProtocolHandlerMap* protocol_handlers);
110
111  // Called by Profile.
112  content::ResourceContext* GetResourceContext() const;
113
114  // Initializes the ProfileIOData object and primes the RequestContext
115  // generation. Must be called prior to any of the Get*() methods other than
116  // GetResouceContext or GetMetricsEnabledStateOnIOThread.
117  void Init(
118      content::ProtocolHandlerMap* protocol_handlers,
119      content::URLRequestInterceptorScopedVector request_interceptors) const;
120
121  net::URLRequestContext* GetMainRequestContext() const;
122  net::URLRequestContext* GetMediaRequestContext() const;
123  net::URLRequestContext* GetExtensionsRequestContext() const;
124  net::URLRequestContext* GetIsolatedAppRequestContext(
125      net::URLRequestContext* main_context,
126      const StoragePartitionDescriptor& partition_descriptor,
127      scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
128          protocol_handler_interceptor,
129      content::ProtocolHandlerMap* protocol_handlers,
130      content::URLRequestInterceptorScopedVector request_interceptors) const;
131  net::URLRequestContext* GetIsolatedMediaRequestContext(
132      net::URLRequestContext* app_context,
133      const StoragePartitionDescriptor& partition_descriptor) const;
134
135  // These are useful when the Chrome layer is called from the content layer
136  // with a content::ResourceContext, and they want access to Chrome data for
137  // that profile.
138  extensions::InfoMap* GetExtensionInfoMap() const;
139  CookieSettings* GetCookieSettings() const;
140  HostContentSettingsMap* GetHostContentSettingsMap() const;
141
142  IntegerPrefMember* session_startup_pref() const {
143    return &session_startup_pref_;
144  }
145
146  SigninNamesOnIOThread* signin_names() const {
147    return signin_names_.get();
148  }
149
150  StringPrefMember* google_services_account_id() const {
151    return &google_services_user_account_id_;
152  }
153
154  StringPrefMember* google_services_username() const {
155    return &google_services_username_;
156  }
157
158  StringPrefMember* google_services_username_pattern() const {
159    return &google_services_username_pattern_;
160  }
161
162  BooleanPrefMember* reverse_autologin_enabled() const {
163    return &reverse_autologin_enabled_;
164  }
165
166  const std::string& reverse_autologin_pending_email() const {
167    return reverse_autologin_pending_email_;
168  }
169
170  void set_reverse_autologin_pending_email(const std::string& email) {
171    reverse_autologin_pending_email_ = email;
172  }
173
174  StringListPrefMember* one_click_signin_rejected_email_list() const {
175    return &one_click_signin_rejected_email_list_;
176  }
177
178  net::URLRequestContext* extensions_request_context() const {
179    return extensions_request_context_.get();
180  }
181
182  BooleanPrefMember* safe_browsing_enabled() const {
183    return &safe_browsing_enabled_;
184  }
185
186  // TODO(feng): move the function to protected area.
187  // IsDataReductionProxyEnabled() should be used as public API.
188  BooleanPrefMember* data_reduction_proxy_enabled() const {
189    return &data_reduction_proxy_enabled_;
190  }
191
192  BooleanPrefMember* printing_enabled() const {
193    return &printing_enabled_;
194  }
195
196  BooleanPrefMember* sync_disabled() const {
197    return &sync_disabled_;
198  }
199
200  BooleanPrefMember* signin_allowed() const {
201    return &signin_allowed_;
202  }
203
204  IntegerPrefMember* network_prediction_options() const {
205    return &network_prediction_options_;
206  }
207
208  content::ResourceContext::SaltCallback GetMediaDeviceIDSalt() const;
209
210  DevToolsNetworkController* network_controller() const {
211    return network_controller_.get();
212  }
213
214  net::TransportSecurityState* transport_security_state() const {
215    return transport_security_state_.get();
216  }
217
218#if defined(OS_CHROMEOS)
219  std::string username_hash() const {
220    return username_hash_;
221  }
222
223  bool use_system_key_slot() const { return use_system_key_slot_; }
224#endif
225
226  Profile::ProfileType profile_type() const {
227    return profile_type_;
228  }
229
230  bool IsOffTheRecord() const;
231
232  IntegerPrefMember* incognito_availibility() const {
233    return &incognito_availibility_pref_;
234  }
235
236  chrome_browser_net::ResourcePrefetchPredictorObserver*
237      resource_prefetch_predictor_observer() const {
238    return resource_prefetch_predictor_observer_.get();
239  }
240
241#if defined(ENABLE_CONFIGURATION_POLICY)
242  policy::PolicyHeaderIOHelper* policy_header_helper() const {
243    return policy_header_helper_.get();
244  }
245#endif
246
247#if defined(ENABLE_MANAGED_USERS)
248  const SupervisedUserURLFilter* supervised_user_url_filter() const {
249    return supervised_user_url_filter_.get();
250  }
251#endif
252
253  // Initialize the member needed to track the metrics enabled state. This is
254  // only to be called on the UI thread.
255  void InitializeMetricsEnabledStateOnUIThread();
256
257  // Returns whether or not metrics reporting is enabled in the browser instance
258  // on which this profile resides. This is safe for use from the IO thread, and
259  // should only be called from there.
260  bool GetMetricsEnabledStateOnIOThread() const;
261
262  // Returns whether or not data reduction proxy is enabled in the browser
263  // instance on which this profile resides.
264  bool IsDataReductionProxyEnabled() const;
265
266  void set_client_cert_store_factory_for_testing(
267    const base::Callback<scoped_ptr<net::ClientCertStore>()>& factory) {
268      client_cert_store_factory_ = factory;
269  }
270
271 protected:
272  // A URLRequestContext for media that owns its HTTP factory, to ensure
273  // it is deleted.
274  class MediaRequestContext : public net::URLRequestContext {
275   public:
276    MediaRequestContext();
277
278    void SetHttpTransactionFactory(
279        scoped_ptr<net::HttpTransactionFactory> http_factory);
280
281   private:
282    virtual ~MediaRequestContext();
283
284    scoped_ptr<net::HttpTransactionFactory> http_factory_;
285  };
286
287  // A URLRequestContext for apps that owns its cookie store and HTTP factory,
288  // to ensure they are deleted.
289  class AppRequestContext : public net::URLRequestContext {
290   public:
291    AppRequestContext();
292
293    void SetCookieStore(net::CookieStore* cookie_store);
294    void SetHttpTransactionFactory(
295        scoped_ptr<net::HttpTransactionFactory> http_factory);
296    void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory);
297
298   private:
299    virtual ~AppRequestContext();
300
301    scoped_refptr<net::CookieStore> cookie_store_;
302    scoped_ptr<net::HttpTransactionFactory> http_factory_;
303    scoped_ptr<net::URLRequestJobFactory> job_factory_;
304  };
305
306  // Created on the UI thread, read on the IO thread during ProfileIOData lazy
307  // initialization.
308  struct ProfileParams {
309    ProfileParams();
310    ~ProfileParams();
311
312    base::FilePath path;
313    IOThread* io_thread;
314    scoped_refptr<CookieSettings> cookie_settings;
315    scoped_refptr<HostContentSettingsMap> host_content_settings_map;
316    scoped_refptr<net::SSLConfigService> ssl_config_service;
317    scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate;
318#if defined(ENABLE_EXTENSIONS)
319    scoped_refptr<extensions::InfoMap> extension_info_map;
320#endif
321    scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
322        resource_prefetch_predictor_observer_;
323
324    // This pointer exists only as a means of conveying a url job factory
325    // pointer from the protocol handler registry on the UI thread to the
326    // the URLRequestContext on the IO thread. The consumer MUST take
327    // ownership of the object by calling release() on this pointer.
328    scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
329        protocol_handler_interceptor;
330
331    // We need to initialize the ProxyConfigService from the UI thread
332    // because on linux it relies on initializing things through gconf,
333    // and needs to be on the main thread.
334    scoped_ptr<net::ProxyConfigService> proxy_config_service;
335
336#if defined(ENABLE_MANAGED_USERS)
337    scoped_refptr<const SupervisedUserURLFilter> supervised_user_url_filter;
338#endif
339
340#if defined(OS_CHROMEOS)
341    std::string username_hash;
342    bool use_system_key_slot;
343#endif
344
345    // The profile this struct was populated from. It's passed as a void* to
346    // ensure it's not accidently used on the IO thread. Before using it on the
347    // UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
348    void* profile;
349
350    prerender::PrerenderTracker* prerender_tracker;
351  };
352
353  explicit ProfileIOData(Profile::ProfileType profile_type);
354
355  static std::string GetSSLSessionCacheShard();
356
357  void InitializeOnUIThread(Profile* profile);
358  void ApplyProfileParamsToContext(net::URLRequestContext* context) const;
359
360  scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
361      scoped_ptr<net::URLRequestJobFactoryImpl> job_factory,
362      content::URLRequestInterceptorScopedVector request_interceptors,
363      scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
364          protocol_handler_interceptor,
365      net::NetworkDelegate* network_delegate,
366      net::FtpTransactionFactory* ftp_transaction_factory) const;
367
368  // Called when the profile is destroyed.
369  void ShutdownOnUIThread(
370      scoped_ptr<ChromeURLRequestContextGetterVector> context_getters);
371
372  // A ChannelIDService object is created by a derived class of
373  // ProfileIOData, and the derived class calls this method to set the
374  // channel_id_service_ member and transfers ownership to the base
375  // class.
376  void set_channel_id_service(
377      net::ChannelIDService* channel_id_service) const;
378
379  data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params()
380      const {
381    return data_reduction_proxy_params_.get();
382  }
383
384  void set_data_reduction_proxy_params(
385      scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
386          data_reduction_proxy_params) const {
387    data_reduction_proxy_params_ = data_reduction_proxy_params.Pass();
388  }
389
390  data_reduction_proxy::DataReductionProxyUsageStats*
391      data_reduction_proxy_usage_stats() const {
392    return data_reduction_proxy_usage_stats_.get();
393  }
394
395  void set_data_reduction_proxy_statistics_prefs(
396      scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
397          data_reduction_proxy_statistics_prefs) {
398    data_reduction_proxy_statistics_prefs_ =
399        data_reduction_proxy_statistics_prefs.Pass();
400  }
401
402  data_reduction_proxy::DataReductionProxyStatisticsPrefs*
403      data_reduction_proxy_statistics_prefs() const {
404    return data_reduction_proxy_statistics_prefs_.get();
405  }
406
407  void set_data_reduction_proxy_usage_stats(
408      scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
409          data_reduction_proxy_usage_stats) const {
410     data_reduction_proxy_usage_stats_ =
411         data_reduction_proxy_usage_stats.Pass();
412  }
413
414  base::Callback<void(bool)> data_reduction_proxy_unavailable_callback() const {
415    return data_reduction_proxy_unavailable_callback_;
416  }
417
418  void set_data_reduction_proxy_unavailable_callback(
419      const base::Callback<void(bool)>& unavailable_callback) const {
420    data_reduction_proxy_unavailable_callback_ = unavailable_callback;
421  }
422
423  DataReductionProxyChromeConfigurator*
424      data_reduction_proxy_chrome_configurator() const {
425    return data_reduction_proxy_chrome_configurator_.get();
426  }
427
428  void set_data_reduction_proxy_chrome_configurator(
429      scoped_ptr<DataReductionProxyChromeConfigurator>
430          data_reduction_proxy_chrome_configurator) const {
431    data_reduction_proxy_chrome_configurator_ =
432        data_reduction_proxy_chrome_configurator.Pass();
433  }
434
435  data_reduction_proxy::DataReductionProxyAuthRequestHandler*
436      data_reduction_proxy_auth_request_handler() const {
437    return data_reduction_proxy_auth_request_handler_.get();
438  }
439
440  void set_data_reduction_proxy_auth_request_handler(
441      scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
442          data_reduction_proxy_auth_request_handler) const {
443    data_reduction_proxy_auth_request_handler_ =
444        data_reduction_proxy_auth_request_handler.Pass();
445  }
446
447  ChromeNetworkDelegate* network_delegate() const {
448    return network_delegate_.get();
449  }
450
451  net::FraudulentCertificateReporter* fraudulent_certificate_reporter() const {
452    return fraudulent_certificate_reporter_.get();
453  }
454
455  net::ProxyService* proxy_service() const {
456    return proxy_service_.get();
457  }
458
459  base::WeakPtr<net::HttpServerProperties> http_server_properties() const;
460
461  void set_http_server_properties(
462      scoped_ptr<net::HttpServerProperties> http_server_properties) const;
463
464  net::URLRequestContext* main_request_context() const {
465    return main_request_context_.get();
466  }
467
468  bool initialized() const {
469    return initialized_;
470  }
471
472  // Destroys the ResourceContext first, to cancel any URLRequests that are
473  // using it still, before we destroy the member variables that those
474  // URLRequests may be accessing.
475  void DestroyResourceContext();
476
477  // Creates network session and main network transaction factory.
478  scoped_ptr<net::HttpCache> CreateMainHttpFactory(
479      const ProfileParams* profile_params,
480      net::HttpCache::BackendFactory* main_backend) const;
481
482  // Creates network transaction factory.
483  scoped_ptr<net::HttpCache> CreateHttpFactory(
484      net::HttpNetworkSession* shared_session,
485      net::HttpCache::BackendFactory* backend) const;
486
487  void SetCookieSettingsForTesting(CookieSettings* cookie_settings);
488
489  void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names);
490
491 private:
492  class ResourceContext : public content::ResourceContext {
493   public:
494    explicit ResourceContext(ProfileIOData* io_data);
495    virtual ~ResourceContext();
496
497    // ResourceContext implementation:
498    virtual net::HostResolver* GetHostResolver() OVERRIDE;
499    virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
500    virtual scoped_ptr<net::ClientCertStore> CreateClientCertStore() OVERRIDE;
501    virtual void CreateKeygenHandler(
502        uint32 key_size_in_bits,
503        const std::string& challenge_string,
504        const GURL& url,
505        const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback)
506        OVERRIDE;
507    virtual SaltCallback GetMediaDeviceIDSalt() OVERRIDE;
508
509   private:
510    friend class ProfileIOData;
511
512    ProfileIOData* const io_data_;
513
514    net::HostResolver* host_resolver_;
515    net::URLRequestContext* request_context_;
516  };
517
518  typedef std::map<StoragePartitionDescriptor,
519                   net::URLRequestContext*,
520                   StoragePartitionDescriptorLess>
521      URLRequestContextMap;
522
523  // --------------------------------------------
524  // Virtual interface for subtypes to implement:
525  // --------------------------------------------
526
527  // Does the actual initialization of the ProfileIOData subtype. Subtypes
528  // should use the static helper functions above to implement this.
529  virtual void InitializeInternal(
530      ProfileParams* profile_params,
531      content::ProtocolHandlerMap* protocol_handlers,
532      content::URLRequestInterceptorScopedVector
533          request_interceptors) const = 0;
534
535  // Initializes the RequestContext for extensions.
536  virtual void InitializeExtensionsRequestContext(
537      ProfileParams* profile_params) const = 0;
538  // Does an on-demand initialization of a RequestContext for the given
539  // isolated app.
540  virtual net::URLRequestContext* InitializeAppRequestContext(
541      net::URLRequestContext* main_context,
542      const StoragePartitionDescriptor& details,
543      scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
544          protocol_handler_interceptor,
545      content::ProtocolHandlerMap* protocol_handlers,
546      content::URLRequestInterceptorScopedVector
547          request_interceptors) const = 0;
548
549  // Does an on-demand initialization of a media RequestContext for the given
550  // isolated app.
551  virtual net::URLRequestContext* InitializeMediaRequestContext(
552      net::URLRequestContext* original_context,
553      const StoragePartitionDescriptor& details) const = 0;
554
555  // These functions are used to transfer ownership of the lazily initialized
556  // context from ProfileIOData to the URLRequestContextGetter.
557  virtual net::URLRequestContext*
558      AcquireMediaRequestContext() const = 0;
559  virtual net::URLRequestContext* AcquireIsolatedAppRequestContext(
560      net::URLRequestContext* main_context,
561      const StoragePartitionDescriptor& partition_descriptor,
562      scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
563          protocol_handler_interceptor,
564      content::ProtocolHandlerMap* protocol_handlers,
565      content::URLRequestInterceptorScopedVector
566          request_interceptors) const = 0;
567  virtual net::URLRequestContext*
568      AcquireIsolatedMediaRequestContext(
569          net::URLRequestContext* app_context,
570          const StoragePartitionDescriptor& partition_descriptor) const = 0;
571
572  // The order *DOES* matter for the majority of these member variables, so
573  // don't move them around unless you know what you're doing!
574  // General rules:
575  //   * ResourceContext references the URLRequestContexts, so
576  //   URLRequestContexts must outlive ResourceContext, hence ResourceContext
577  //   should be destroyed first.
578  //   * URLRequestContexts reference a whole bunch of members, so
579  //   URLRequestContext needs to be destroyed before them.
580  //   * Therefore, ResourceContext should be listed last, and then the
581  //   URLRequestContexts, and then the URLRequestContext members.
582  //   * Note that URLRequestContext members have a directed dependency graph
583  //   too, so they must themselves be ordered correctly.
584
585  // Tracks whether or not we've been lazily initialized.
586  mutable bool initialized_;
587
588  // Data from the UI thread from the Profile, used to initialize ProfileIOData.
589  // Deleted after lazy initialization.
590  mutable scoped_ptr<ProfileParams> profile_params_;
591
592  // Provides access to the email addresses of all signed in profiles.
593  mutable scoped_ptr<SigninNamesOnIOThread> signin_names_;
594
595  // Used for testing.
596  mutable base::Callback<scoped_ptr<net::ClientCertStore>()>
597      client_cert_store_factory_;
598
599  mutable StringPrefMember google_services_user_account_id_;
600  mutable StringPrefMember google_services_username_;
601  mutable StringPrefMember google_services_username_pattern_;
602  mutable BooleanPrefMember reverse_autologin_enabled_;
603
604  // During the reverse autologin request chain processing, this member saves
605  // the email of the google account that is being signed into.
606  std::string reverse_autologin_pending_email_;
607
608  mutable StringListPrefMember one_click_signin_rejected_email_list_;
609
610  mutable scoped_refptr<MediaDeviceIDSalt> media_device_id_salt_;
611
612  // Member variables which are pointed to by the various context objects.
613  mutable BooleanPrefMember enable_referrers_;
614  mutable BooleanPrefMember enable_do_not_track_;
615  mutable BooleanPrefMember force_safesearch_;
616  mutable BooleanPrefMember safe_browsing_enabled_;
617  mutable BooleanPrefMember data_reduction_proxy_enabled_;
618  mutable BooleanPrefMember printing_enabled_;
619  mutable BooleanPrefMember sync_disabled_;
620  mutable BooleanPrefMember signin_allowed_;
621  mutable IntegerPrefMember network_prediction_options_;
622  // TODO(marja): Remove session_startup_pref_ if no longer needed.
623  mutable IntegerPrefMember session_startup_pref_;
624  mutable BooleanPrefMember quick_check_enabled_;
625  mutable IntegerPrefMember incognito_availibility_pref_;
626
627  // The state of metrics reporting in the browser that this profile runs on.
628  // Unfortunately, since ChromeOS has a separate representation of this state,
629  // we need to make one available based on the platform.
630#if defined(OS_CHROMEOS)
631  bool enable_metrics_;
632#else
633  BooleanPrefMember enable_metrics_;
634#endif
635
636#if defined(ENABLE_CONFIGURATION_POLICY)
637  // Pointed to by NetworkDelegate.
638  mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_;
639  mutable scoped_ptr<policy::PolicyHeaderIOHelper> policy_header_helper_;
640#endif
641
642  // Pointed to by URLRequestContext.
643#if defined(ENABLE_EXTENSIONS)
644  mutable scoped_refptr<extensions::InfoMap> extension_info_map_;
645#endif
646  mutable scoped_ptr<net::ChannelIDService> channel_id_service_;
647
648  // data_reduction_proxy_* classes must be declared before |network_delegate_|.
649  // The data_reduction_proxy_* classes are passed in to |network_delegate_|,
650  // so this ordering ensures that the |network_delegate_| never references
651  // freed objects.
652  mutable scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
653      data_reduction_proxy_params_;
654  mutable scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
655      data_reduction_proxy_usage_stats_;
656  mutable scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
657            data_reduction_proxy_statistics_prefs_;
658  mutable base::Callback<void(bool)> data_reduction_proxy_unavailable_callback_;
659  mutable scoped_ptr<DataReductionProxyChromeConfigurator>
660      data_reduction_proxy_chrome_configurator_;
661  mutable scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
662      data_reduction_proxy_auth_request_handler_;
663
664  mutable scoped_ptr<ChromeNetworkDelegate> network_delegate_;
665  mutable scoped_ptr<net::FraudulentCertificateReporter>
666      fraudulent_certificate_reporter_;
667  mutable scoped_ptr<net::ProxyService> proxy_service_;
668  mutable scoped_ptr<net::TransportSecurityState> transport_security_state_;
669  mutable scoped_ptr<net::HttpServerProperties>
670      http_server_properties_;
671#if defined(OS_CHROMEOS)
672  // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that
673  // case, the verifier is owned by  |cert_verifier_|. Otherwise, set to NULL.
674  mutable policy::PolicyCertVerifier* policy_cert_verifier_;
675  mutable scoped_ptr<net::CertVerifier> cert_verifier_;
676  mutable std::string username_hash_;
677  mutable bool use_system_key_slot_;
678#endif
679
680  mutable scoped_ptr<net::TransportSecurityPersister>
681      transport_security_persister_;
682
683  // These are only valid in between LazyInitialize() and their accessor being
684  // called.
685  mutable scoped_ptr<net::URLRequestContext> main_request_context_;
686  mutable scoped_ptr<net::URLRequestContext> extensions_request_context_;
687  // One URLRequestContext per isolated app for main and media requests.
688  mutable URLRequestContextMap app_request_context_map_;
689  mutable URLRequestContextMap isolated_media_request_context_map_;
690
691  mutable scoped_ptr<ResourceContext> resource_context_;
692
693  mutable scoped_refptr<CookieSettings> cookie_settings_;
694
695  mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
696
697  mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
698      resource_prefetch_predictor_observer_;
699
700  mutable scoped_ptr<ChromeHttpUserAgentSettings>
701      chrome_http_user_agent_settings_;
702
703#if defined(ENABLE_MANAGED_USERS)
704  mutable scoped_refptr<const SupervisedUserURLFilter>
705      supervised_user_url_filter_;
706#endif
707
708  mutable scoped_ptr<DevToolsNetworkController> network_controller_;
709
710  // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
711  bool initialized_on_UI_thread_;
712
713  const Profile::ProfileType profile_type_;
714
715  DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
716};
717
718#endif  // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
719