Chromium Code Reviews| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 } | 483 } |
| 478 } | 484 } |
| 479 #endif | 485 #endif |
| 480 | 486 |
| 481 incognito_availibility_pref_.Init( | 487 incognito_availibility_pref_.Init( |
| 482 prefs::kIncognitoModeAvailability, pref_service); | 488 prefs::kIncognitoModeAvailability, pref_service); |
| 483 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); | 489 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); |
| 484 | 490 |
| 485 initialized_on_UI_thread_ = true; | 491 initialized_on_UI_thread_ = true; |
| 486 | 492 |
| 487 #if defined(OS_ANDROID) | |
| 488 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 489 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 493 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 490 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread, | 494 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread, |
| 491 base::Unretained(this), g_browser_process->io_thread(), profile)); | 495 base::Unretained(this), g_browser_process->io_thread(), profile)); |
| 492 #endif | |
| 493 #endif | |
| 494 | 496 |
| 495 // We need to make sure that content initializes its own data structures that | 497 // We need to make sure that content initializes its own data structures that |
| 496 // are associated with each ResourceContext because we might post this | 498 // are associated with each ResourceContext because we might post this |
| 497 // object to the IO thread after this function. | 499 // object to the IO thread after this function. |
| 498 BrowserContext::EnsureResourceContextInitialized(profile); | 500 BrowserContext::EnsureResourceContextInitialized(profile); |
| 499 } | 501 } |
| 500 | 502 |
| 501 #if defined(OS_ANDROID) | |
| 502 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 503 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( | 503 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( |
| 504 IOThread* io_thread, Profile* profile) { | 504 IOThread* io_thread, Profile* profile) { |
| 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 506 IOThread::Globals* globals = io_thread->globals(); | 506 IOThread::Globals* globals = io_thread->globals(); |
| 507 DataReductionProxyUsageStats* usage_stats = | 507 DataReductionProxyUsageStats* usage_stats = |
| 508 globals->data_reduction_proxy_usage_stats.get(); | 508 globals->data_reduction_proxy_usage_stats.get(); |
| 509 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 509 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 510 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread, | 510 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread, |
| 511 base::Unretained(this), profile, usage_stats)); | 511 base::Unretained(this), profile, usage_stats)); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread( | 514 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread( |
| 515 Profile* profile, | 515 Profile* profile, |
| 516 DataReductionProxyUsageStats* usage_stats) { | 516 DataReductionProxyUsageStats* usage_stats) { |
| 517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 518 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { | 518 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { |
| 519 #if defined(OS_ANDROID) | |
|
bengr
2014/07/11 20:42:53
I think we need an API for initializing the proxy
Not at Google. Contact bengr
2014/07/16 22:41:33
Done.
| |
| 519 DataReductionProxySettingsAndroid* proxySettingsAndroid = | 520 DataReductionProxySettingsAndroid* proxySettingsAndroid = |
| 520 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); | 521 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); |
| 521 if (proxySettingsAndroid) | 522 if (proxySettingsAndroid) |
| 522 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); | 523 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); |
| 524 #else | |
| 525 | |
| 526 int flags = DataReductionProxyParams::kFallbackAllowed | | |
| 527 DataReductionProxyParams::kAllowed; | |
| 528 | |
| 529 DataReductionProxySettings* proxySettings = | |
| 530 new DataReductionProxySettings(new DataReductionProxyParams(flags)); | |
| 531 proxySettings->SetDataReductionProxyUsageStats(usage_stats); | |
| 532 | |
| 533 PrefService* prefs = profile->GetPrefs(); | |
| 534 | |
| 535 | |
| 536 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> | |
| 537 configurator(new DataReductionProxyChromeConfigurator(prefs)); | |
| 538 proxySettings->SetProxyConfigurator(configurator.Pass()); | |
| 539 | |
| 540 | |
| 541 | |
| 542 proxySettings->InitDataReductionProxySettings(prefs, | |
| 543 g_browser_process->local_state(), | |
| 544 ProfileManager::GetActiveUserProfile()->GetRequestContext()); | |
| 545 proxySettings->SetDataReductionProxyEnabled(true); | |
|
bengr
2014/07/11 20:42:53
Obviously, this must be removed and hooked to UI.
Not at Google. Contact bengr
2014/07/16 22:41:33
Removed
| |
| 546 | |
| 547 #endif | |
| 548 | |
| 523 } | 549 } |
| 524 } | 550 } |
| 525 #endif | |
| 526 #endif | |
| 527 | 551 |
| 528 ProfileIOData::MediaRequestContext::MediaRequestContext() { | 552 ProfileIOData::MediaRequestContext::MediaRequestContext() { |
| 529 } | 553 } |
| 530 | 554 |
| 531 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( | 555 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( |
| 532 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 556 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
| 533 http_factory_ = http_factory.Pass(); | 557 http_factory_ = http_factory.Pass(); |
| 534 set_http_transaction_factory(http_factory_.get()); | 558 set_http_transaction_factory(http_factory_.get()); |
| 535 } | 559 } |
| 536 | 560 |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 void ProfileIOData::SetCookieSettingsForTesting( | 1272 void ProfileIOData::SetCookieSettingsForTesting( |
| 1249 CookieSettings* cookie_settings) { | 1273 CookieSettings* cookie_settings) { |
| 1250 DCHECK(!cookie_settings_.get()); | 1274 DCHECK(!cookie_settings_.get()); |
| 1251 cookie_settings_ = cookie_settings; | 1275 cookie_settings_ = cookie_settings; |
| 1252 } | 1276 } |
| 1253 | 1277 |
| 1254 void ProfileIOData::set_signin_names_for_testing( | 1278 void ProfileIOData::set_signin_names_for_testing( |
| 1255 SigninNamesOnIOThread* signin_names) { | 1279 SigninNamesOnIOThread* signin_names) { |
| 1256 signin_names_.reset(signin_names); | 1280 signin_names_.reset(signin_names); |
| 1257 } | 1281 } |
| OLD | NEW |