--- a/chrome/browser/devtools/chrome_devtools_session.cc +++ b/chrome/browser/devtools/chrome_devtools_session.cc @@ -100,7 +100,8 @@ ChromeDevToolsSession::ChromeDevToolsSession( if (IsDomainAvailableToUntrustedClient() || channel->GetClient()->IsTrusted()) { target_handler_ = std::make_unique( - &dispatcher_, channel->GetClient()->IsTrusted()); + &dispatcher_, channel->GetClient()->IsTrusted(), + channel->GetClient()->MayReadLocalFiles()); } if (IsDomainAvailableToUntrustedClient() || channel->GetClient()->IsTrusted()) { --- a/chrome/browser/devtools/protocol/target_handler.cc +++ b/chrome/browser/devtools/protocol/target_handler.cc @@ -40,8 +40,9 @@ NavigateParams CreateNavigateParams(Profile* profile, } // namespace TargetHandler::TargetHandler(protocol::UberDispatcher* dispatcher, - bool is_trusted) - : is_trusted_(is_trusted) { + bool is_trusted, + bool may_read_local_files) + : is_trusted_(is_trusted), may_read_local_files_(may_read_local_files) { protocol::Target::Dispatcher::wire(dispatcher, this); } @@ -124,7 +125,8 @@ protocol::Response TargetHandler::CreateTarget( gurl = GURL(url::kAboutBlankURL); } - if (!is_trusted_ && gurl.SchemeIs(content::kChromeUIUntrustedScheme)) { + if ((!is_trusted_ && gurl.SchemeIs(content::kChromeUIUntrustedScheme)) || + (!may_read_local_files_ && gurl.SchemeIsFile())) { return protocol::Response::ServerError( "Refusing to create a target with the specified URL"); } --- a/chrome/browser/devtools/protocol/target_handler.h +++ b/chrome/browser/devtools/protocol/target_handler.h @@ -16,7 +16,9 @@ using RemoteLocations = std::set; class TargetHandler : public protocol::Target::Backend { public: - TargetHandler(protocol::UberDispatcher* dispatcher, bool is_trusted); + TargetHandler(protocol::UberDispatcher* dispatcher, + bool is_trusted, + bool may_read_local_files); TargetHandler(const TargetHandler&) = delete; TargetHandler& operator=(const TargetHandler&) = delete; @@ -43,6 +45,7 @@ class TargetHandler : public protocol::Target::Backend { private: RemoteLocations remote_locations_; const bool is_trusted_; + const bool may_read_local_files_; }; #endif // CHROME_BROWSER_DEVTOOLS_PROTOCOL_TARGET_HANDLER_H_