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 "mojo/services/window_manager/window_manager_delegate.h"
|
||||||
#include "sky/tools/debugger/focus_rules.h"
|
#include "sky/tools/debugger/focus_rules.h"
|
||||||
#include "sky/tools/debugger/debugger.mojom.h"
|
#include "sky/tools/debugger/debugger.mojom.h"
|
||||||
|
#include "sky/viewer/services/inspector.mojom.h"
|
||||||
|
|
||||||
namespace sky {
|
namespace sky {
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
|||||||
mojo::ViewManager* view_manager,
|
mojo::ViewManager* view_manager,
|
||||||
mojo::View* root,
|
mojo::View* root,
|
||||||
mojo::ServiceProviderImpl* exported_services,
|
mojo::ServiceProviderImpl* exported_services,
|
||||||
scoped_ptr<mojo::ServiceProvider> remote_service_provider) override {
|
scoped_ptr<mojo::ServiceProvider> imported_services) override {
|
||||||
view_manager_ = view_manager;
|
view_manager_ = view_manager;
|
||||||
|
|
||||||
root_ = root;
|
root_ = root;
|
||||||
@ -104,10 +105,19 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
|||||||
// We can get Navigate commands before we've actually been
|
// We can get Navigate commands before we've actually been
|
||||||
// embedded into the view and content_ created.
|
// embedded into the view and content_ created.
|
||||||
// Just save the last one.
|
// Just save the last one.
|
||||||
if (content_)
|
if (content_) {
|
||||||
content_->Embed(url);
|
scoped_ptr<mojo::ServiceProviderImpl> exported_services(
|
||||||
else
|
new mojo::ServiceProviderImpl());
|
||||||
|
viewer_services_ = content_->Embed(url, exported_services.Pass());
|
||||||
|
} else {
|
||||||
pending_url_ = url;
|
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_;
|
scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
|
||||||
@ -117,6 +127,8 @@ class SkyDebugger : public mojo::ApplicationDelegate,
|
|||||||
mojo::View* content_;
|
mojo::View* content_;
|
||||||
std::string pending_url_;
|
std::string pending_url_;
|
||||||
|
|
||||||
|
scoped_ptr<mojo::ServiceProvider> viewer_services_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SkyDebugger);
|
DISALLOW_COPY_AND_ASSIGN(SkyDebugger);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ module sky {
|
|||||||
|
|
||||||
interface Debugger {
|
interface Debugger {
|
||||||
NavigateToURL(string url);
|
NavigateToURL(string url);
|
||||||
|
InjectInspector();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,10 @@ class Prompt : public mojo::ApplicationDelegate {
|
|||||||
Reload();
|
Reload();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (command == "inspect") {
|
||||||
|
Inspect();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (command.size() == 1) {
|
if (command.size() == 1) {
|
||||||
char c = command[0];
|
char c = command[0];
|
||||||
if (c == 'h')
|
if (c == 'h')
|
||||||
@ -111,16 +115,25 @@ class Prompt : public mojo::ApplicationDelegate {
|
|||||||
<< "Sky Debugger" << std::endl
|
<< "Sky Debugger" << std::endl
|
||||||
<< "============" << std::endl
|
<< "============" << std::endl
|
||||||
<< "Type a URL to load in the debugger, enter to reload." << std::endl
|
<< "Type a URL to load in the debugger, enter to reload." << std::endl
|
||||||
<< "Commands: help -- Help" << std::endl
|
<< "Commands: help -- Help" << std::endl
|
||||||
<< " trace -- Capture a trace" << std::endl
|
<< " trace -- Capture a trace" << std::endl
|
||||||
<< " reload -- Reload the current page" << std::endl
|
<< " reload -- Reload the current page" << std::endl
|
||||||
<< " q -- Quit" << std::endl;
|
<< " inspect -- Inspect the current page" << std::endl
|
||||||
|
<< " q -- Quit" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reload() {
|
void Reload() {
|
||||||
debugger_->NavigateToURL(url_);
|
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() {
|
void Quit() {
|
||||||
std::cout << "quitting" << std::endl;
|
std::cout << "quitting" << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user