browserWindow: adding devtools-focused event

This commit is contained in:
Robo 2015-03-31 21:15:06 +05:30
parent ce3d9f44ff
commit 3aefa5f549
6 changed files with 17 additions and 0 deletions

View file

@ -139,6 +139,10 @@ void Window::OnRendererResponsive() {
Emit("responsive");
}
void Window::OnDevToolsFocus() {
Emit("devtools-focused");
}
// static
mate::Wrappable* Window::New(v8::Isolate* isolate,
const mate::Dictionary& options) {

View file

@ -64,6 +64,7 @@ class Window : public mate::EventEmitter,
void OnWindowLeaveFullScreen() override;
void OnRendererUnresponsive() override;
void OnRendererResponsive() override;
void OnDevToolsFocus() override;
private:
// APIs for NativeWindow.

View file

@ -762,6 +762,10 @@ void NativeWindow::DevToolsAppendToFile(const std::string& url,
CallDevToolsFunction("DevToolsAPI.appendedToURL", &url_value);
}
void NativeWindow::DevToolsFocused() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsFocus());
}
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
if (!window_unresposive_closure_.IsCancelled())
return;

View file

@ -290,6 +290,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
bool save_as) override;
void DevToolsAppendToFile(const std::string& url,
const std::string& content) override;
void DevToolsFocused() override;
// Whether window has standard frame.
bool has_frame_;

View file

@ -50,6 +50,9 @@ class NativeWindowObserver {
virtual void OnWindowEnterFullScreen() {}
virtual void OnWindowLeaveFullScreen() {}
// Called when devtools window gets focused.
virtual void OnDevToolsFocus() {}
// Called when renderer is hung.
virtual void OnRendererUnresponsive() {}

View file

@ -184,6 +184,10 @@ Emitted when devtools is opened.
Emitted when devtools is closed.
### Event: 'devtools-focused'
Emitted when devtools is focused / opened.
### Class Method: BrowserWindow.getAllWindows()
Returns an array of all opened browser windows.