has_frame_(true),
is_closed_(false),
node_integration_("all"),
+ has_dialog_attached_(false),
weak_factory_(this),
inspectable_web_contents_(
brightray::InspectableWebContents::Create(web_contents)) {
Show();
}
+bool NativeWindow::HasModalDialog() {
+ return has_dialog_attached_;
+}
+
void NativeWindow::OpenDevTools() {
inspectable_web_contents()->ShowDevTools();
}
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
CapturePageCallback;
+ class DialogScope {
+ public:
+ DialogScope(NativeWindow* window)
+ : window_(window) {
+ if (window_ != NULL)
+ window_->set_has_dialog_attached(true);
+ }
+
+ ~DialogScope() {
+ if (window_ != NULL)
+ window_->set_has_dialog_attached(false);
+ }
+
+ private:
+ NativeWindow* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(DialogScope);
+ };
+
virtual ~NativeWindow();
// Create window with existing WebContents.
virtual void FlashFrame(bool flash) = 0;
virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0;
- virtual bool HasModalDialog() = 0;
+ virtual bool HasModalDialog();
virtual gfx::NativeWindow GetNativeWindow() = 0;
virtual bool IsClosed() const { return is_closed_; }
bool has_frame() const { return has_frame_; }
std::string node_integration() const { return node_integration_; }
+ void set_has_dialog_attached(bool has_dialog_attached) {
+ has_dialog_attached_ = has_dialog_attached;
+ }
+
protected:
explicit NativeWindow(content::WebContents* web_contents,
base::DictionaryValue* options);
// The security token of iframe.
std::string node_integration_;
+ // There is a dialog that has been attached to window.
+ bool has_dialog_attached_;
+
// Closure that would be called when window is unresponsive when closing,
// it should be cancelled when we can prove that the window is responsive.
base::CancelableClosure window_unresposive_closure_;
DISALLOW_COPY_AND_ASSIGN(NativeWindowFramelessView);
};
-bool WindowHasModalDialog(HWND parent, HWND except, HWND after = NULL) {
- HWND hwnd = ::FindWindowEx(parent, after, NULL, NULL);
- if (hwnd != except &&
- (::GetWindowLong(hwnd, GWL_STYLE) & (WS_VISIBLE | WS_POPUP)))
- return true;
- else if (hwnd == NULL)
- return false;
- else
- return WindowHasModalDialog(parent, except, hwnd);
-}
-
} // namespace
NativeWindowWin::NativeWindowWin(content::WebContents* web_contents,
return IsFullscreen();
}
-bool NativeWindowWin::HasModalDialog() {
- return WindowHasModalDialog(GetNativeWindow(),
- GetWebContents()->GetView()->GetNativeView());
-}
-
gfx::NativeWindow NativeWindowWin::GetNativeWindow() {
return window_->GetNativeView();
}
virtual void FlashFrame(bool flash) OVERRIDE;
virtual void SetKiosk(bool kiosk) OVERRIDE;
virtual bool IsKiosk() OVERRIDE;
- virtual bool HasModalDialog() OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
void OnMenuCommand(int position, HMENU menu);
}
bool Show(atom::NativeWindow* parent_window) {
+ atom::NativeWindow::DialogScope dialog_scope(parent_window);
HWND window = parent_window ? parent_window->GetNativeWindow() : NULL;
return dialog_->DoModal(window) == IDOK;
}
string16 title_;
views::Widget* widget_;
views::MessageBoxView* message_box_view_;
+ scoped_ptr<NativeWindow::DialogScope> dialog_scope_;
std::vector<views::LabelButton*> buttons_;
MessageBoxCallback callback_;
result_(-1),
title_(UTF8ToUTF16(title)),
widget_(NULL),
- message_box_view_(NULL) {
+ message_box_view_(NULL),
+ dialog_scope_(new NativeWindow::DialogScope(parent_window)) {
DCHECK_GT(buttons.size(), 0u);
set_owned_by_client();
void MessageDialog::WindowClosing() {
should_close_ = true;
+ dialog_scope_.reset();
if (delete_on_close_) {
callback_.Run(GetResult());