From 845d425b09367b2bf1fe0cc8f260744bb373316c Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Thu, 5 Jul 2018 11:16:46 -0700 Subject: [PATCH] Handle file:// with net::FileProtocolHandler and don't covert brave:// to file:// credit the patch to @bridiver fix https://github.com/brave/browser-laptop/issues/14642 Auditor: @bridiver, @diracdeltas --- atom/browser/atom_browser_context.cc | 9 ++++++++- .../browser/ui/webui/chrome_web_ui_controller_factory.cc | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index daa09d0fe4..5a0162375c 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -32,6 +32,7 @@ #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/file_protocol_handler.h" #include "net/url_request/ftp_protocol_handler.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_intercepting_job_factory.h" @@ -89,9 +90,15 @@ AtomBrowserContext::CreateURLRequestJobFactory( url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler)); job_factory->SetProtocolHandler( url::kFileScheme, + std::make_unique( + base::CreateTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::USER_VISIBLE, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}))); + job_factory->SetProtocolHandler( + "brave", base::WrapUnique( new asar::AsarProtocolHandler(base::CreateTaskRunnerWithTraits( - {base::MayBlock(), base::TaskPriority::USER_BLOCKING, + {base::MayBlock(), base::TaskPriority::USER_VISIBLE, base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})))); job_factory->SetProtocolHandler( url::kHttpScheme, diff --git a/chromium_src/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chromium_src/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index a37d90beba..b434c9a056 100644 --- a/chromium_src/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chromium_src/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -47,7 +47,7 @@ class BraveDataSource : public content::URLDataSource, const std::string& path, const content::ResourceRequestInfo::WebContentsGetter& wc_getter, const GotDataCallback& callback) override { - GURL url = GURL("file:///" + path); + GURL url = GURL("brave:///" + path); if (!url.is_valid()) { DLOG(WARNING) << "Invalid webui resource: brave://" << path; callback.Run(