|
@@ -20,7 +20,8 @@ namespace brightray {
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
-const char kChromeUIDevToolsBundledHost[] = "devtools";
|
|
|
+const char kChromeUIDevToolsHost[] = "devtools";
|
|
|
+const char kChromeUIDevToolsBundledPath[] = "bundled";
|
|
|
|
|
|
std::string PathWithoutParams(const std::string& path) {
|
|
|
return GURL(std::string("chrome-devtools://devtools/") + path)
|
|
@@ -53,19 +54,23 @@ class BundledDataSource : public content::URLDataSource {
|
|
|
|
|
|
// content::URLDataSource implementation.
|
|
|
std::string GetSource() const override {
|
|
|
- return kChromeUIDevToolsBundledHost;
|
|
|
+ return kChromeUIDevToolsHost;
|
|
|
}
|
|
|
|
|
|
void StartDataRequest(const std::string& path,
|
|
|
int render_process_id,
|
|
|
- int render_view_id,
|
|
|
+ int render_frame_id,
|
|
|
const GotDataCallback& callback) override {
|
|
|
- std::string filename = PathWithoutParams(path);
|
|
|
- base::StringPiece resource =
|
|
|
- content::DevToolsFrontendHost::GetFrontendResource(filename);
|
|
|
- scoped_refptr<base::RefCountedStaticMemory> bytes(
|
|
|
- new base::RefCountedStaticMemory(resource.data(), resource.length()));
|
|
|
- callback.Run(bytes.get());
|
|
|
+ // Serve request from local bundle.
|
|
|
+ std::string bundled_path_prefix(kChromeUIDevToolsBundledPath);
|
|
|
+ bundled_path_prefix += "/";
|
|
|
+ if (base::StartsWith(path, bundled_path_prefix,
|
|
|
+ base::CompareCase::INSENSITIVE_ASCII)) {
|
|
|
+ StartBundledDataRequest(path.substr(bundled_path_prefix.length()),
|
|
|
+ render_process_id, render_frame_id, callback);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ callback.Run(nullptr);
|
|
|
}
|
|
|
|
|
|
std::string GetMimeType(const std::string& path) const override {
|
|
@@ -84,6 +89,24 @@ class BundledDataSource : public content::URLDataSource {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ void StartBundledDataRequest(
|
|
|
+ const std::string& path,
|
|
|
+ int render_process_id,
|
|
|
+ int render_frame_id,
|
|
|
+ const content::URLDataSource::GotDataCallback& callback) {
|
|
|
+ std::string filename = PathWithoutParams(path);
|
|
|
+ base::StringPiece resource =
|
|
|
+ content::DevToolsFrontendHost::GetFrontendResource(filename);
|
|
|
+
|
|
|
+ DLOG_IF(WARNING, resource.empty())
|
|
|
+ << "Unable to find dev tool resource: " << filename
|
|
|
+ << ". If you compiled with debug_devtools=1, try running with "
|
|
|
+ "--debug-devtools.";
|
|
|
+ scoped_refptr<base::RefCountedStaticMemory> bytes(
|
|
|
+ new base::RefCountedStaticMemory(resource.data(), resource.length()));
|
|
|
+ callback.Run(bytes.get());
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
virtual ~BundledDataSource() {}
|
|
|
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|