return v8::Undefined();
}
+// static
+v8::Handle<v8::Value> Window::FocusOnWebView(const v8::Arguments &args) {
+ UNWRAP_WINDOW_AND_CHECK;
+
+ self->window_->FocusOnWebView();
+
+ return v8::Undefined();
+}
+
+// static
+v8::Handle<v8::Value> Window::BlurWebView(const v8::Arguments &args) {
+ UNWRAP_WINDOW_AND_CHECK;
+
+ self->window_->BlurWebView();
+
+ return v8::Undefined();
+}
+
// static
v8::Handle<v8::Value> Window::GetPageTitle(const v8::Arguments &args) {
UNWRAP_WINDOW_AND_CHECK;
NODE_SET_PROTOTYPE_METHOD(t, "isKiosk", IsKiosk);
NODE_SET_PROTOTYPE_METHOD(t, "openDevTools", OpenDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
+ NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView);
+ NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView);
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
NODE_SET_PROTOTYPE_METHOD(t, "isLoading", IsLoading);
static v8::Handle<v8::Value> IsKiosk(const v8::Arguments &args);
static v8::Handle<v8::Value> OpenDevTools(const v8::Arguments &args);
static v8::Handle<v8::Value> CloseDevTools(const v8::Arguments &args);
+ static v8::Handle<v8::Value> FocusOnWebView(const v8::Arguments &args);
+ static v8::Handle<v8::Value> BlurWebView(const v8::Arguments &args);
// APIs for WebContents.
static v8::Handle<v8::Value> GetPageTitle(const v8::Arguments &args);
inspectable_web_contents()->GetView()->CloseDevTools();
}
+void NativeWindow::FocusOnWebView() {
+ GetWebContents()->GetRenderViewHost()->Focus();
+}
+
+void NativeWindow::BlurWebView() {
+ GetWebContents()->GetRenderViewHost()->Blur();
+}
+
void NativeWindow::CloseWebContents() {
bool prevent_default = false;
FOR_EACH_OBSERVER(NativeWindowObserver,
WindowList::RemoveWindow(this);
}
+void NativeWindow::NotifyWindowBlur() {
+ FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
+}
+
// Window opened by window.open.
void NativeWindow::WebContentsCreated(
content::WebContents* source_contents,
}
void NativeWindow::ActivateContents(content::WebContents* contents) {
- GetWebContents()->GetRenderViewHost()->Focus();
+ FocusOnWebView();
}
void NativeWindow::DeactivateContents(content::WebContents* contents) {
- GetWebContents()->GetRenderViewHost()->Blur();
+ BlurWebView();
}
void NativeWindow::MoveContents(content::WebContents* source,
virtual bool IsClosed() const { return is_closed_; }
virtual void OpenDevTools();
virtual void CloseDevTools();
+ virtual void FocusOnWebView();
+ virtual void BlurWebView();
// The same with closing a tab in a real browser.
//
}
void NotifyWindowClosed();
+ void NotifyWindowBlur();
// Implementations of content::WebContentsDelegate.
virtual void WebContentsCreated(content::WebContents* source_contents,
NSWindow*& window() { return window_; }
+ void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
+
protected:
void SetNonLionFullscreen(bool fullscreen);
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "content/public/browser/render_view_host.h"
@interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> {
@private
return self;
}
-- (void)windowWillClose:(NSNotification *)notification {
+- (void)windowDidResignKey:(NSNotification*)notification {
+ shell_->NotifyWindowBlur();
+}
+
+- (void)windowWillClose:(NSNotification*)notification {
shell_->window() = nil;
[self autorelease];
}
// Called when the window is closed.
virtual void OnWindowClosed() {}
+
+ // Called when window loses focus.
+ virtual void OnWindowBlur() {}
};
} // namespace atom