| Index: chrome/browser/profiles/profile_io_data.cc
|
| diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
|
| index 19646787be9606ba0fd779951ef39ee6fa95e807..8060cebf7460ee783feec9f754f82bb0b8eb5979 100644
|
| --- a/chrome/browser/profiles/profile_io_data.cc
|
| +++ b/chrome/browser/profiles/profile_io_data.cc
|
| @@ -724,8 +724,9 @@ ProfileIOData* ProfileIOData::FromResourceContext(
|
| }
|
|
|
| // static
|
| -bool ProfileIOData::IsHandledProtocol(const std::string& scheme) {
|
| +bool ProfileIOData::IsBuiltInProtocol(const std::string& scheme) {
|
| DCHECK_EQ(scheme, base::ToLowerASCII(scheme));
|
| + // The list below MUST include every protocol that could return a response.
|
| static const char* const kProtocolList[] = {
|
| url::kFileScheme,
|
| content::kChromeDevToolsScheme,
|
| @@ -758,13 +759,13 @@ bool ProfileIOData::IsHandledProtocol(const std::string& scheme) {
|
| }
|
|
|
| // static
|
| -bool ProfileIOData::IsHandledURL(const GURL& url) {
|
| +bool ProfileIOData::HasBuiltInProtocol(const GURL& url) {
|
| if (!url.is_valid()) {
|
| // We handle error cases.
|
| return true;
|
| }
|
|
|
| - return IsHandledProtocol(url.scheme());
|
| + return IsBuiltInProtocol(url.scheme());
|
| }
|
|
|
| // static
|
| @@ -775,6 +776,7 @@ void ProfileIOData::InstallProtocolHandlers(
|
| protocol_handlers->begin();
|
| it != protocol_handlers->end();
|
| ++it) {
|
| + DCHECK(IsBuiltInProtocol(it->first));
|
| bool set_protocol = job_factory->SetProtocolHandler(
|
| it->first, base::WrapUnique(it->second.release()));
|
| DCHECK(set_protocol);
|
| @@ -1178,44 +1180,48 @@ ProfileIOData::SetUpJobFactoryDefaults(
|
| protocol_handler_interceptor,
|
| net::NetworkDelegate* network_delegate,
|
| net::HostResolver* host_resolver) const {
|
| - // NOTE(willchan): Keep these protocol handlers in sync with
|
| - // ProfileIOData::IsHandledProtocol().
|
| - bool set_protocol = job_factory->SetProtocolHandler(
|
| + // NOTE(nick): It is absolutely critical for the built-in protocol handlers to
|
| + // be enumerated by ProfileIOData::IsBuiltInProtocol(), so use this lambda to
|
| + // make sure you've got it right.
|
| + net::URLRequestJobFactoryImpl* job_factory_ptr = job_factory.get();
|
| + auto install_builtin_handler = [job_factory_ptr](
|
| + const char* p,
|
| + std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler> h) {
|
| + DCHECK(IsBuiltInProtocol(p)) << p;
|
| + bool set_protocol_succeeded =
|
| + job_factory_ptr->SetProtocolHandler(p, std::move(h));
|
| + DCHECK(set_protocol_succeeded);
|
| + };
|
| +
|
| + install_builtin_handler(
|
| url::kFileScheme,
|
| base::MakeUnique<net::FileProtocolHandler>(
|
| content::BrowserThread::GetBlockingPool()
|
| ->GetTaskRunnerWithShutdownBehavior(
|
| base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
|
| - DCHECK(set_protocol);
|
|
|
| #if defined(ENABLE_EXTENSIONS)
|
| DCHECK(extension_info_map_.get());
|
| // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
|
| bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
|
| - set_protocol = job_factory->SetProtocolHandler(
|
| - extensions::kExtensionScheme,
|
| - extensions::CreateExtensionProtocolHandler(is_incognito,
|
| - extension_info_map_.get()));
|
| - DCHECK(set_protocol);
|
| - set_protocol = job_factory->SetProtocolHandler(
|
| - extensions::kExtensionResourceScheme,
|
| - CreateExtensionResourceProtocolHandler());
|
| - DCHECK(set_protocol);
|
| + install_builtin_handler(extensions::kExtensionScheme,
|
| + extensions::CreateExtensionProtocolHandler(
|
| + is_incognito, extension_info_map_.get()));
|
| + install_builtin_handler(extensions::kExtensionResourceScheme,
|
| + CreateExtensionResourceProtocolHandler());
|
| #endif
|
| - set_protocol = job_factory->SetProtocolHandler(
|
| - url::kDataScheme, base::MakeUnique<net::DataProtocolHandler>());
|
| - DCHECK(set_protocol);
|
| + install_builtin_handler(url::kDataScheme,
|
| + base::MakeUnique<net::DataProtocolHandler>());
|
| #if defined(OS_CHROMEOS)
|
| if (profile_params_) {
|
| - set_protocol = job_factory->SetProtocolHandler(
|
| + install_builtin_handler(
|
| content::kExternalFileScheme,
|
| base::MakeUnique<chromeos::ExternalFileProtocolHandler>(
|
| profile_params_->profile));
|
| - DCHECK(set_protocol);
|
| }
|
| #endif // defined(OS_CHROMEOS)
|
| #if defined(OS_ANDROID)
|
| - set_protocol = job_factory->SetProtocolHandler(
|
| + install_builtin_handler(
|
| url::kContentScheme,
|
| content::ContentProtocolHandler::Create(
|
| content::BrowserThread::GetBlockingPool()
|
| @@ -1223,13 +1229,13 @@ ProfileIOData::SetUpJobFactoryDefaults(
|
| base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
|
| #endif
|
|
|
| - job_factory->SetProtocolHandler(
|
| + install_builtin_handler(
|
| url::kAboutScheme,
|
| base::MakeUnique<about_handler::AboutProtocolHandler>());
|
|
|
| #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
|
| - job_factory->SetProtocolHandler(
|
| - url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver));
|
| + install_builtin_handler(url::kFtpScheme,
|
| + net::FtpProtocolHandler::Create(host_resolver));
|
| #endif // !BUILDFLAG(DISABLE_FTP_SUPPORT)
|
|
|
| #if defined(DEBUG_DEVTOOLS)
|
|
|