Add the debugDevTools JS API.

This commit is contained in:
Cheng Zhao 2014-02-24 12:08:33 +08:00
parent 8b9d35d84e
commit eaedac2536
4 changed files with 20 additions and 10 deletions

View file

@ -414,6 +414,12 @@ void Window::InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args) {
self->window_->InspectElement(x, y);
}
// static
void Window::DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
self->window_->DebugDevTools();
}
// static
void Window::FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
@ -663,6 +669,7 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "isDevToolsOpened", IsDevToolsOpened);
NODE_SET_PROTOTYPE_METHOD(t, "inspectElement", InspectElement);
NODE_SET_PROTOTYPE_METHOD(t, "debugDevTools", DebugDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView);
NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView);
NODE_SET_PROTOTYPE_METHOD(t, "isWebViewFocused", IsWebViewFocused);

View file

@ -86,6 +86,7 @@ class Window : public EventEmitter,
static void CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args);
static void InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args);
static void DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
static void FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
static void BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
static void IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args);

View file

@ -167,8 +167,6 @@ bool NativeWindow::HasModalDialog() {
void NativeWindow::OpenDevTools() {
inspectable_web_contents()->ShowDevTools();
DebugDevTools();
}
void NativeWindow::CloseDevTools() {
@ -187,14 +185,16 @@ void NativeWindow::InspectElement(int x, int y) {
agent->InspectElement(x, y);
}
void NativeWindow::DebugDevTools() {
if (!IsDevToolsOpened())
return;
scoped_ptr<NativeWindow> NativeWindow::DebugDevTools() {
scoped_ptr<NativeWindow> window;
if (IsDevToolsOpened()) {
base::DictionaryValue options;
window.reset(NativeWindow::Create(&options));
window->devtools_delegate_.reset(new DevToolsDelegate(
window.get(), GetDevToolsWebContents()));
}
base::DictionaryValue options;
NativeWindow* window = NativeWindow::Create(&options);
window->devtools_delegate_.reset(new DevToolsDelegate(
window, GetDevToolsWebContents()));
return window.Pass();
}
void NativeWindow::FocusOnWebView() {

View file

@ -128,7 +128,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void CloseDevTools();
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
virtual void DebugDevTools();
// Creates a new window to debug the devtools.
virtual scoped_ptr<NativeWindow> DebugDevTools();
virtual void FocusOnWebView();
virtual void BlurWebView();