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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (!PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) | 181 if (!PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) |
182 return false; | 182 return false; |
183 | 183 |
184 if (inspector_dir.empty()) | 184 if (inspector_dir.empty()) |
185 return false; | 185 return false; |
186 | 186 |
187 *path = inspector_dir.AppendASCII(relative_path); | 187 *path = inspector_dir.AppendASCII(relative_path); |
188 return true; | 188 return true; |
189 } | 189 } |
190 | 190 |
191 class DebugDevToolsInterceptor : public net::URLRequestJobFactory::Interceptor { | 191 class DebugDevToolsInterceptor |
| 192 : public net::URLRequestJobFactory::ProtocolHandler { |
192 public: | 193 public: |
193 DebugDevToolsInterceptor() {} | 194 DebugDevToolsInterceptor() {} |
194 virtual ~DebugDevToolsInterceptor() {} | 195 virtual ~DebugDevToolsInterceptor() {} |
195 | 196 |
196 virtual net::URLRequestJob* MaybeIntercept( | 197 virtual net::URLRequestJob* MaybeCreateJob( |
197 net::URLRequest* request, | 198 net::URLRequest* request, |
198 net::NetworkDelegate* network_delegate) const OVERRIDE { | 199 net::NetworkDelegate* network_delegate) const OVERRIDE { |
199 FilePath path; | 200 FilePath path; |
200 if (IsSupportedDevToolsURL(request->url(), &path)) | 201 if (IsSupportedDevToolsURL(request->url(), &path)) |
201 return new net::URLRequestFileJob(request, network_delegate, path); | 202 return new net::URLRequestFileJob(request, network_delegate, path); |
202 | 203 |
203 return NULL; | 204 return NULL; |
204 } | 205 } |
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 }; | 206 }; |
223 #endif // defined(DEBUG_DEVTOOLS) | 207 #endif // defined(DEBUG_DEVTOOLS) |
224 | 208 |
225 } // namespace | 209 } // namespace |
226 | 210 |
227 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 211 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
229 PrefService* pref_service = profile->GetPrefs(); | 213 PrefService* pref_service = profile->GetPrefs(); |
230 PrefService* local_state_pref_service = g_browser_process->local_state(); | 214 PrefService* local_state_pref_service = g_browser_process->local_state(); |
231 | 215 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 chrome::kAboutScheme, | 742 chrome::kAboutScheme, |
759 new chrome_browser_net::AboutProtocolHandler()); | 743 new chrome_browser_net::AboutProtocolHandler()); |
760 #if !defined(DISABLE_FTP_SUPPORT) | 744 #if !defined(DISABLE_FTP_SUPPORT) |
761 DCHECK(ftp_transaction_factory); | 745 DCHECK(ftp_transaction_factory); |
762 job_factory->SetProtocolHandler( | 746 job_factory->SetProtocolHandler( |
763 chrome::kFtpScheme, | 747 chrome::kFtpScheme, |
764 new net::FtpProtocolHandler(ftp_transaction_factory, | 748 new net::FtpProtocolHandler(ftp_transaction_factory, |
765 ftp_auth_cache)); | 749 ftp_auth_cache)); |
766 #endif // !defined(DISABLE_FTP_SUPPORT) | 750 #endif // !defined(DISABLE_FTP_SUPPORT) |
767 | 751 |
| 752 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
| 753 job_factory.PassAs<net::URLRequestJobFactory>(); |
768 #if defined(DEBUG_DEVTOOLS) | 754 #if defined(DEBUG_DEVTOOLS) |
769 job_factory->AddInterceptor(new DebugDevToolsInterceptor()); | 755 top_job_factory.reset(new net::ProtocolInterceptJobFactory( |
| 756 top_job_factory.Pass(), |
| 757 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 758 new DebugDevToolsInterceptor))); |
770 #endif | 759 #endif |
771 | 760 |
772 if (protocol_handler_interceptor) { | 761 if (protocol_handler_interceptor) { |
773 protocol_handler_interceptor->Chain( | 762 protocol_handler_interceptor->Chain(top_job_factory.Pass()); |
774 job_factory.PassAs<net::URLRequestJobFactory>()); | |
775 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); | 763 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); |
776 } else { | 764 } else { |
777 return job_factory.PassAs<net::URLRequestJobFactory>(); | 765 return top_job_factory.Pass(); |
778 } | 766 } |
779 } | 767 } |
780 | 768 |
781 void ProfileIOData::ShutdownOnUIThread() { | 769 void ProfileIOData::ShutdownOnUIThread() { |
782 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
783 | 771 |
784 if (signin_names_) | 772 if (signin_names_) |
785 signin_names_->ReleaseResourcesOnUIThread(); | 773 signin_names_->ReleaseResourcesOnUIThread(); |
786 | 774 |
787 google_services_username_.Destroy(); | 775 google_services_username_.Destroy(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 void ProfileIOData::SetCookieSettingsForTesting( | 832 void ProfileIOData::SetCookieSettingsForTesting( |
845 CookieSettings* cookie_settings) { | 833 CookieSettings* cookie_settings) { |
846 DCHECK(!cookie_settings_.get()); | 834 DCHECK(!cookie_settings_.get()); |
847 cookie_settings_ = cookie_settings; | 835 cookie_settings_ = cookie_settings; |
848 } | 836 } |
849 | 837 |
850 void ProfileIOData::set_signin_names_for_testing( | 838 void ProfileIOData::set_signin_names_for_testing( |
851 SigninNamesOnIOThread* signin_names) { | 839 SigninNamesOnIOThread* signin_names) { |
852 signin_names_.reset(signin_names); | 840 signin_names_.reset(signin_names); |
853 } | 841 } |
OLD | NEW |