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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 486 } |
481 } | 487 } |
482 #endif | 488 #endif |
483 | 489 |
484 incognito_availibility_pref_.Init( | 490 incognito_availibility_pref_.Init( |
485 prefs::kIncognitoModeAvailability, pref_service); | 491 prefs::kIncognitoModeAvailability, pref_service); |
486 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); | 492 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); |
487 | 493 |
488 initialized_on_UI_thread_ = true; | 494 initialized_on_UI_thread_ = true; |
489 | 495 |
490 #if defined(OS_ANDROID) | |
491 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
492 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 496 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
493 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread, | 497 base::Bind(&ProfileIOData::SetupDataReductionProxyOnIOThread, |
494 base::Unretained(this), g_browser_process->io_thread(), profile)); | 498 base::Unretained(this), g_browser_process->io_thread(), profile)); |
495 #endif | |
496 #endif | |
497 | 499 |
498 // We need to make sure that content initializes its own data structures that | 500 // We need to make sure that content initializes its own data structures that |
499 // are associated with each ResourceContext because we might post this | 501 // are associated with each ResourceContext because we might post this |
500 // object to the IO thread after this function. | 502 // object to the IO thread after this function. |
501 BrowserContext::EnsureResourceContextInitialized(profile); | 503 BrowserContext::EnsureResourceContextInitialized(profile); |
502 } | 504 } |
503 | 505 |
504 #if defined(OS_ANDROID) | 506 void ProfileIOData::SetupDataReductionProxyOnIOThread( |
505 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
506 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( | |
507 IOThread* io_thread, Profile* profile) { | 507 IOThread* io_thread, Profile* profile) { |
508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
509 IOThread::Globals* globals = io_thread->globals(); | 509 IOThread::Globals* globals = io_thread->globals(); |
| 510 DataReductionProxyParams* params = globals->data_reduction_proxy_params.get(); |
510 DataReductionProxyUsageStats* usage_stats = | 511 DataReductionProxyUsageStats* usage_stats = |
511 globals->data_reduction_proxy_usage_stats.get(); | 512 globals->data_reduction_proxy_usage_stats.get(); |
512 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 513 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
513 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread, | 514 base::Bind(&ProfileIOData::SetupDataReductionProxyOnUIThread, |
514 base::Unretained(this), profile, usage_stats)); | 515 base::Unretained(this), profile, params, usage_stats)); |
515 } | 516 } |
516 | 517 |
517 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread( | 518 void ProfileIOData::SetupDataReductionProxyOnUIThread( |
518 Profile* profile, | 519 Profile* profile, |
| 520 DataReductionProxyParams* params, |
519 DataReductionProxyUsageStats* usage_stats) { | 521 DataReductionProxyUsageStats* usage_stats) { |
520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
521 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { | 523 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { |
| 524 // TODO(kundaji): Combine code to initialize DRP on different platforms. |
| 525 #if defined(OS_ANDROID) |
522 DataReductionProxySettingsAndroid* proxySettingsAndroid = | 526 DataReductionProxySettingsAndroid* proxySettingsAndroid = |
523 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); | 527 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); |
524 if (proxySettingsAndroid) | 528 if (proxySettingsAndroid) |
525 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); | 529 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); |
| 530 #elif !defined(OS_IOS) |
| 531 data_reduction_proxy_settings_.reset( |
| 532 new DataReductionProxySettings(params)); |
| 533 data_reduction_proxy_settings_->SetDataReductionProxyUsageStats( |
| 534 usage_stats); |
| 535 PrefService* prefs = profile->GetPrefs(); |
| 536 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
| 537 configurator(new DataReductionProxyChromeConfigurator(prefs)); |
| 538 data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass()); |
| 539 data_reduction_proxy_settings_->InitDataReductionProxySettings(prefs, |
| 540 g_browser_process->local_state(), |
| 541 ProfileManager::GetActiveUserProfile()->GetRequestContext()); |
| 542 #endif |
526 } | 543 } |
527 } | 544 } |
528 #endif | |
529 #endif | |
530 | 545 |
531 ProfileIOData::MediaRequestContext::MediaRequestContext() { | 546 ProfileIOData::MediaRequestContext::MediaRequestContext() { |
532 } | 547 } |
533 | 548 |
534 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( | 549 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( |
535 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 550 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
536 http_factory_ = http_factory.Pass(); | 551 http_factory_ = http_factory.Pass(); |
537 set_http_transaction_factory(http_factory_.get()); | 552 set_http_transaction_factory(http_factory_.get()); |
538 } | 553 } |
539 | 554 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 // NOTE: Proxy service uses the default io thread network delegate, not the | 1037 // NOTE: Proxy service uses the default io thread network delegate, not the |
1023 // delegate just created. | 1038 // delegate just created. |
1024 proxy_service_.reset( | 1039 proxy_service_.reset( |
1025 ProxyServiceFactory::CreateProxyService( | 1040 ProxyServiceFactory::CreateProxyService( |
1026 io_thread->net_log(), | 1041 io_thread->net_log(), |
1027 io_thread_globals->proxy_script_fetcher_context.get(), | 1042 io_thread_globals->proxy_script_fetcher_context.get(), |
1028 io_thread_globals->system_network_delegate.get(), | 1043 io_thread_globals->system_network_delegate.get(), |
1029 profile_params_->proxy_config_service.release(), | 1044 profile_params_->proxy_config_service.release(), |
1030 command_line, | 1045 command_line, |
1031 quick_check_enabled_.GetValue())); | 1046 quick_check_enabled_.GetValue())); |
| 1047 DCHECK(io_thread_globals->data_reduction_proxy_params); |
| 1048 proxy_service_->SetDataReductionProxyOrigins( |
| 1049 io_thread_globals->data_reduction_proxy_params->GetDefaultOrigin(), |
| 1050 io_thread_globals->data_reduction_proxy_params-> |
| 1051 GetDefaultFallbackOrigin()); |
1032 | 1052 |
1033 transport_security_state_.reset(new net::TransportSecurityState()); | 1053 transport_security_state_.reset(new net::TransportSecurityState()); |
1034 transport_security_persister_.reset( | 1054 transport_security_persister_.reset( |
1035 new net::TransportSecurityPersister( | 1055 new net::TransportSecurityPersister( |
1036 transport_security_state_.get(), | 1056 transport_security_state_.get(), |
1037 profile_params_->path, | 1057 profile_params_->path, |
1038 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 1058 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
1039 IsOffTheRecord())); | 1059 IsOffTheRecord())); |
1040 | 1060 |
1041 // Take ownership over these parameters. | 1061 // Take ownership over these parameters. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 void ProfileIOData::SetCookieSettingsForTesting( | 1271 void ProfileIOData::SetCookieSettingsForTesting( |
1252 CookieSettings* cookie_settings) { | 1272 CookieSettings* cookie_settings) { |
1253 DCHECK(!cookie_settings_.get()); | 1273 DCHECK(!cookie_settings_.get()); |
1254 cookie_settings_ = cookie_settings; | 1274 cookie_settings_ = cookie_settings; |
1255 } | 1275 } |
1256 | 1276 |
1257 void ProfileIOData::set_signin_names_for_testing( | 1277 void ProfileIOData::set_signin_names_for_testing( |
1258 SigninNamesOnIOThread* signin_names) { | 1278 SigninNamesOnIOThread* signin_names) { |
1259 signin_names_.reset(signin_names); | 1279 signin_names_.reset(signin_names); |
1260 } | 1280 } |
OLD | NEW |