Commit 63162150 authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

[Chromecast] Update extension request handler to load files too

If we recieve a request for an extension that doesn't have a 'cast_url'
key present defer to the normal extension request processor to load
the files from disk

This is also required to load background pages (as it is from disk)

Bug: b/73768170
Test: Load extension that loads from disk, verify fallback occurs
Change-Id: I7bf477f92dbebfd37077ed417e12d17a03d35308
Reviewed-on: https://chromium-review.googlesource.com/934924Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553682}
parent 85a7e025
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chromecast/browser/extension_request_protocol_handler.h" #include "chromecast/browser/extension_request_protocol_handler.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/info_map.h" #include "extensions/browser/info_map.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -265,6 +266,8 @@ net::URLRequestJob* ExtensionRequestProtocolHandler::MaybeCreateJob( ...@@ -265,6 +266,8 @@ net::URLRequestJob* ExtensionRequestProtocolHandler::MaybeCreateJob(
// This can't be done in the constructor as extensions::ExtensionSystem::Get // This can't be done in the constructor as extensions::ExtensionSystem::Get
// will fail until after this is constructed. // will fail until after this is constructed.
info_map_ = extensions::ExtensionSystem::Get(browser_context_)->info_map(); info_map_ = extensions::ExtensionSystem::Get(browser_context_)->info_map();
default_handler_ = extensions::CreateExtensionProtocolHandler(
false, const_cast<extensions::InfoMap*>(info_map_));
} }
const extensions::Extension* extension = const extensions::Extension* extension =
...@@ -277,8 +280,8 @@ net::URLRequestJob* ExtensionRequestProtocolHandler::MaybeCreateJob( ...@@ -277,8 +280,8 @@ net::URLRequestJob* ExtensionRequestProtocolHandler::MaybeCreateJob(
std::string cast_url; std::string cast_url;
if (!extension->manifest()->GetString("cast_url", &cast_url)) { if (!extension->manifest()->GetString("cast_url", &cast_url)) {
LOG(ERROR) << "No 'cast_url' value for extension"; // Defer to the default handler to load from disk.
return nullptr; return default_handler_->MaybeCreateJob(request, network_delegate);
} }
// Replace chrome-extension://<id> with whatever the extension wants to go to. // Replace chrome-extension://<id> with whatever the extension wants to go to.
......
...@@ -31,6 +31,8 @@ class ExtensionRequestProtocolHandler ...@@ -31,6 +31,8 @@ class ExtensionRequestProtocolHandler
private: private:
content::BrowserContext* const browser_context_; content::BrowserContext* const browser_context_;
mutable const extensions::InfoMap* info_map_ = nullptr; mutable const extensions::InfoMap* info_map_ = nullptr;
mutable std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
default_handler_;
}; };
} // namespace chromecast } // namespace chromecast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment