diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index d69aab22fa8a..e31ebc4147e4 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -16,8 +16,11 @@ #include "chrome/browser/browser_process.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" +#include "net/ftp/ftp_network_layer.h" #include "net/url_request/data_protocol_handler.h" +#include "net/url_request/ftp_protocol_handler.h" #include "net/url_request/url_request_intercepting_job_factory.h" +#include "net/url_request/url_request_context.h" #include "url/url_constants.h" using content::BrowserThread; @@ -69,6 +72,13 @@ net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory( job_factory->SetProtocolHandler( url::kWssScheme, new HttpProtocolHandler(url::kWssScheme)); + auto host_resolver = url_request_context_getter() + ->GetURLRequestContext() + ->host_resolver(); + job_factory->SetProtocolHandler( + url::kFtpScheme, new net::FtpProtocolHandler( + new net::FtpNetworkLayer(host_resolver))); + // Set up interceptors in the reverse order. scoped_ptr top_job_factory = job_factory.Pass(); content::URLRequestInterceptorScopedVector::reverse_iterator it; diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 10ac9bbd6b7c..d7d115feb8e3 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -16,12 +16,15 @@ #include "base/strings/string_number_conversions.h" #include "content/public/renderer/render_view.h" #include "ipc/ipc_message_macros.h" +#include "net/base/net_module.h" +#include "net/grit/net_resources.h" #include "third_party/WebKit/public/web/WebDraggableRegion.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebKit.h" #include "third_party/WebKit/public/web/WebView.h" +#include "ui/base/resource/resource_bundle.h" #include "atom/common/node_includes.h" @@ -49,6 +52,16 @@ std::vector> ListValueToVector( return result; } +base::StringPiece NetResourceProvider(int key) { + if (key == IDR_DIR_HEADER_HTML) { + base::StringPiece html_data = + ui::ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_DIR_HEADER_HTML); + return html_data; + } + return base::StringPiece(); +} + } // namespace AtomRenderViewObserver::AtomRenderViewObserver( @@ -57,6 +70,8 @@ AtomRenderViewObserver::AtomRenderViewObserver( : content::RenderViewObserver(render_view), renderer_client_(renderer_client), document_created_(false) { + // Initialise resource for directory listing. + net::NetModule::SetResourceProvider(NetResourceProvider); } AtomRenderViewObserver::~AtomRenderViewObserver() {