| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 URLRequestContextMap; | 364 URLRequestContextMap; |
| 376 | 365 |
| 377 // -------------------------------------------- | 366 // -------------------------------------------- |
| 378 // Virtual interface for subtypes to implement: | 367 // Virtual interface for subtypes to implement: |
| 379 // -------------------------------------------- | 368 // -------------------------------------------- |
| 380 | 369 |
| 381 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 370 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
| 382 // should use the static helper functions above to implement this. | 371 // should use the static helper functions above to implement this. |
| 383 virtual void InitializeInternal( | 372 virtual void InitializeInternal( |
| 384 ProfileParams* profile_params, | 373 ProfileParams* profile_params, |
| 385 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 374 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 386 blob_protocol_handler, | |
| 387 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 388 file_system_protocol_handler, | |
| 389 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 390 developer_protocol_handler, | |
| 391 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 392 chrome_protocol_handler, | |
| 393 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 394 chrome_devtools_protocol_handler) const = 0; | |
| 395 | 375 |
| 396 // Initializes the RequestContext for extensions. | 376 // Initializes the RequestContext for extensions. |
| 397 virtual void InitializeExtensionsRequestContext( | 377 virtual void InitializeExtensionsRequestContext( |
| 398 ProfileParams* profile_params) const = 0; | 378 ProfileParams* profile_params) const = 0; |
| 399 // Does an on-demand initialization of a RequestContext for the given | 379 // Does an on-demand initialization of a RequestContext for the given |
| 400 // isolated app. | 380 // isolated app. |
| 401 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 381 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
| 402 ChromeURLRequestContext* main_context, | 382 ChromeURLRequestContext* main_context, |
| 403 const StoragePartitionDescriptor& details, | 383 const StoragePartitionDescriptor& details, |
| 404 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 384 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 405 protocol_handler_interceptor, | 385 protocol_handler_interceptor, |
| 406 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 386 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 407 blob_protocol_handler, | |
| 408 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 409 file_system_protocol_handler, | |
| 410 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 411 developer_protocol_handler, | |
| 412 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 413 chrome_protocol_handler, | |
| 414 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 415 chrome_devtools_protocol_handler) const = 0; | |
| 416 | 387 |
| 417 // Does an on-demand initialization of a media RequestContext for the given | 388 // Does an on-demand initialization of a media RequestContext for the given |
| 418 // isolated app. | 389 // isolated app. |
| 419 virtual ChromeURLRequestContext* InitializeMediaRequestContext( | 390 virtual ChromeURLRequestContext* InitializeMediaRequestContext( |
| 420 ChromeURLRequestContext* original_context, | 391 ChromeURLRequestContext* original_context, |
| 421 const StoragePartitionDescriptor& details) const = 0; | 392 const StoragePartitionDescriptor& details) const = 0; |
| 422 | 393 |
| 423 // These functions are used to transfer ownership of the lazily initialized | 394 // These functions are used to transfer ownership of the lazily initialized |
| 424 // context from ProfileIOData to the URLRequestContextGetter. | 395 // context from ProfileIOData to the URLRequestContextGetter. |
| 425 virtual ChromeURLRequestContext* | 396 virtual ChromeURLRequestContext* |
| 426 AcquireMediaRequestContext() const = 0; | 397 AcquireMediaRequestContext() const = 0; |
| 427 virtual ChromeURLRequestContext* | 398 virtual ChromeURLRequestContext* |
| 428 AcquireIsolatedAppRequestContext( | 399 AcquireIsolatedAppRequestContext( |
| 429 ChromeURLRequestContext* main_context, | 400 ChromeURLRequestContext* main_context, |
| 430 const StoragePartitionDescriptor& partition_descriptor, | 401 const StoragePartitionDescriptor& partition_descriptor, |
| 431 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 402 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 432 protocol_handler_interceptor, | 403 protocol_handler_interceptor, |
| 433 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 404 content::ProtocolHandlerMap* protocol_handlers) const = 0; |
| 434 blob_protocol_handler, | |
| 435 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 436 file_system_protocol_handler, | |
| 437 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 438 developer_protocol_handler, | |
| 439 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 440 chrome_protocol_handler, | |
| 441 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 442 chrome_devtools_protocol_handler) const = 0; | |
| 443 virtual ChromeURLRequestContext* | 405 virtual ChromeURLRequestContext* |
| 444 AcquireIsolatedMediaRequestContext( | 406 AcquireIsolatedMediaRequestContext( |
| 445 ChromeURLRequestContext* app_context, | 407 ChromeURLRequestContext* app_context, |
| 446 const StoragePartitionDescriptor& partition_descriptor) const = 0; | 408 const StoragePartitionDescriptor& partition_descriptor) const = 0; |
| 447 | 409 |
| 448 // Returns the LoadTimeStats object to be used for this profile. | 410 // Returns the LoadTimeStats object to be used for this profile. |
| 449 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( | 411 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( |
| 450 IOThread::Globals* io_thread_globals) const = 0; | 412 IOThread::Globals* io_thread_globals) const = 0; |
| 451 | 413 |
| 452 // The order *DOES* matter for the majority of these member variables, so | 414 // The order *DOES* matter for the majority of these member variables, so |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 510 |
| 549 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 511 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| 550 bool initialized_on_UI_thread_; | 512 bool initialized_on_UI_thread_; |
| 551 | 513 |
| 552 bool is_incognito_; | 514 bool is_incognito_; |
| 553 | 515 |
| 554 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 516 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 555 }; | 517 }; |
| 556 | 518 |
| 557 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 519 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |