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 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/extensions/extension_resource_protocols.h" | 35 #include "chrome/browser/extensions/extension_resource_protocols.h" |
36 #include "chrome/browser/io_thread.h" | 36 #include "chrome/browser/io_thread.h" |
37 #include "chrome/browser/media/media_device_id_salt.h" | 37 #include "chrome/browser/media/media_device_id_salt.h" |
38 #include "chrome/browser/net/about_protocol_handler.h" | 38 #include "chrome/browser/net/about_protocol_handler.h" |
39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
41 #include "chrome/browser/net/chrome_net_log.h" | 41 #include "chrome/browser/net/chrome_net_log.h" |
42 #include "chrome/browser/net/chrome_network_delegate.h" | 42 #include "chrome/browser/net/chrome_network_delegate.h" |
43 #include "chrome/browser/net/cookie_store_util.h" | 43 #include "chrome/browser/net/cookie_store_util.h" |
44 #include "chrome/browser/net/proxy_service_factory.h" | 44 #include "chrome/browser/net/proxy_service_factory.h" |
| 45 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
45 #include "chrome/browser/profiles/profile.h" | 46 #include "chrome/browser/profiles/profile.h" |
46 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
47 #include "chrome/browser/signin/signin_names_io_thread.h" | 48 #include "chrome/browser/signin/signin_names_io_thread.h" |
48 #include "chrome/common/chrome_paths.h" | 49 #include "chrome/common/chrome_paths.h" |
49 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
50 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
51 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
| 53 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se
rvice.h" |
| 54 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" |
| 55 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
52 #include "components/startup_metric_utils/startup_metric_utils.h" | 56 #include "components/startup_metric_utils/startup_metric_utils.h" |
53 #include "components/sync_driver/pref_names.h" | 57 #include "components/sync_driver/pref_names.h" |
54 #include "components/url_fixer/url_fixer.h" | 58 #include "components/url_fixer/url_fixer.h" |
55 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
56 #include "content/public/browser/host_zoom_map.h" | 60 #include "content/public/browser/host_zoom_map.h" |
57 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
58 #include "content/public/browser/resource_context.h" | 62 #include "content/public/browser/resource_context.h" |
59 #include "extensions/browser/extension_protocols.h" | 63 #include "extensions/browser/extension_protocols.h" |
60 #include "extensions/browser/extension_system.h" | 64 #include "extensions/browser/extension_system.h" |
61 #include "extensions/browser/info_map.h" | 65 #include "extensions/browser/info_map.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 #include "net/ssl/client_cert_store_win.h" | 132 #include "net/ssl/client_cert_store_win.h" |
129 #endif | 133 #endif |
130 | 134 |
131 #if defined(OS_MACOSX) | 135 #if defined(OS_MACOSX) |
132 #include "net/ssl/client_cert_store_mac.h" | 136 #include "net/ssl/client_cert_store_mac.h" |
133 #endif | 137 #endif |
134 | 138 |
135 using content::BrowserContext; | 139 using content::BrowserContext; |
136 using content::BrowserThread; | 140 using content::BrowserThread; |
137 using content::ResourceContext; | 141 using content::ResourceContext; |
| 142 using data_reduction_proxy::DataReductionProxyParams; |
| 143 using data_reduction_proxy::DataReductionProxySettings; |
138 using data_reduction_proxy::DataReductionProxyUsageStats; | 144 using data_reduction_proxy::DataReductionProxyUsageStats; |
139 | 145 |
140 namespace { | 146 namespace { |
141 | 147 |
142 #if defined(DEBUG_DEVTOOLS) | 148 #if defined(DEBUG_DEVTOOLS) |
143 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { | 149 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { |
144 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); | 150 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); |
145 bundled_path_prefix = "/" + bundled_path_prefix + "/"; | 151 bundled_path_prefix = "/" + bundled_path_prefix + "/"; |
146 | 152 |
147 if (!url.SchemeIs(content::kChromeDevToolsScheme) || | 153 if (!url.SchemeIs(content::kChromeDevToolsScheme) || |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 485 } |
480 } | 486 } |
481 #endif | 487 #endif |
482 | 488 |
483 incognito_availibility_pref_.Init( | 489 incognito_availibility_pref_.Init( |
484 prefs::kIncognitoModeAvailability, pref_service); | 490 prefs::kIncognitoModeAvailability, pref_service); |
485 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); | 491 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); |
486 | 492 |
487 initialized_on_UI_thread_ = true; | 493 initialized_on_UI_thread_ = true; |
488 | 494 |
489 #if defined(OS_ANDROID) | |
490 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
491 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 495 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
492 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread, | 496 base::Bind(&ProfileIOData::SetupDataReductionProxyOnIOThread, |
493 base::Unretained(this), g_browser_process->io_thread(), profile)); | 497 base::Unretained(this), g_browser_process->io_thread(), profile)); |
494 #endif | |
495 #endif | |
496 | 498 |
497 // We need to make sure that content initializes its own data structures that | 499 // We need to make sure that content initializes its own data structures that |
498 // are associated with each ResourceContext because we might post this | 500 // are associated with each ResourceContext because we might post this |
499 // object to the IO thread after this function. | 501 // object to the IO thread after this function. |
500 BrowserContext::EnsureResourceContextInitialized(profile); | 502 BrowserContext::EnsureResourceContextInitialized(profile); |
501 } | 503 } |
502 | 504 |
503 #if defined(OS_ANDROID) | 505 void ProfileIOData::SetupDataReductionProxyOnIOThread( |
504 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
505 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( | |
506 IOThread* io_thread, Profile* profile) { | 506 IOThread* io_thread, Profile* profile) { |
507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
508 IOThread::Globals* globals = io_thread->globals(); | 508 IOThread::Globals* globals = io_thread->globals(); |
| 509 DataReductionProxyParams* params = globals->data_reduction_proxy_params.get(); |
509 DataReductionProxyUsageStats* usage_stats = | 510 DataReductionProxyUsageStats* usage_stats = |
510 globals->data_reduction_proxy_usage_stats.get(); | 511 globals->data_reduction_proxy_usage_stats.get(); |
511 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 512 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
512 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread, | 513 base::Bind(&ProfileIOData::SetupDataReductionProxyOnUIThread, |
513 base::Unretained(this), profile, usage_stats)); | 514 base::Unretained(this), profile, params, usage_stats)); |
514 } | 515 } |
515 | 516 |
516 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread( | 517 void ProfileIOData::SetupDataReductionProxyOnUIThread( |
517 Profile* profile, | 518 Profile* profile, |
| 519 DataReductionProxyParams* params, |
518 DataReductionProxyUsageStats* usage_stats) { | 520 DataReductionProxyUsageStats* usage_stats) { |
519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
520 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { | 522 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { |
| 523 // TODO(kundaji): Combine code to initialize DRP on different platforms. |
| 524 #if defined(OS_ANDROID) |
521 DataReductionProxySettingsAndroid* proxySettingsAndroid = | 525 DataReductionProxySettingsAndroid* proxySettingsAndroid = |
522 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); | 526 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); |
523 if (proxySettingsAndroid) | 527 if (proxySettingsAndroid) |
524 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); | 528 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); |
| 529 #elif !defined(OS_IOS) |
| 530 data_reduction_proxy_settings_.reset( |
| 531 new DataReductionProxySettings(params)); |
| 532 data_reduction_proxy_settings_->SetDataReductionProxyUsageStats( |
| 533 usage_stats); |
| 534 PrefService* prefs = profile->GetPrefs(); |
| 535 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
| 536 configurator(new DataReductionProxyChromeConfigurator(prefs)); |
| 537 data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass()); |
| 538 data_reduction_proxy_settings_->InitDataReductionProxySettings(prefs, |
| 539 g_browser_process->local_state(), |
| 540 ProfileManager::GetActiveUserProfile()->GetRequestContext()); |
| 541 #endif |
525 } | 542 } |
526 } | 543 } |
527 #endif | |
528 #endif | |
529 | 544 |
530 ProfileIOData::MediaRequestContext::MediaRequestContext() { | 545 ProfileIOData::MediaRequestContext::MediaRequestContext() { |
531 } | 546 } |
532 | 547 |
533 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( | 548 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( |
534 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 549 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
535 http_factory_ = http_factory.Pass(); | 550 http_factory_ = http_factory.Pass(); |
536 set_http_transaction_factory(http_factory_.get()); | 551 set_http_transaction_factory(http_factory_.get()); |
537 } | 552 } |
538 | 553 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 // NOTE: Proxy service uses the default io thread network delegate, not the | 1036 // NOTE: Proxy service uses the default io thread network delegate, not the |
1022 // delegate just created. | 1037 // delegate just created. |
1023 proxy_service_.reset( | 1038 proxy_service_.reset( |
1024 ProxyServiceFactory::CreateProxyService( | 1039 ProxyServiceFactory::CreateProxyService( |
1025 io_thread->net_log(), | 1040 io_thread->net_log(), |
1026 io_thread_globals->proxy_script_fetcher_context.get(), | 1041 io_thread_globals->proxy_script_fetcher_context.get(), |
1027 io_thread_globals->system_network_delegate.get(), | 1042 io_thread_globals->system_network_delegate.get(), |
1028 profile_params_->proxy_config_service.release(), | 1043 profile_params_->proxy_config_service.release(), |
1029 command_line, | 1044 command_line, |
1030 quick_check_enabled_.GetValue())); | 1045 quick_check_enabled_.GetValue())); |
| 1046 DCHECK(io_thread_globals->data_reduction_proxy_params); |
| 1047 proxy_service_->SetDataReductionProxyOrigins( |
| 1048 io_thread_globals->data_reduction_proxy_params->GetDefaultOrigin(), |
| 1049 io_thread_globals->data_reduction_proxy_params-> |
| 1050 GetDefaultFallbackOrigin()); |
1031 | 1051 |
1032 transport_security_state_.reset(new net::TransportSecurityState()); | 1052 transport_security_state_.reset(new net::TransportSecurityState()); |
1033 transport_security_persister_.reset( | 1053 transport_security_persister_.reset( |
1034 new net::TransportSecurityPersister( | 1054 new net::TransportSecurityPersister( |
1035 transport_security_state_.get(), | 1055 transport_security_state_.get(), |
1036 profile_params_->path, | 1056 profile_params_->path, |
1037 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 1057 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
1038 IsOffTheRecord())); | 1058 IsOffTheRecord())); |
1039 | 1059 |
1040 // Take ownership over these parameters. | 1060 // Take ownership over these parameters. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 void ProfileIOData::SetCookieSettingsForTesting( | 1270 void ProfileIOData::SetCookieSettingsForTesting( |
1251 CookieSettings* cookie_settings) { | 1271 CookieSettings* cookie_settings) { |
1252 DCHECK(!cookie_settings_.get()); | 1272 DCHECK(!cookie_settings_.get()); |
1253 cookie_settings_ = cookie_settings; | 1273 cookie_settings_ = cookie_settings; |
1254 } | 1274 } |
1255 | 1275 |
1256 void ProfileIOData::set_signin_names_for_testing( | 1276 void ProfileIOData::set_signin_names_for_testing( |
1257 SigninNamesOnIOThread* signin_names) { | 1277 SigninNamesOnIOThread* signin_names) { |
1258 signin_names_.reset(signin_names); | 1278 signin_names_.reset(signin_names); |
1259 } | 1279 } |
OLD | NEW |