| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "net/cookies/canonical_cookie.h" | 62 #include "net/cookies/canonical_cookie.h" |
| 63 #include "net/cookies/cookie_monster.h" | 63 #include "net/cookies/cookie_monster.h" |
| 64 #include "net/http/http_transaction_factory.h" | 64 #include "net/http/http_transaction_factory.h" |
| 65 #include "net/http/http_util.h" | 65 #include "net/http/http_util.h" |
| 66 #include "net/proxy/proxy_config_service_fixed.h" | 66 #include "net/proxy/proxy_config_service_fixed.h" |
| 67 #include "net/proxy/proxy_script_fetcher_impl.h" | 67 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 68 #include "net/proxy/proxy_service.h" | 68 #include "net/proxy/proxy_service.h" |
| 69 #include "net/url_request/data_protocol_handler.h" | 69 #include "net/url_request/data_protocol_handler.h" |
| 70 #include "net/url_request/file_protocol_handler.h" | 70 #include "net/url_request/file_protocol_handler.h" |
| 71 #include "net/url_request/ftp_protocol_handler.h" | 71 #include "net/url_request/ftp_protocol_handler.h" |
| 72 #include "net/url_request/protocol_intercept_job_factory.h" |
| 72 #include "net/url_request/url_request.h" | 73 #include "net/url_request/url_request.h" |
| 73 #include "net/url_request/url_request_file_job.h" | 74 #include "net/url_request/url_request_file_job.h" |
| 74 #include "net/url_request/url_request_job_factory_impl.h" | 75 #include "net/url_request/url_request_job_factory_impl.h" |
| 75 | 76 |
| 76 #if defined(ENABLE_MANAGED_USERS) | 77 #if defined(ENABLE_MANAGED_USERS) |
| 77 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 78 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
| 78 #include "chrome/browser/managed_mode/managed_user_service.h" | 79 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 79 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 80 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 80 #endif | 81 #endif |
| 81 | 82 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (!PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) | 182 if (!PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) |
| 182 return false; | 183 return false; |
| 183 | 184 |
| 184 if (inspector_dir.empty()) | 185 if (inspector_dir.empty()) |
| 185 return false; | 186 return false; |
| 186 | 187 |
| 187 *path = inspector_dir.AppendASCII(relative_path); | 188 *path = inspector_dir.AppendASCII(relative_path); |
| 188 return true; | 189 return true; |
| 189 } | 190 } |
| 190 | 191 |
| 191 class DebugDevToolsInterceptor : public net::URLRequestJobFactory::Interceptor { | 192 class DebugDevToolsInterceptor |
| 193 : public net::URLRequestJobFactory::ProtocolHandler { |
| 192 public: | 194 public: |
| 193 DebugDevToolsInterceptor() {} | 195 DebugDevToolsInterceptor() {} |
| 194 virtual ~DebugDevToolsInterceptor() {} | 196 virtual ~DebugDevToolsInterceptor() {} |
| 195 | 197 |
| 196 virtual net::URLRequestJob* MaybeIntercept( | 198 virtual net::URLRequestJob* MaybeCreateJob( |
| 197 net::URLRequest* request, | 199 net::URLRequest* request, |
| 198 net::NetworkDelegate* network_delegate) const OVERRIDE { | 200 net::NetworkDelegate* network_delegate) const OVERRIDE { |
| 199 FilePath path; | 201 FilePath path; |
| 200 if (IsSupportedDevToolsURL(request->url(), &path)) | 202 if (IsSupportedDevToolsURL(request->url(), &path)) |
| 201 return new net::URLRequestFileJob(request, network_delegate, path); | 203 return new net::URLRequestFileJob(request, network_delegate, path); |
| 202 | 204 |
| 203 return NULL; | 205 return NULL; |
| 204 } | 206 } |
| 205 | |
| 206 virtual net::URLRequestJob* MaybeInterceptRedirect( | |
| 207 const GURL& location, | |
| 208 net::URLRequest* request, | |
| 209 net::NetworkDelegate* network_delegate) const OVERRIDE { | |
| 210 return NULL; | |
| 211 } | |
| 212 | |
| 213 virtual net::URLRequestJob* MaybeInterceptResponse( | |
| 214 net::URLRequest* request, | |
| 215 net::NetworkDelegate* network_delegate) const OVERRIDE { | |
| 216 return NULL; | |
| 217 } | |
| 218 | |
| 219 virtual bool WillHandleProtocol(const std::string& protocol) const { | |
| 220 return protocol == chrome::kChromeDevToolsScheme; | |
| 221 } | |
| 222 }; | 207 }; |
| 223 #endif // defined(DEBUG_DEVTOOLS) | 208 #endif // defined(DEBUG_DEVTOOLS) |
| 224 | 209 |
| 225 } // namespace | 210 } // namespace |
| 226 | 211 |
| 227 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 212 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 229 PrefService* pref_service = profile->GetPrefs(); | 214 PrefService* pref_service = profile->GetPrefs(); |
| 230 PrefService* local_state_pref_service = g_browser_process->local_state(); | 215 PrefService* local_state_pref_service = g_browser_process->local_state(); |
| 231 | 216 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 chrome::kAboutScheme, | 743 chrome::kAboutScheme, |
| 759 new chrome_browser_net::AboutProtocolHandler()); | 744 new chrome_browser_net::AboutProtocolHandler()); |
| 760 #if !defined(DISABLE_FTP_SUPPORT) | 745 #if !defined(DISABLE_FTP_SUPPORT) |
| 761 DCHECK(ftp_transaction_factory); | 746 DCHECK(ftp_transaction_factory); |
| 762 job_factory->SetProtocolHandler( | 747 job_factory->SetProtocolHandler( |
| 763 chrome::kFtpScheme, | 748 chrome::kFtpScheme, |
| 764 new net::FtpProtocolHandler(ftp_transaction_factory, | 749 new net::FtpProtocolHandler(ftp_transaction_factory, |
| 765 ftp_auth_cache)); | 750 ftp_auth_cache)); |
| 766 #endif // !defined(DISABLE_FTP_SUPPORT) | 751 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 767 | 752 |
| 753 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
| 754 job_factory.PassAs<net::URLRequestJobFactory>(); |
| 768 #if defined(DEBUG_DEVTOOLS) | 755 #if defined(DEBUG_DEVTOOLS) |
| 769 job_factory->AddInterceptor(new DebugDevToolsInterceptor()); | 756 top_job_factory.reset(new net::ProtocolInterceptJobFactory( |
| 757 top_job_factory.Pass(), |
| 758 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 759 new DebugDevToolsInterceptor))); |
| 770 #endif | 760 #endif |
| 771 | 761 |
| 772 if (protocol_handler_interceptor) { | 762 if (protocol_handler_interceptor) { |
| 773 protocol_handler_interceptor->Chain( | 763 protocol_handler_interceptor->Chain(top_job_factory.Pass()); |
| 774 job_factory.PassAs<net::URLRequestJobFactory>()); | |
| 775 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); | 764 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); |
| 776 } else { | 765 } else { |
| 777 return job_factory.PassAs<net::URLRequestJobFactory>(); | 766 return top_job_factory.Pass(); |
| 778 } | 767 } |
| 779 } | 768 } |
| 780 | 769 |
| 781 void ProfileIOData::ShutdownOnUIThread() { | 770 void ProfileIOData::ShutdownOnUIThread() { |
| 782 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 771 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 783 | 772 |
| 784 if (signin_names_) | 773 if (signin_names_) |
| 785 signin_names_->ReleaseResourcesOnUIThread(); | 774 signin_names_->ReleaseResourcesOnUIThread(); |
| 786 | 775 |
| 787 google_services_username_.Destroy(); | 776 google_services_username_.Destroy(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 void ProfileIOData::SetCookieSettingsForTesting( | 833 void ProfileIOData::SetCookieSettingsForTesting( |
| 845 CookieSettings* cookie_settings) { | 834 CookieSettings* cookie_settings) { |
| 846 DCHECK(!cookie_settings_.get()); | 835 DCHECK(!cookie_settings_.get()); |
| 847 cookie_settings_ = cookie_settings; | 836 cookie_settings_ = cookie_settings; |
| 848 } | 837 } |
| 849 | 838 |
| 850 void ProfileIOData::set_signin_names_for_testing( | 839 void ProfileIOData::set_signin_names_for_testing( |
| 851 SigninNamesOnIOThread* signin_names) { | 840 SigninNamesOnIOThread* signin_names) { |
| 852 signin_names_.reset(signin_names); | 841 signin_names_.reset(signin_names); |
| 853 } | 842 } |
| OLD | NEW |