diff --git a/brightray/browser/devtools_ui.cc b/brightray/browser/devtools_ui.cc index 2e08a32d8fb3..390a2dbf216b 100644 --- a/brightray/browser/devtools_ui.cc +++ b/brightray/browser/devtools_ui.cc @@ -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 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 bytes( + new base::RefCountedStaticMemory(resource.data(), resource.length())); + callback.Run(bytes.get()); + } + private: virtual ~BundledDataSource() {} DISALLOW_COPY_AND_ASSIGN(BundledDataSource); diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 59647b9a7f0a..c7d93a7aca00 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -38,11 +38,13 @@ const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0 }; -const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?" - "can_dock=%s&" - "toolbarColor=rgba(223,223,223,1)&" - "textColor=rgba(0,0,0,1)&" - "experiments=true"; +const char kChromeUIDevToolsURL[] = + "chrome-devtools://devtools/bundled/inspector.html?" + "can_dock=%s&" + "toolbarColor=rgba(223,223,223,1)&" + "textColor=rgba(0,0,0,1)&" + "experiments=true"; + const char kDevToolsBoundsPref[] = "brightray.devtools.bounds"; const char kDevToolsZoomPref[] = "brightray.devtools.zoom"; const char kDevToolsPreferences[] = "brightray.devtools.preferences";