// static
void Window::DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
- self->window_->DebugDevTools();
+ if (self->window_->IsDevToolsOpened())
+ NativeWindow::Debug(self->window_->GetDevToolsWebContents());
}
// static
return Create(content::WebContents::Create(create_params), options);
}
+// static
+NativeWindow* NativeWindow::Debug(content::WebContents* web_contents) {
+ base::DictionaryValue options;
+ NativeWindow* window = NativeWindow::Create(&options);
+ window->devtools_delegate_.reset(new DevToolsDelegate(window, web_contents));
+ return window;
+}
+
// static
NativeWindow* NativeWindow::FromRenderView(int process_id, int routing_id) {
// Stupid iterating.
agent->InspectElement(x, y);
}
-void NativeWindow::DebugDevTools() {
- if (!IsDevToolsOpened())
- return;
-
- base::DictionaryValue options;
- NativeWindow* window = NativeWindow::Create(&options);
- window->devtools_delegate_.reset(new DevToolsDelegate(
- window, GetDevToolsWebContents()));
-}
-
void NativeWindow::FocusOnWebView() {
GetWebContents()->GetRenderViewHost()->Focus();
}
virtual ~NativeWindow();
- // Create window with existing WebContents.
+ // Create window with existing WebContents, the caller is responsible for
+ // managing the window's live.
static NativeWindow* Create(content::WebContents* web_contents,
base::DictionaryValue* options);
- // Create window with new WebContents.
+ // Create window with new WebContents, the caller is responsible for
+ // managing the window's live.
static NativeWindow* Create(base::DictionaryValue* options);
+ // Creates a devtools window to debug the WebContents, the returned window
+ // will manage its own life.
+ static NativeWindow* Debug(content::WebContents* web_contents);
+
// Find a window from its process id and routing id.
static NativeWindow* FromRenderView(int process_id, int routing_id);
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
- // Creates a new window to debug the devtools.
- virtual void DebugDevTools();
-
virtual void FocusOnWebView();
virtual void BlurWebView();
virtual bool IsWebViewFocused();