Add inspect command to skydb
This CL adds an "inspect" command to skydb that injects the inspector module into the page and prints some instructions for opening the inspector. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/690433004
This commit is contained in:
parent
0335886abf
commit
c56ab49799
@ -16,6 +16,7 @@
|
||||
#include "mojo/services/window_manager/window_manager_delegate.h"
|
||||
#include "sky/tools/debugger/focus_rules.h"
|
||||
#include "sky/tools/debugger/debugger.mojom.h"
|
||||
#include "sky/viewer/services/inspector.mojom.h"
|
||||
|
||||
namespace sky {
|
||||
|
||||
@ -58,7 +59,7 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
||||
mojo::ViewManager* view_manager,
|
||||
mojo::View* root,
|
||||
mojo::ServiceProviderImpl* exported_services,
|
||||
scoped_ptr<mojo::ServiceProvider> remote_service_provider) override {
|
||||
scoped_ptr<mojo::ServiceProvider> imported_services) override {
|
||||
view_manager_ = view_manager;
|
||||
|
||||
root_ = root;
|
||||
@ -104,10 +105,19 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
||||
// We can get Navigate commands before we've actually been
|
||||
// embedded into the view and content_ created.
|
||||
// Just save the last one.
|
||||
if (content_)
|
||||
content_->Embed(url);
|
||||
else
|
||||
if (content_) {
|
||||
scoped_ptr<mojo::ServiceProviderImpl> exported_services(
|
||||
new mojo::ServiceProviderImpl());
|
||||
viewer_services_ = content_->Embed(url, exported_services.Pass());
|
||||
} else {
|
||||
pending_url_ = url;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void InjectInspector() override {
|
||||
InspectorServicePtr inspector_service;
|
||||
mojo::ConnectToService(viewer_services_.get(), &inspector_service);
|
||||
inspector_service->Inject();
|
||||
}
|
||||
|
||||
scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
|
||||
@ -117,6 +127,8 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
||||
mojo::View* content_;
|
||||
std::string pending_url_;
|
||||
|
||||
scoped_ptr<mojo::ServiceProvider> viewer_services_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SkyDebugger);
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@ module sky {
|
||||
|
||||
interface Debugger {
|
||||
NavigateToURL(string url);
|
||||
InjectInspector();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ class Prompt : public mojo::ApplicationDelegate {
|
||||
Reload();
|
||||
return true;
|
||||
}
|
||||
if (command == "inspect") {
|
||||
Inspect();
|
||||
return true;
|
||||
}
|
||||
if (command.size() == 1) {
|
||||
char c = command[0];
|
||||
if (c == 'h')
|
||||
@ -111,16 +115,25 @@ class Prompt : public mojo::ApplicationDelegate {
|
||||
<< "Sky Debugger" << std::endl
|
||||
<< "============" << std::endl
|
||||
<< "Type a URL to load in the debugger, enter to reload." << std::endl
|
||||
<< "Commands: help -- Help" << std::endl
|
||||
<< " trace -- Capture a trace" << std::endl
|
||||
<< " reload -- Reload the current page" << std::endl
|
||||
<< " q -- Quit" << std::endl;
|
||||
<< "Commands: help -- Help" << std::endl
|
||||
<< " trace -- Capture a trace" << std::endl
|
||||
<< " reload -- Reload the current page" << std::endl
|
||||
<< " inspect -- Inspect the current page" << std::endl
|
||||
<< " q -- Quit" << std::endl;
|
||||
}
|
||||
|
||||
void Reload() {
|
||||
debugger_->NavigateToURL(url_);
|
||||
}
|
||||
|
||||
void Inspect() {
|
||||
debugger_->InjectInspector();
|
||||
std::cout
|
||||
<< "Open the following URL in Chrome:" << std::endl
|
||||
<< "chrome-devtools://devtools/bundled/devtools.html?ws=localhost:9898"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void Quit() {
|
||||
std::cout << "quitting" << std::endl;
|
||||
exit(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user