Use the new devtools URL
This commit is contained in:
parent
f077a51459
commit
dca5c763e9
2 changed files with 39 additions and 14 deletions
|
@ -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);
|
||||
|
|
|
@ -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?"
|
||||
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";
|
||||
|
|
Loading…
Reference in a new issue