Make the DebugDevTools API more generic.
This commit is contained in:
parent
1c07235121
commit
d37bf06b5a
3 changed files with 18 additions and 16 deletions
|
@ -417,7 +417,8 @@ void Window::InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
// 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
|
||||
|
|
|
@ -101,6 +101,14 @@ NativeWindow* NativeWindow::Create(base::DictionaryValue* options) {
|
|||
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.
|
||||
|
@ -203,16 +211,6 @@ void NativeWindow::InspectElement(int x, int y) {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -72,13 +72,19 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
|
||||
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);
|
||||
|
||||
|
@ -125,9 +131,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
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();
|
||||
|
|
Loading…
Reference in a new issue