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 #include "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/threading/sequenced_worker_pool.h" | 23 #include "base/threading/sequenced_worker_pool.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/content_settings/content_settings_provider.h" | 26 #include "chrome/browser/content_settings/content_settings_provider.h" |
27 #include "chrome/browser/content_settings/cookie_settings.h" | 27 #include "chrome/browser/content_settings/cookie_settings.h" |
28 #include "chrome/browser/content_settings/host_content_settings_map.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map.h" |
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 31 #include "chrome/browser/devtools/devtools_network_controller.h" |
| 32 #include "chrome/browser/devtools/devtools_network_transaction_factory.h" |
31 #include "chrome/browser/download/download_service.h" | 33 #include "chrome/browser/download/download_service.h" |
32 #include "chrome/browser/download/download_service_factory.h" | 34 #include "chrome/browser/download/download_service_factory.h" |
33 #include "chrome/browser/extensions/extension_resource_protocols.h" | 35 #include "chrome/browser/extensions/extension_resource_protocols.h" |
34 #include "chrome/browser/io_thread.h" | 36 #include "chrome/browser/io_thread.h" |
35 #include "chrome/browser/media/media_device_id_salt.h" | 37 #include "chrome/browser/media/media_device_id_salt.h" |
36 #include "chrome/browser/net/about_protocol_handler.h" | 38 #include "chrome/browser/net/about_protocol_handler.h" |
37 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
38 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
39 #include "chrome/browser/net/chrome_net_log.h" | 41 #include "chrome/browser/net/chrome_net_log.h" |
40 #include "chrome/browser/net/chrome_network_delegate.h" | 42 #include "chrome/browser/net/chrome_network_delegate.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 | 735 |
734 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | 736 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { |
735 DCHECK(initialized_); | 737 DCHECK(initialized_); |
736 return host_content_settings_map_.get(); | 738 return host_content_settings_map_.get(); |
737 } | 739 } |
738 | 740 |
739 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const { | 741 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const { |
740 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_); | 742 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_); |
741 } | 743 } |
742 | 744 |
| 745 void ProfileIOData::SetNetworkState( |
| 746 const std::string& client_id, bool offline) const { |
| 747 DCHECK(network_controller_); |
| 748 network_controller_->SetNetworkState(client_id, offline); |
| 749 } |
| 750 |
743 bool ProfileIOData::IsOffTheRecord() const { | 751 bool ProfileIOData::IsOffTheRecord() const { |
744 return profile_type() == Profile::INCOGNITO_PROFILE | 752 return profile_type() == Profile::INCOGNITO_PROFILE |
745 || profile_type() == Profile::GUEST_PROFILE; | 753 || profile_type() == Profile::GUEST_PROFILE; |
746 } | 754 } |
747 | 755 |
748 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { | 756 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { |
749 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 757 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
750 #if defined(OS_CHROMEOS) | 758 #if defined(OS_CHROMEOS) |
751 // Just fetch the value from ChromeOS' settings while we're on the UI thread. | 759 // Just fetch the value from ChromeOS' settings while we're on the UI thread. |
752 // TODO(stevet): For now, this value is only set on profile initialization. | 760 // TODO(stevet): For now, this value is only set on profile initialization. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 ContentSetting setting = content_settings->GetContentSetting( | 893 ContentSetting setting = content_settings->GetContentSetting( |
886 origin, origin, type, NO_RESOURCE_IDENTIFIER); | 894 origin, origin, type, NO_RESOURCE_IDENTIFIER); |
887 return setting == CONTENT_SETTING_ALLOW; | 895 return setting == CONTENT_SETTING_ALLOW; |
888 } | 896 } |
889 | 897 |
890 ResourceContext::SaltCallback | 898 ResourceContext::SaltCallback |
891 ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { | 899 ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { |
892 return io_data_->GetMediaDeviceIDSalt(); | 900 return io_data_->GetMediaDeviceIDSalt(); |
893 } | 901 } |
894 | 902 |
| 903 void ProfileIOData::ResourceContext::SetNetworkState( |
| 904 const std::string& client_id, |
| 905 bool offline) { |
| 906 io_data_->SetNetworkState(client_id, offline); |
| 907 } |
| 908 |
895 // static | 909 // static |
896 std::string ProfileIOData::GetSSLSessionCacheShard() { | 910 std::string ProfileIOData::GetSSLSessionCacheShard() { |
897 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 911 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
898 // The SSL session cache is partitioned by setting a string. This returns a | 912 // The SSL session cache is partitioned by setting a string. This returns a |
899 // unique string to partition the SSL session cache. Each time we create a | 913 // unique string to partition the SSL session cache. Each time we create a |
900 // new profile, we'll get a fresh SSL session cache which is separate from | 914 // new profile, we'll get a fresh SSL session cache which is separate from |
901 // the other profiles. | 915 // the other profiles. |
902 static unsigned ssl_session_cache_instance = 0; | 916 static unsigned ssl_session_cache_instance = 0; |
903 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 917 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
904 } | 918 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 | 1147 |
1134 void ProfileIOData::set_server_bound_cert_service( | 1148 void ProfileIOData::set_server_bound_cert_service( |
1135 net::ServerBoundCertService* server_bound_cert_service) const { | 1149 net::ServerBoundCertService* server_bound_cert_service) const { |
1136 server_bound_cert_service_.reset(server_bound_cert_service); | 1150 server_bound_cert_service_.reset(server_bound_cert_service); |
1137 } | 1151 } |
1138 | 1152 |
1139 void ProfileIOData::DestroyResourceContext() { | 1153 void ProfileIOData::DestroyResourceContext() { |
1140 resource_context_.reset(); | 1154 resource_context_.reset(); |
1141 } | 1155 } |
1142 | 1156 |
1143 void ProfileIOData::PopulateNetworkSessionParams( | 1157 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( |
1144 const ProfileParams* profile_params, | 1158 const ProfileParams* profile_params, |
1145 net::HttpNetworkSession::Params* params) const { | 1159 net::HttpCache::BackendFactory* main_backend) const { |
1146 | 1160 net::HttpNetworkSession::Params params; |
1147 ChromeURLRequestContext* context = main_request_context(); | 1161 ChromeURLRequestContext* context = main_request_context(); |
1148 | 1162 |
1149 IOThread* const io_thread = profile_params->io_thread; | 1163 IOThread* const io_thread = profile_params->io_thread; |
1150 | 1164 |
1151 io_thread->InitializeNetworkSessionParams(params); | 1165 io_thread->InitializeNetworkSessionParams(¶ms); |
1152 | 1166 |
1153 params->host_resolver = context->host_resolver(); | 1167 params.host_resolver = context->host_resolver(); |
1154 params->cert_verifier = context->cert_verifier(); | 1168 params.cert_verifier = context->cert_verifier(); |
1155 params->server_bound_cert_service = context->server_bound_cert_service(); | 1169 params.server_bound_cert_service = context->server_bound_cert_service(); |
1156 params->transport_security_state = context->transport_security_state(); | 1170 params.transport_security_state = context->transport_security_state(); |
1157 params->cert_transparency_verifier = context->cert_transparency_verifier(); | 1171 params.cert_transparency_verifier = context->cert_transparency_verifier(); |
1158 params->proxy_service = context->proxy_service(); | 1172 params.proxy_service = context->proxy_service(); |
1159 params->ssl_session_cache_shard = GetSSLSessionCacheShard(); | 1173 params.ssl_session_cache_shard = GetSSLSessionCacheShard(); |
1160 params->ssl_config_service = context->ssl_config_service(); | 1174 params.ssl_config_service = context->ssl_config_service(); |
1161 params->http_auth_handler_factory = context->http_auth_handler_factory(); | 1175 params.http_auth_handler_factory = context->http_auth_handler_factory(); |
1162 params->network_delegate = network_delegate(); | 1176 params.network_delegate = network_delegate(); |
1163 params->http_server_properties = context->http_server_properties(); | 1177 params.http_server_properties = context->http_server_properties(); |
1164 params->net_log = context->net_log(); | 1178 params.net_log = context->net_log(); |
| 1179 |
| 1180 network_controller_.reset(new DevToolsNetworkController()); |
| 1181 |
| 1182 net::HttpNetworkSession* session = new net::HttpNetworkSession(params); |
| 1183 return scoped_ptr<net::HttpCache>(new net::HttpCache( |
| 1184 new DevToolsNetworkTransactionFactory(network_controller_.get(), session), |
| 1185 context->net_log(), main_backend, true)); |
| 1186 } |
| 1187 |
| 1188 scoped_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory( |
| 1189 net::HttpNetworkSession* shared_session, |
| 1190 net::HttpCache::BackendFactory* backend) const { |
| 1191 return scoped_ptr<net::HttpCache>(new net::HttpCache( |
| 1192 new DevToolsNetworkTransactionFactory( |
| 1193 network_controller_.get(), shared_session), |
| 1194 shared_session->net_log(), backend, false)); |
1165 } | 1195 } |
1166 | 1196 |
1167 void ProfileIOData::SetCookieSettingsForTesting( | 1197 void ProfileIOData::SetCookieSettingsForTesting( |
1168 CookieSettings* cookie_settings) { | 1198 CookieSettings* cookie_settings) { |
1169 DCHECK(!cookie_settings_.get()); | 1199 DCHECK(!cookie_settings_.get()); |
1170 cookie_settings_ = cookie_settings; | 1200 cookie_settings_ = cookie_settings; |
1171 } | 1201 } |
1172 | 1202 |
1173 void ProfileIOData::set_signin_names_for_testing( | 1203 void ProfileIOData::set_signin_names_for_testing( |
1174 SigninNamesOnIOThread* signin_names) { | 1204 SigninNamesOnIOThread* signin_names) { |
1175 signin_names_.reset(signin_names); | 1205 signin_names_.reset(signin_names); |
1176 } | 1206 } |
OLD | NEW |