| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/prefs/public/pref_member.h" | 16 #include "base/prefs/public/pref_member.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 19 #include "chrome/browser/io_thread.h" | 19 #include "chrome/browser/io_thread.h" |
| 20 #include "chrome/browser/net/chrome_url_request_context.h" | 20 #include "chrome/browser/net/chrome_url_request_context.h" |
| 21 #include "chrome/browser/profiles/storage_partition_descriptor.h" | 21 #include "chrome/browser/profiles/storage_partition_descriptor.h" |
| 22 #include "content/public/browser/content_browser_client.h" |
| 22 #include "content/public/browser/resource_context.h" | 23 #include "content/public/browser/resource_context.h" |
| 23 #include "net/cookies/cookie_monster.h" | 24 #include "net/cookies/cookie_monster.h" |
| 24 #include "net/http/http_network_session.h" | 25 #include "net/http/http_network_session.h" |
| 25 #include "net/url_request/url_request_job_factory.h" | 26 #include "net/url_request/url_request_job_factory.h" |
| 26 | 27 |
| 27 class ChromeHttpUserAgentSettings; | 28 class ChromeHttpUserAgentSettings; |
| 28 class ChromeNetworkDelegate; | 29 class ChromeNetworkDelegate; |
| 29 class CookieSettings; | 30 class CookieSettings; |
| 30 class DesktopNotificationService; | 31 class DesktopNotificationService; |
| 31 class ExtensionInfoMap; | 32 class ExtensionInfoMap; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 static ProfileIOData* FromResourceContext(content::ResourceContext* rc); | 71 static ProfileIOData* FromResourceContext(content::ResourceContext* rc); |
| 71 | 72 |
| 72 // Returns true if |scheme| is handled in Chrome, or by default handlers in | 73 // Returns true if |scheme| is handled in Chrome, or by default handlers in |
| 73 // net::URLRequest. | 74 // net::URLRequest. |
| 74 static bool IsHandledProtocol(const std::string& scheme); | 75 static bool IsHandledProtocol(const std::string& scheme); |
| 75 | 76 |
| 76 // Returns true if |url| is handled in Chrome, or by default handlers in | 77 // Returns true if |url| is handled in Chrome, or by default handlers in |
| 77 // net::URLRequest. | 78 // net::URLRequest. |
| 78 static bool IsHandledURL(const GURL& url); | 79 static bool IsHandledURL(const GURL& url); |
| 79 | 80 |
| 81 // Utility to install additional WebUI handlers into the |job_factory|. |
| 82 // Ownership of the handlers is transfered from |protocol_handlers| |
| 83 // to the |job_factory|. |
| 84 static void InstallProtocolHandlers( |
| 85 net::URLRequestJobFactoryImpl* job_factory, |
| 86 content::ProtocolHandlerMap* protocol_handlers); |
| 87 |
| 80 // Called by Profile. | 88 // Called by Profile. |
| 81 content::ResourceContext* GetResourceContext() const; | 89 content::ResourceContext* GetResourceContext() const; |
| 82 | 90 |
| 83 // Initializes the ProfileIOData object and primes the RequestContext | 91 // Initializes the ProfileIOData object and primes the RequestContext |
| 84 // generation. Must be called prior to any of the Get*() methods other than | 92 // generation. Must be called prior to any of the Get*() methods other than |
| 85 // GetResouceContext or GetMetricsEnabledStateOnIOThread. | 93 // GetResouceContext or GetMetricsEnabledStateOnIOThread. |
| 86 void Init( | 94 void Init(content::ProtocolHandlerMap* protocol_handlers) const; |
| 87 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 88 blob_protocol_handler, | |
| 89 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 90 file_system_protocol_handler, | |
| 91 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 92 developer_protocol_handler, | |
| 93 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 94 chrome_protocol_handler, | |
| 95 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 96 chrome_devtools_protocol_handler) const; | |
| 97 | 95 |
| 98 ChromeURLRequestContext* GetMainRequestContext() const; | 96 ChromeURLRequestContext* GetMainRequestContext() const; |
| 99 ChromeURLRequestContext* GetMediaRequestContext() const; | 97 ChromeURLRequestContext* GetMediaRequestContext() const; |
| 100 ChromeURLRequestContext* GetExtensionsRequestContext() const; | 98 ChromeURLRequestContext* GetExtensionsRequestContext() const; |
| 101 ChromeURLRequestContext* GetIsolatedAppRequestContext( | 99 ChromeURLRequestContext* GetIsolatedAppRequestContext( |
| 102 ChromeURLRequestContext* main_context, | 100 ChromeURLRequestContext* main_context, |
| 103 const StoragePartitionDescriptor& partition_descriptor, | 101 const StoragePartitionDescriptor& partition_descriptor, |
| 104 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 102 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 105 protocol_handler_interceptor, | 103 protocol_handler_interceptor, |
| 106 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 104 content::ProtocolHandlerMap* protocol_handlers) const; |
| 107 blob_protocol_handler, | |
| 108 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 109 file_system_protocol_handler, | |
| 110 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 111 developer_protocol_handler, | |
| 112 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 113 chrome_protocol_handler, | |
| 114 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 115 chrome_devtools_protocol_handler) const; | |
| 116 ChromeURLRequestContext* GetIsolatedMediaRequestContext( | 105 ChromeURLRequestContext* GetIsolatedMediaRequestContext( |
| 117 ChromeURLRequestContext* app_context, | 106 ChromeURLRequestContext* app_context, |
| 118 const StoragePartitionDescriptor& partition_descriptor) const; | 107 const StoragePartitionDescriptor& partition_descriptor) const; |
| 119 | 108 |
| 120 // These are useful when the Chrome layer is called from the content layer | 109 // These are useful when the Chrome layer is called from the content layer |
| 121 // with a content::ResourceContext, and they want access to Chrome data for | 110 // with a content::ResourceContext, and they want access to Chrome data for |
| 122 // that profile. | 111 // that profile. |
| 123 ExtensionInfoMap* GetExtensionInfoMap() const; | 112 ExtensionInfoMap* GetExtensionInfoMap() const; |
| 124 CookieSettings* GetCookieSettings() const; | 113 CookieSettings* GetCookieSettings() const; |
| 125 | 114 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 URLRequestContextMap; | 368 URLRequestContextMap; |
| 380 | 369 |
| 381 // -------------------------------------------- | 370 // -------------------------------------------- |
| 382 // Virtual interface for subtypes to implement: | 371 // Virtual interface for subtypes to implement: |
| 383 // -------------------------------------------- | 372 // -------------------------------------------- |
| 384 | 373 |
| 385 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 374 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
| 386 // should use the static helper functions above to implement this. | 375 // should use the static helper functions above to implement this. |
| 387 virtual void InitializeInternal( | 376 virtual void InitializeInternal( |
| 388 ProfileParams* profile_params, | 377 ProfileParams* profile_params, |
| 389 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 378 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 390 blob_protocol_handler, | |
| 391 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 392 file_system_protocol_handler, | |
| 393 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 394 developer_protocol_handler, | |
| 395 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 396 chrome_protocol_handler, | |
| 397 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 398 chrome_devtools_protocol_handler) const = 0; | |
| 399 | 379 |
| 400 // Initializes the RequestContext for extensions. | 380 // Initializes the RequestContext for extensions. |
| 401 virtual void InitializeExtensionsRequestContext( | 381 virtual void InitializeExtensionsRequestContext( |
| 402 ProfileParams* profile_params) const = 0; | 382 ProfileParams* profile_params) const = 0; |
| 403 // Does an on-demand initialization of a RequestContext for the given | 383 // Does an on-demand initialization of a RequestContext for the given |
| 404 // isolated app. | 384 // isolated app. |
| 405 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 385 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
| 406 ChromeURLRequestContext* main_context, | 386 ChromeURLRequestContext* main_context, |
| 407 const StoragePartitionDescriptor& details, | 387 const StoragePartitionDescriptor& details, |
| 408 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 388 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 409 protocol_handler_interceptor, | 389 protocol_handler_interceptor, |
| 410 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 390 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 411 blob_protocol_handler, | |
| 412 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 413 file_system_protocol_handler, | |
| 414 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 415 developer_protocol_handler, | |
| 416 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 417 chrome_protocol_handler, | |
| 418 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 419 chrome_devtools_protocol_handler) const = 0; | |
| 420 | 391 |
| 421 // Does an on-demand initialization of a media RequestContext for the given | 392 // Does an on-demand initialization of a media RequestContext for the given |
| 422 // isolated app. | 393 // isolated app. |
| 423 virtual ChromeURLRequestContext* InitializeMediaRequestContext( | 394 virtual ChromeURLRequestContext* InitializeMediaRequestContext( |
| 424 ChromeURLRequestContext* original_context, | 395 ChromeURLRequestContext* original_context, |
| 425 const StoragePartitionDescriptor& details) const = 0; | 396 const StoragePartitionDescriptor& details) const = 0; |
| 426 | 397 |
| 427 // These functions are used to transfer ownership of the lazily initialized | 398 // These functions are used to transfer ownership of the lazily initialized |
| 428 // context from ProfileIOData to the URLRequestContextGetter. | 399 // context from ProfileIOData to the URLRequestContextGetter. |
| 429 virtual ChromeURLRequestContext* | 400 virtual ChromeURLRequestContext* |
| 430 AcquireMediaRequestContext() const = 0; | 401 AcquireMediaRequestContext() const = 0; |
| 431 virtual ChromeURLRequestContext* | 402 virtual ChromeURLRequestContext* |
| 432 AcquireIsolatedAppRequestContext( | 403 AcquireIsolatedAppRequestContext( |
| 433 ChromeURLRequestContext* main_context, | 404 ChromeURLRequestContext* main_context, |
| 434 const StoragePartitionDescriptor& partition_descriptor, | 405 const StoragePartitionDescriptor& partition_descriptor, |
| 435 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 406 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 436 protocol_handler_interceptor, | 407 protocol_handler_interceptor, |
| 437 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 408 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 438 blob_protocol_handler, | |
| 439 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 440 file_system_protocol_handler, | |
| 441 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 442 developer_protocol_handler, | |
| 443 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 444 chrome_protocol_handler, | |
| 445 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 446 chrome_devtools_protocol_handler) const = 0; | |
| 447 virtual ChromeURLRequestContext* | 409 virtual ChromeURLRequestContext* |
| 448 AcquireIsolatedMediaRequestContext( | 410 AcquireIsolatedMediaRequestContext( |
| 449 ChromeURLRequestContext* app_context, | 411 ChromeURLRequestContext* app_context, |
| 450 const StoragePartitionDescriptor& partition_descriptor) const = 0; | 412 const StoragePartitionDescriptor& partition_descriptor) const = 0; |
| 451 | 413 |
| 452 // Returns the LoadTimeStats object to be used for this profile. | 414 // Returns the LoadTimeStats object to be used for this profile. |
| 453 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( | 415 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( |
| 454 IOThread::Globals* io_thread_globals) const = 0; | 416 IOThread::Globals* io_thread_globals) const = 0; |
| 455 | 417 |
| 456 // The order *DOES* matter for the majority of these member variables, so | 418 // The order *DOES* matter for the majority of these member variables, so |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 515 |
| 554 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 516 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| 555 bool initialized_on_UI_thread_; | 517 bool initialized_on_UI_thread_; |
| 556 | 518 |
| 557 bool is_incognito_; | 519 bool is_incognito_; |
| 558 | 520 |
| 559 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 521 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 560 }; | 522 }; |
| 561 | 523 |
| 562 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 524 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |